Skip to content

Commit

Permalink
Added ExperimentList.all_laue(). Added test for ExperimentList.all_*().
Browse files Browse the repository at this point in the history
  • Loading branch information
toastisme committed May 2, 2024
1 parent 7356de7 commit 4e8320c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dxtbx/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ def all_tof(self):
"""Check if all the experiments are time-of-flight"""
return all(exp.get_type() == ExperimentType.TOF for exp in self)

def all_laue(self):
"""Check if all the experiments are Laue experiments"""
return all(exp.get_type() == ExperimentType.LAUE for exp in self)

def to_dict(self):
"""Serialize the experiment list to dictionary."""

Expand Down
70 changes: 70 additions & 0 deletions tests/model/test_experiment_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,3 +1202,73 @@ def test_from_templates(dials_data):
assert len(expts) == 1
assert expts[0].imageset.get_template() == str(template)
assert len(expts[0].imageset) == 45


def test_experiment_list_all():
experiments = ExperimentList()
for i in range(3):
experiments.append(Experiment())

assert experiments.all_stills()
experiments[0].goniometer = Goniometer()
assert experiments.all_stills()
experiments[1].goniometer = Goniometer()
experiments[2].goniometer = Goniometer()
assert experiments.all_stills()

experiments[0].beam = BeamFactory.make_polychromatic_beam(
direction=(0, 0, -1),
sample_to_source_distance=(100),
probe=Probe.xray,
wavelength_range=(1, 10),
)
assert not experiments.all_stills()
experiments[1].beam = BeamFactory.make_polychromatic_beam(
direction=(0, 0, -1),
sample_to_source_distance=(100),
probe=Probe.xray,
wavelength_range=(1, 10),
)
experiments[2].beam = BeamFactory.make_polychromatic_beam(
direction=(0, 0, -1),
sample_to_source_distance=(100),
probe=Probe.xray,
wavelength_range=(1, 10),
)
assert experiments.all_laue()

experiments[0].beam = Beam()
assert not experiments.all_laue()
experiments[1].beam = Beam()
experiments[2].beam = Beam()
assert experiments.all_stills()

experiments[0].scan = Scan((1, 1000), (0, 0.05))
assert not experiments.all_stills()
experiments[1].scan = Scan((1, 1000), (0, 0.05))
experiments[2].scan = Scan((1, 1000), (0, 0.05))
assert experiments.all_rotations()

experiments[0].scan = ScanFactory.make_scan_from_properties(
(1, 10), properties={"time_of_flight": list(range(10))}
)
assert not experiments.all_rotations()
experiments[1].scan = ScanFactory.make_scan_from_properties(
(1, 10), properties={"time_of_flight": list(range(10))}
)
experiments[2].scan = ScanFactory.make_scan_from_properties(
(1, 10), properties={"time_of_flight": list(range(10))}
)
assert experiments.all_tof()

experiments[0].scan = ScanFactory.make_scan_from_properties(
(1, 10), properties={"other_property": list(range(10))}
)
assert not experiments.all_tof()
experiments[1].scan = ScanFactory.make_scan_from_properties(
(1, 10), properties={"other_property": list(range(10))}
)
experiments[2].scan = ScanFactory.make_scan_from_properties(
(1, 10), properties={"other_property": list(range(10))}
)
assert experiments.all_stills()

0 comments on commit 4e8320c

Please sign in to comment.