From 5ce1e9f25ef3601f5863d157ffb11e9018657512 Mon Sep 17 00:00:00 2001 From: Simon Heybrock Date: Tue, 11 Apr 2023 13:36:56 +0200 Subject: [PATCH 1/5] Fix exception when loading NXdata with NXlog signal Also affected NXdata subclasses --- src/scippnexus/v2/nxdata.py | 3 +++ tests/nxdata_test.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/scippnexus/v2/nxdata.py b/src/scippnexus/v2/nxdata.py index 1f879c46..f8bf6815 100644 --- a/src/scippnexus/v2/nxdata.py +++ b/src/scippnexus/v2/nxdata.py @@ -102,6 +102,9 @@ def _init_signal(self, name: Optional[str], children): break # NXlog or NXevent_data can take the role of the signal. for name, field in children.items(): + if name == self._signal_name: + # Avoid duplicate handling + continue if isinstance(field, EventField) or (isinstance(field, Group) and field.nx_class in [NXlog, NXevent_data]): diff --git a/tests/nxdata_test.py b/tests/nxdata_test.py index 2083d07f..ba71d2d9 100644 --- a/tests/nxdata_test.py +++ b/tests/nxdata_test.py @@ -211,6 +211,23 @@ def test_auxiliary_signal_causes_load_as_dataset(h5root): assert_identical(data[...], sc.Dataset({'signal': da.data, 'xx': da.coords['xx']})) +def test_NXlog_data_is_loaded_as_time_dependent_data_array(nxroot): + da = sc.DataArray(data=sc.array(dims=['time'], unit='K', values=[1, 2, 3]), + coords={ + 'time': + sc.epoch(unit='s') + + sc.array(dims=['time'], unit='s', values=[1, 2, 3]) + }) + data = nxroot.create_class('data1', NXdata) + log = data.create_class('data', NXlog) + log['time'] = da.coords['time'] + log['value'] = da.data + data._group.attrs['signal'] = 'data' + + loaded = data[()] + assert_identical(loaded, da) + + def test_field_dims_match_NXdata_dims(h5root): da = sc.DataArray( sc.array(dims=['xx', 'yy'], unit='m', values=[[1, 2, 3], [4, 5, 6]])) From 0d5938ceddff84dd36db6673f27128e23e28fa44 Mon Sep 17 00:00:00 2001 From: Simon Heybrock Date: Mon, 17 Apr 2023 13:12:12 +0200 Subject: [PATCH 2/5] Elaborate on mechanism for finding signal in NXdata --- src/scippnexus/v2/nxdata.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/scippnexus/v2/nxdata.py b/src/scippnexus/v2/nxdata.py index f8bf6815..b6b9fff6 100644 --- a/src/scippnexus/v2/nxdata.py +++ b/src/scippnexus/v2/nxdata.py @@ -89,6 +89,14 @@ def __init__(self, self._valid = False def _init_signal(self, name: Optional[str], children): + # There are multiple ways NeXus can define the "signal" dataset. The latest + # version uses `signal` attribute on the group (passed as `name`). However, + # we must give precedence to the `signal` attribute on the dataset, since + # older files may use that (and the `signal` group attribute is unrelated). + # Finally, NXlog and NXevent_data can take the role of the signal. In practice + # those may not be indicate by a `signal` attribute, but we support that + # anyway since otherwise we would not be able to find NXevent_data signals + # in many common files. if name is not None and name in children: self._signal_name = name self._signal = children[name] From c6d82466a2fba7c4064f83694c442b11a0f34634 Mon Sep 17 00:00:00 2001 From: Simon Heybrock Date: Mon, 17 Apr 2023 13:45:35 +0200 Subject: [PATCH 3/5] 23.04 release notes --- docs/about/release-notes.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/about/release-notes.rst b/docs/about/release-notes.rst index 2e364584..0d2b29c4 100644 --- a/docs/about/release-notes.rst +++ b/docs/about/release-notes.rst @@ -28,6 +28,17 @@ Release Notes Neil Vaytet :sup:`a`\ , and Jan-Lukas Wynen :sup:`a` +v23.04.0 +-------- + +Features +~~~~~~~~ + +* Added the future API of ``scippnexus`` as ``scippnexus.v2``. + For many users the API changes will be minor. + The old API will be deprecated soon and users should try to migrate to the new API. + Note that ``v2`` is not fully stable yet and in particular the behavior in edge case is subject to change. + v23.03.0 -------- From 6c9bfa6be6336b0a3835c61fa139876c3682a1b7 Mon Sep 17 00:00:00 2001 From: Simon Heybrock Date: Mon, 17 Apr 2023 13:49:19 +0200 Subject: [PATCH 4/5] Add front page news --- docs/index.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index 55fa7f82..e028dd08 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -27,6 +27,11 @@ This is especially powerful since a number of concepts of Scipp map well to conc News ---- +- [April 2023] scippnexus-23.04.0 has been released. + This adds ``scippnexus.v2``, which provides the future API of ``scippnexus``. + The new API avoids performance bottlenecks when working with small files that contain many groups and datasets. + The new behavior is also more faithful to the file content. + ``v2`` will become the default in the near future. - [March 2023] scippnexus-23.03.0 has been released. This brings a number of improvements, including handling of legacy files and loading of geometry information. - [January 2023] scippnexus-23.01.0 has been released. From 3194bb16dae3b5beb4d8e5994fe3c87232ce3a7f Mon Sep 17 00:00:00 2001 From: Simon Heybrock <12912489+SimonHeybrock@users.noreply.github.com> Date: Mon, 17 Apr 2023 14:32:48 +0200 Subject: [PATCH 5/5] Update docs/about/release-notes.rst Co-authored-by: Jan-Lukas Wynen --- docs/about/release-notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/about/release-notes.rst b/docs/about/release-notes.rst index 0d2b29c4..a69f9d39 100644 --- a/docs/about/release-notes.rst +++ b/docs/about/release-notes.rst @@ -37,7 +37,7 @@ Features * Added the future API of ``scippnexus`` as ``scippnexus.v2``. For many users the API changes will be minor. The old API will be deprecated soon and users should try to migrate to the new API. - Note that ``v2`` is not fully stable yet and in particular the behavior in edge case is subject to change. + Note that ``v2`` is not fully stable yet and in particular the behavior in edge cases is subject to change. v23.03.0 --------