Skip to content

Commit

Permalink
Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeilstenedmands committed Oct 23, 2023
1 parent 9b2d4d2 commit f87a4b4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/dials/algorithms/indexing/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions tests/algorithms/indexing/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))
Expand Down
12 changes: 6 additions & 6 deletions tests/algorithms/indexing/test_phi_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
]
)
Expand All @@ -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,
)
]
)
Expand Down

0 comments on commit f87a4b4

Please sign in to comment.