def test_find_class_softlink(nexus_file): """ Test that nexus.find_class follows soft links. Call find_class on /entry/instrument and assert that it correctly follows the soft link to /entry/sample/beam. """ with h5py.File(nexus_file, "r") as fr: assert len(nexus.find_class(fr["entry/instrument"], "NXbeam")) == 1 assert len(nexus.find_class(fr["entry/sample"], "NXbeam")) == 1
def test_find_class(nexus_file): """ Test dxtbx.format.nexus.find_class 1. Ensure that nexus.find_class finds the single NXbeam child of /entry/sample. 2. Ensure that the broken link /entry/instrument/broken_link exists but is ignored by nexus.find_class, even in a search for children without an NX_class. """ with h5py.File(nexus_file, "r") as fr: beams = nexus.find_class(fr["entry/sample"], "NXbeam") assert len(beams) == 1 assert beams[0].name == "/entry/sample/beam" instrument = fr["entry/instrument"] classless = nexus.find_class(instrument, None) assert "broken_link" in instrument and not classless
def understand(image_file): import h5py is_nexus_still = False try: from dxtbx.format.nexus import find_entries, find_class # Get the file handle handle = h5py.File(image_file, 'r') for entry in find_entries(handle, "/"): for sample in find_class(entry, "NXsample"): if 'depends_on' not in sample: is_nexus_still = True except IOError: return False return is_nexus_still
def understand(image_file): is_nexus_still = False try: # Get the file handle with h5py.File(image_file, "r") as handle: if "/entry/sample/goniometer/omega_increment" in handle: return False for entry in nexus.find_entries(handle): for sample in nexus.find_class(entry, "NXsample"): if "depends_on" not in sample: is_nexus_still = True except IOError: return False return is_nexus_still