@@ -28,6 +28,7 @@ def nxroot():
2828 yield root
2929
3030
31+ @pytest .mark .filterwarnings ("ignore:Failed to load :UserWarning" )
3132def test_returns_as_datagroup_if_no_signal_found (nxroot ):
3233 detector_numbers = sc .array (dims = ['' ], unit = None , values = np .array ([1 , 2 , 3 , 4 ]))
3334 detector = nxroot .create_class ('detector0' , NXdetector )
@@ -145,6 +146,24 @@ def test_loads_data_with_coords(h5root):
145146 assert sc .identical (detector [...]['data' ], da .rename_dims ({'yy' : 'dim_1' }))
146147
147148
149+ def test_nxcite_does_not_prevent_load_as_nxdetector (h5root ):
150+ da = sc .DataArray (
151+ sc .array (dims = ['xx' , 'yy' ], unit = 'K' , values = [[1.1 , 2.2 ], [3.3 , 4.4 ]])
152+ )
153+ da .coords ['detector_number' ] = detector_numbers_xx_yy_1234 ()
154+ da .coords ['xx' ] = sc .array (dims = ['xx' ], unit = 'm' , values = [0.1 , 0.2 ])
155+ detector = snx .create_class (h5root , 'detector0' , NXdetector )
156+ snx .create_field (detector , 'detector_number' , da .coords ['detector_number' ])
157+ snx .create_field (detector , 'xx' , da .coords ['xx' ])
158+ snx .create_field (detector , 'data' , da .data )
159+ snx .create_class (detector , 'cite' , snx .NXcite )
160+ detector .attrs ['axes' ] = ['xx' , '.' ]
161+ detector = make_group (detector )
162+ loaded = detector [...]
163+ assert 'cite' in loaded
164+ assert sc .identical (loaded ['data' ], da .rename_dims ({'yy' : 'dim_1' }))
165+
166+
148167def test_slicing_works_as_in_scipp (h5root ):
149168 da = sc .DataArray (
150169 sc .array (dims = ['xx' , 'yy' ], unit = 'K' , values = [[1.1 , 2.2 , 3.3 ], [3.3 , 4.4 , 5.5 ]])
@@ -657,6 +676,7 @@ def test_cylindrical_geometry_with_detector_numbers(nxroot):
657676 )
658677
659678
679+ @pytest .mark .filterwarnings ("ignore:Failed to load :UserWarning" )
660680def test_falls_back_to_hdf5_dim_labels (nxroot ):
661681 detector = nxroot .create_class ('detector0' , NXdetector )
662682 xy = sc .array (dims = ['x' , 'y' ], values = [[1 , 2 ], [3 , 4 ]])
@@ -672,6 +692,7 @@ def test_falls_back_to_hdf5_dim_labels(nxroot):
672692 assert_identical (dg ['z' ], z )
673693
674694
695+ @pytest .mark .filterwarnings ("ignore:Failed to load :UserWarning" )
675696def test_falls_back_to_partial_hdf5_dim_labels (nxroot ):
676697 detector = nxroot .create_class ('detector0' , NXdetector )
677698 xyz = sc .ones (dims = ['x' , 'dim_1' , 'z' ], shape = (2 , 2 , 3 ))
@@ -683,6 +704,7 @@ def test_falls_back_to_partial_hdf5_dim_labels(nxroot):
683704 assert_identical (dg ['xyz' ], xyz )
684705
685706
707+ @pytest .mark .filterwarnings ("ignore:Failed to load :UserWarning" )
686708def test_squeezes_trailing_when_fall_back_to_partial_hdf5_dim_labels (nxroot ):
687709 detector = nxroot .create_class ('detector0' , NXdetector )
688710 x = sc .ones (dims = ['x' , 'dim_1' ], shape = (2 , 1 ))
@@ -693,6 +715,7 @@ def test_squeezes_trailing_when_fall_back_to_partial_hdf5_dim_labels(nxroot):
693715 assert_identical (dg ['x' ], sc .squeeze (x ))
694716
695717
718+ @pytest .mark .filterwarnings ("ignore:Failed to load :UserWarning" )
696719def test_falls_back_to_hdf5_dim_labels_given_unnamed_axes (h5root ):
697720 xy = sc .array (dims = ['x' , 'y' ], values = [[1 , 2 ], [3 , 4 ]])
698721 z = sc .array (dims = ['z' ], values = [1 , 2 , 3 ])
@@ -712,6 +735,7 @@ def test_falls_back_to_hdf5_dim_labels_given_unnamed_axes(h5root):
712735 assert_identical (dg ['z' ], z )
713736
714737
738+ @pytest .mark .filterwarnings ("ignore:Failed to load :UserWarning" )
715739def test_falls_back_to_hdf5_dim_labels_given_partially_axes (h5root ):
716740 xy = sc .array (dims = ['x' , 'yy' ], values = [[1 , 2 ], [3 , 4 ]])
717741 z = sc .array (dims = ['zz' ], values = [1 , 2 , 3 ])
0 commit comments