Skip to content

Commit

Permalink
Test scans, beams, and gonios too
Browse files Browse the repository at this point in the history
  • Loading branch information
phyy-nx committed Mar 25, 2023
1 parent 5f63944 commit a860cd8
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/nexus/test_nxmx_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dxtbx.model.experiment_list import ExperimentListFactory
from dxtbx.format.nxmx_writer import NXmxWriter, phil_scope
from dxtbx.format.nexus import h5str
from libtbx.test_utils import approx_equal
from libtbx.phil import parse


Expand Down Expand Up @@ -39,7 +40,7 @@ def test_writer_jf16M(dials_data, tmpdir):

NXmxWriter(params)(expts1)

expts2 = ExperimentListFactory.from_filenames([tmpdir / "4img.h5"])
expts2 = ExperimentListFactory.from_filenames([output_file])

def recursive_test(pg1, pg2):
assert pg1.is_similar_to(pg2)
Expand All @@ -49,6 +50,13 @@ def recursive_test(pg1, pg2):
for d1, d2 in zip(expts1.detectors(), expts2.detectors()):
recursive_test(d1.hierarchy(), d2.hierarchy())

for b1, b2 in zip(expts1.beams(), expts2.beams()):
assert approx_equal(b1.get_wavelength(), b2.get_wavelength())
assert approx_equal(b2.get_s0(), b2.get_s0())

assert not (any(expts2.scans()))
assert not (any(expts2.goniometers()))


def test_writer_x4wide(dials_data, tmpdir):
cbfspath = dials_data("x4wide", pathlib=True) / "X4_wide_M1S4_2_000*.cbf"
Expand Down Expand Up @@ -82,3 +90,14 @@ def recursive_test(pg1, pg2):

for d1, d2 in zip(expts1.detectors(), expts2.detectors()):
recursive_test(d1.hierarchy(), d2.hierarchy())

for b1, b2 in zip(expts1.beams(), expts2.beams()):
assert approx_equal(b1.get_wavelength(), b2.get_wavelength())
assert approx_equal(b2.get_s0(), b2.get_s0())

for scan1, scan2 in zip(expts1.scans(), expts2.scans()):
assert approx_equal(scan1.get_array_range(), scan2.get_array_range())
assert approx_equal(scan1.get_oscillation(), scan2.get_oscillation())

for gonio1, gonio2 in zip(expts1.goniometers(), expts2.goniometers()):
assert approx_equal(gonio1.get_rotation_axis(), gonio2.get_rotation_axis())

0 comments on commit a860cd8

Please sign in to comment.