diff --git a/src/scippnexus/nxtransformations.py b/src/scippnexus/nxtransformations.py index e2563ab2..c3b8eceb 100644 --- a/src/scippnexus/nxtransformations.py +++ b/src/scippnexus/nxtransformations.py @@ -3,6 +3,7 @@ # @author Simon Heybrock from __future__ import annotations +import warnings from typing import Dict, List, Optional, Tuple, Union import numpy as np @@ -381,8 +382,10 @@ def _with_positions( out[store_position] = transform * sc.vector([0, 0, 0], unit='m') if store_transform is not None: out[store_transform] = transform - except TransformationChainResolver.ChainError: - pass + except TransformationChainResolver.ChainError as e: + warnings.warn( + UserWarning(f'depends_on chain references missing node:\n{e}') + ) for name, value in dg.items(): if isinstance(value, sc.DataGroup): value = _with_positions( diff --git a/tests/nxtransformations_test.py b/tests/nxtransformations_test.py index cbc652ca..3693e83a 100644 --- a/tests/nxtransformations_test.py +++ b/tests/nxtransformations_test.py @@ -615,6 +615,7 @@ def test_compute_positions_with_rotation(h5root): ) +@pytest.mark.filterwarnings("ignore:depends_on chain references missing node") def test_compute_positions_skips_for_path_beyond_root(h5root): instrument = snx.create_class(h5root, 'instrument', snx.NXinstrument) value = sc.scalar(6.5, unit='m') @@ -712,3 +713,13 @@ def test_compute_positions_does_not_apply_time_dependent_transform_to_pixel_offs assert 'position' not in result['detector_0']['data'].coords result = snx.compute_positions(loaded, store_transform='transform') assert_identical(result['detector_0']['transform'], t * offset) + + +def test_compute_positions_warns_if_depends_on_is_dead_link(h5root): + instrument = snx.create_class(h5root, 'instrument', snx.NXinstrument) + detector = create_detector(instrument) + snx.create_field(detector, 'depends_on', sc.scalar('transform')) + root = make_group(h5root) + loaded = root[()] + with pytest.warns(UserWarning, match='depends_on chain references missing node'): + snx.compute_positions(loaded)