From 73a98abc5331c55dfd2288623cf7776743ba98a4 Mon Sep 17 00:00:00 2001 From: Richard Gildea Date: Tue, 27 Jun 2023 14:08:30 +0100 Subject: [PATCH 1/4] Fix for nxmx import overwritten by local variable (#641) * Unbreak help test * explicitly set program name * minor change to docstring * Fix for nxmx import overwritten by local variable Introduced by #597 Another case were bugs have crept in through lack of tests (see #470) * news * Rename newsfragments/XXX.bugfix to newsfragments/641.bugfix --- newsfragments/641.bugfix | 1 + src/dxtbx/command_line/dlsnxs2cbf.py | 4 ++-- src/dxtbx/util/dlsnxs2cbf.py | 15 ++++++++------- tests/command_line/test_dlsnxs2cbf.py | 5 ++--- 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 newsfragments/641.bugfix diff --git a/newsfragments/641.bugfix b/newsfragments/641.bugfix new file mode 100644 index 000000000..3012098b5 --- /dev/null +++ b/newsfragments/641.bugfix @@ -0,0 +1 @@ +``dxtbx.dlsnxs2cbf``: Fix import overwritten by local variable. diff --git a/src/dxtbx/command_line/dlsnxs2cbf.py b/src/dxtbx/command_line/dlsnxs2cbf.py index 7c6cc4dbc..742fb2534 100644 --- a/src/dxtbx/command_line/dlsnxs2cbf.py +++ b/src/dxtbx/command_line/dlsnxs2cbf.py @@ -2,7 +2,7 @@ Convert a NXmx-format NeXus file to a set of CBF-format image files. Note that this tool does not produce full imgCIF-format files, only -Dectris-style mini-CBF files consisting of a plain text simplified +DECTRIS-style mini-CBF files consisting of a plain text simplified header and the binary compressed image data. The simplified header does not contain a full description of the experiment geometry and some metadata, including the detector orientation, are unspecified. As @@ -18,7 +18,7 @@ import dxtbx.util.dlsnxs2cbf -parser = argparse.ArgumentParser(description=__doc__) +parser = argparse.ArgumentParser(description=__doc__, prog="dxtbx.dlsnxs2cbf") parser.add_argument( "nexus_file", metavar="nexus-file", help="Input NeXus file.", type=Path ) diff --git a/src/dxtbx/util/dlsnxs2cbf.py b/src/dxtbx/util/dlsnxs2cbf.py index a78e2f584..011afe42d 100644 --- a/src/dxtbx/util/dlsnxs2cbf.py +++ b/src/dxtbx/util/dlsnxs2cbf.py @@ -12,11 +12,12 @@ from tqdm import tqdm import dxtbx.model +import dxtbx.nexus from dxtbx.ext import compress -def compute_cbf_header(nxmx: nxmx.NXmx, nn: int): - nxentry = nxmx.entries[0] +def compute_cbf_header(nxmx_obj: nxmx.NXmx, nn: int): + nxentry = nxmx_obj.entries[0] nxsample = nxentry.samples[0] nxinstrument = nxentry.instruments[0] nxdetector = nxinstrument.detectors[0] @@ -145,11 +146,11 @@ def make_cbf( with h5py.File(in_name) as f: start_tag = binascii.unhexlify("0c1a04d5") - nxmx = nxmx.NXmx(f) - nxsample = nxmx.entries[0].samples[0] - nxinstrument = nxmx.entries[0].instruments[0] + nxmx_obj = nxmx.NXmx(f) + nxsample = nxmx_obj.entries[0].samples[0] + nxinstrument = nxmx_obj.entries[0].instruments[0] nxdetector = nxinstrument.detectors[0] - nxdata = nxmx.entries[0].data[0] + nxdata = nxmx_obj.entries[0].data[0] dependency_chain = nxmx.get_dependency_chain(nxsample.depends_on) scan_axis = None @@ -183,7 +184,7 @@ def make_cbf( print(f"Writing images to {template}{'#' * num_digits}.cbf:") for j in tqdm(range(num_images), unit=" images"): - header = compute_cbf_header(nxmx, j) + header = compute_cbf_header(nxmx_obj, j) (data,) = dxtbx.nexus.get_raw_data(nxdata, nxdetector, j) if bit_depth_readout: # if 32 bit then it is a signed int, I think if 8, 16 then it is diff --git a/tests/command_line/test_dlsnxs2cbf.py b/tests/command_line/test_dlsnxs2cbf.py index 5bf7673fd..954b3947c 100644 --- a/tests/command_line/test_dlsnxs2cbf.py +++ b/tests/command_line/test_dlsnxs2cbf.py @@ -69,10 +69,9 @@ def test_dlsnxs2cbf_deleted_axis(dials_data, tmp_path, remove_axis): make_cbf(tmp_path / master, template=str(tmp_path / "image_%04d.cbf")) -@pytest.mark.xfail(reason="Broken for old data while collecting new data") def test_dlsnxs2cbf_help(capsys): with pytest.raises(SystemExit): run(["-h"]) captured = capsys.readouterr() - assert parser.description in captured.out - assert "Template cbf output name e.g. 'image_%04d.cbf'" in captured.out + assert parser.description.splitlines()[0] in captured.out + assert "usage: dxtbx.dlsnxs2cbf" in captured.out From fc6eb43e12cc699d28dd94f2365fb9d4ba0c8294 Mon Sep 17 00:00:00 2001 From: Nicholas Devenish Date: Tue, 27 Jun 2023 14:22:04 +0100 Subject: [PATCH 2/4] MNT: Skip tests removed from DLS filesystem --- tests/format/test_FormatNXmxDLS16M.py | 2 ++ tests/format/test_FormatNXmxDLS16MI03.py | 1 + 2 files changed, 3 insertions(+) diff --git a/tests/format/test_FormatNXmxDLS16M.py b/tests/format/test_FormatNXmxDLS16M.py index be60d4681..56ecc1434 100644 --- a/tests/format/test_FormatNXmxDLS16M.py +++ b/tests/format/test_FormatNXmxDLS16M.py @@ -98,6 +98,7 @@ def test_rotation_scan_i04_2022_run_5(master_h5): assert masker.get_mask(imageset.get_detector(), 100)[0].count(False) == 1110799 +@pytest.mark.skip(reason="Data erased from CM visit") @pytest.mark.parametrize( "master_h5", [ @@ -116,6 +117,7 @@ def test_masked_i04_32bit(master_h5): assert flex.max(imageset[0][0]) != 0x7FFFFFFF +@pytest.mark.skip(reason="Data erased from CM visit") @pytest.mark.parametrize( "master_h5", [ diff --git a/tests/format/test_FormatNXmxDLS16MI03.py b/tests/format/test_FormatNXmxDLS16MI03.py index 0dc5f4833..6a71dc3b6 100644 --- a/tests/format/test_FormatNXmxDLS16MI03.py +++ b/tests/format/test_FormatNXmxDLS16MI03.py @@ -11,6 +11,7 @@ pytest.importorskip("h5py") +@pytest.mark.skip(reason="Data erased from CM visit") @pytest.mark.parametrize( "master_h5,masked_count", [ From 397410de75d262047054c5e75522eb8cd4df78a7 Mon Sep 17 00:00:00 2001 From: DiamondLightSource-build-server Date: Thu, 29 Jun 2023 09:43:58 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Bump=20version:=203.15.0=20=E2=86=92=203.15?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index cd5ce585f..fed29b1be 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 3.15.0 +current_version = 3.15.1 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P[a-z]+)?(?P\d+)? diff --git a/setup.py b/setup.py index 3789f7137..1da76bbec 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ # Static version number which is updated by bump2version # Do not change this manually - use 'bump2version ' -__version_tag__ = "3.15.0" +__version_tag__ = "3.15.1" setup_kwargs = { "name": "dxtbx", From 1cae1c05daf077edfd26f5714ebfefa2d379dd68 Mon Sep 17 00:00:00 2001 From: DiamondLightSource-build-server Date: Thu, 29 Jun 2023 09:43:58 +0100 Subject: [PATCH 4/4] Towncrier for 3.15.1 towncrier --name "DIALS" --version 3.15.1 --- CHANGELOG.rst | 9 +++++++++ newsfragments/641.bugfix | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) delete mode 100644 newsfragments/641.bugfix diff --git a/CHANGELOG.rst b/CHANGELOG.rst index dddf08c6e..101191acd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,12 @@ +DIALS 3.15.1 (2023-06-29) +========================= + +Bugfixes +-------- + +- ``dxtbx.dlsnxs2cbf``: Fix import overwritten by local variable. (`#641 `_) + + dxtbx 3.15.0 (2023-06-13) ========================= diff --git a/newsfragments/641.bugfix b/newsfragments/641.bugfix deleted file mode 100644 index 3012098b5..000000000 --- a/newsfragments/641.bugfix +++ /dev/null @@ -1 +0,0 @@ -``dxtbx.dlsnxs2cbf``: Fix import overwritten by local variable.