@@ -319,10 +319,11 @@ def test_normalize_by_monitor_histogram_monitor_finer_bins_in_monitor_hist() ->
319319 sc .testing .assert_allclose (normalized , expected )
320320
321321
322- def test_normalize_by_monitor_histogram_zero_count_bins_are_ignored_hist () -> None :
322+ def test_normalize_by_monitor_histogram_masked_bins_are_ignored_hist () -> None :
323323 detector = sc .DataArray (
324324 sc .array (dims = ['w' ], values = [0 , 10 , 30 , 0 ], unit = 'counts' ),
325325 coords = {'w' : sc .array (dims = ['w' ], values = [- 1.0 , 0 , 2 , 3 , 4 ], unit = 'Å' )},
326+ masks = {'m' : sc .array (dims = ['w' ], values = [True , False , False , True ])},
326327 )
327328 monitor = sc .DataArray (
328329 sc .array (dims = ['w' ], values = [5.0 , 6.0 ], unit = 'counts' ),
@@ -339,16 +340,21 @@ def test_normalize_by_monitor_histogram_zero_count_bins_are_ignored_hist() -> No
339340 expected = sc .DataArray (
340341 sc .array (dims = ['w' ], values = [0.0 , 11 , 11 , float ('NaN' )], unit = 'counts' ),
341342 coords = {'w' : sc .array (dims = ['w' ], values = [- 1.0 , 0 , 2 , 3 , 4 ], unit = 'Å' )},
343+ masks = {'m' : sc .array (dims = ['w' ], values = [True , False , False , True ])},
342344 )
343345
344346 sc .testing .assert_identical (normalized , expected )
345347
346348
347- def test_normalize_by_monitor_histogram_zero_count_bins_are_ignored () -> None :
348- detector = sc .DataArray (
349- sc .array (dims = ['w' ], values = [0 , 10 , 30 ], unit = 'counts' ),
350- coords = {'w' : sc .arange ('w' , 3.0 , unit = 'Å' )},
351- ).bin (w = sc .array (dims = ['w' ], values = [- 1.0 , 0 , 2 , 3 , 4 ], unit = 'Å' ))
349+ def test_normalize_by_monitor_histogram_masked_bins_are_ignored () -> None :
350+ detector = (
351+ sc .DataArray (
352+ sc .array (dims = ['w' ], values = [0 , 10 , 30 , 40 ], unit = 'counts' ),
353+ coords = {'w' : sc .arange ('w' , 4.0 , unit = 'Å' )},
354+ )
355+ .bin (w = sc .array (dims = ['w' ], values = [- 1.0 , 0 , 2 , 3 , 4 ], unit = 'Å' ))
356+ .assign_masks (m = sc .array (dims = ['w' ], values = [True , False , False , True ]))
357+ )
352358 monitor = sc .DataArray (
353359 sc .array (dims = ['w' ], values = [5.0 , 6.0 ], unit = 'counts' ),
354360 coords = {'w' : sc .array (dims = ['w' ], values = [- 0.5 , 2 , 3 ], unit = 'Å' )},
@@ -359,10 +365,14 @@ def test_normalize_by_monitor_histogram_zero_count_bins_are_ignored() -> None:
359365 uncertainty_broadcast_mode = UncertaintyBroadcastMode .fail ,
360366 )
361367
362- expected = sc .DataArray (
363- sc .array (dims = ['w' ], values = [0.0 , 110 / 7 , 110 / 7 ], unit = 'counts' ),
364- coords = {'w' : sc .arange ('w' , 3.0 , unit = 'Å' )},
365- ).bin (w = sc .array (dims = ['w' ], values = [- 1.0 , 0 , 2 , 3 , 4 ], unit = 'Å' ))
368+ expected = (
369+ sc .DataArray (
370+ sc .array (dims = ['w' ], values = [0.0 , 110 / 7 , 110 / 7 , 0 ], unit = 'counts' ),
371+ coords = {'w' : sc .arange ('w' , 4.0 , unit = 'Å' )},
372+ )
373+ .bin (w = sc .array (dims = ['w' ], values = [- 1.0 , 0 , 2 , 3 , 4 ], unit = 'Å' ))
374+ .assign_masks (m = sc .array (dims = ['w' ], values = [True , False , False , True ]))
375+ )
366376
367377 sc .testing .assert_allclose (normalized , expected )
368378
0 commit comments