From f87a4b45a879bf7f8bf7578247eb5f6e4e5695d0 Mon Sep 17 00:00:00 2001 From: James Beilsten-Edmands <30625594+jbeilstenedmands@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:41:09 +0100 Subject: [PATCH] Fix some tests --- src/dials/algorithms/indexing/indexer.py | 4 ++++ tests/algorithms/indexing/test_index.py | 13 ++++++++++--- tests/algorithms/indexing/test_phi_scan.py | 12 ++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/dials/algorithms/indexing/indexer.py b/src/dials/algorithms/indexing/indexer.py index 8bdfa828e5..0b3928ab09 100644 --- a/src/dials/algorithms/indexing/indexer.py +++ b/src/dials/algorithms/indexing/indexer.py @@ -691,6 +691,10 @@ def index(self): refined_reflections.unset_flags( sel.iselection(), refined_reflections.flags.indexed ) + self.unindexed_reflections.extend( + refined_reflections.select(sel) + ) + refined_reflections.del_selected(sel) break self._unit_cell_volume_sanity_check(experiments, refined_experiments) diff --git a/tests/algorithms/indexing/test_index.py b/tests/algorithms/indexing/test_index.py index a1d8dedc2c..39a39a225e 100644 --- a/tests/algorithms/indexing/test_index.py +++ b/tests/algorithms/indexing/test_index.py @@ -68,12 +68,17 @@ def run_indexing( assert out_refls.is_file() experiments_list = load.experiment_list(out_expts, check_format=False) - assert len(experiments_list.crystals()) == n_expected_lattices + assert ( + len([c for c in experiments_list.crystals() if c is not None]) + == n_expected_lattices + ) indexed_reflections = flex.reflection_table.from_file(out_refls) indexed_reflections.assert_experiment_identifiers_are_consistent(experiments_list) rmsds = None - for i, experiment in enumerate(experiments_list): + for experiment in experiments_list: + if experiment.crystal is None: + continue assert unit_cells_are_similar( experiment.crystal.get_unit_cell(), expected_unit_cell, @@ -88,7 +93,9 @@ def run_indexing( sg.type().hall_symbol(), expected_hall_symbol, ) - reflections = indexed_reflections.select(indexed_reflections["id"] == i) + reflections = indexed_reflections.select_on_experiment_identifiers( + [experiment.identifier] + ) mi = reflections["miller_index"] assert (mi != (0, 0, 0)).count(False) == 0 reflections = reflections.select(mi != (0, 0, 0)) diff --git a/tests/algorithms/indexing/test_phi_scan.py b/tests/algorithms/indexing/test_phi_scan.py index 3bfdc95488..ad673468d7 100644 --- a/tests/algorithms/indexing/test_phi_scan.py +++ b/tests/algorithms/indexing/test_phi_scan.py @@ -97,9 +97,9 @@ def test_run(dials_data, tmp_path): assert result_old.rmsds == pytest.approx(result_new.rmsds, abs=1e-6) assert result_old.experiments[ - 0 + 1 ].crystal.get_unit_cell().parameters() == pytest.approx( - result_new.experiments[0].crystal.get_unit_cell().parameters(), abs=1e-6 + result_new.experiments[1].crystal.get_unit_cell().parameters(), abs=1e-6 ) # Now test refinement gradients are correct @@ -110,9 +110,9 @@ def test_run(dials_data, tmp_path): detector=imageset_old.get_detector(), goniometer=gonio_old, scan=imageset_old.get_scan(), - crystal=result_old.experiments[0].crystal, + crystal=result_old.experiments[1].crystal, imageset=None, - identifier=result_old.experiments[0].identifier, + identifier=result_old.experiments[1].identifier, ) ] ) @@ -123,9 +123,9 @@ def test_run(dials_data, tmp_path): detector=imageset_new.get_detector(), goniometer=gonio_new, scan=imageset_new.get_scan(), - crystal=result_new.experiments[0].crystal, + crystal=result_new.experiments[1].crystal, imageset=None, - identifier=result_new.experiments[0].identifier, + identifier=result_new.experiments[1].identifier, ) ] )