@@ -376,8 +376,6 @@ def test_normalize_by_monitor_integrated_expected_results():
376376 sc .arange ('wavelength' , 1 , 4 , unit = 'counts' ),
377377 coords = {'wavelength' : sc .arange ('wavelength' , 3.0 , unit = 'Å' )},
378378 ).bin (wavelength = sc .array (dims = ['wavelength' ], values = [0.0 , 2 , 3 ], unit = 'Å' ))
379- # "midpoints" at bounds to ensure we include that range.
380- detector .coords ['wavelength' ] = detector .coords ['wavelength' ][::2 ]
381379 monitor = sc .DataArray (
382380 sc .array (dims = ['wavelength' ], values = [4.0 , 5.0 , 6.0 ], unit = 'counts' ),
383381 coords = {
@@ -391,19 +389,32 @@ def test_normalize_by_monitor_integrated_expected_results():
391389 monitor = WavelengthMonitor [SampleRun , CaveMonitor ](monitor ),
392390 uncertainty_broadcast_mode = UncertaintyBroadcastMode .fail ,
393391 )
392+ # Last event is at 2, so the monitor bin with value 6.0 is not used.
394393 expected = ScaledCountsDspacing [SampleRun ](
395- detector / sc .scalar (4 * 0.5 + 5 * 1.5 + 6 * 1 , unit = 'counts * Å' )
394+ detector / sc .scalar (4 * 0.5 + 5 * 1.5 , unit = 'counts * Å' )
396395 )
397396 sc .testing .assert_identical (normalized , expected )
398397
399398
400- def test_normalize_by_monitor_integrated_ignores_monitor_values_out_of_range ():
399+ @pytest .mark .parametrize ('event_coord' , [True , False ])
400+ def test_normalize_by_monitor_integrated_ignores_monitor_values_out_of_range (
401+ event_coord : bool ,
402+ ):
401403 detector = sc .DataArray (
402- sc .arange ('wavelength' , 3 , unit = 'counts' ),
403- coords = {'wavelength' : sc .arange ('wavelength' , 3.0 , unit = 'Å' )},
404- ).bin (wavelength = sc .array (dims = ['wavelength' ], values = [0.0 , 2 , 3 ], unit = 'Å' ))
405- # "midpoints" at bounds to ensure we include that range.
406- detector .coords ['wavelength' ] = detector .coords ['wavelength' ][::2 ]
404+ sc .arange ('wavelength' , 4 , unit = 'counts' ),
405+ coords = {'wavelength' : sc .arange ('wavelength' , 4.0 , unit = 'Å' )},
406+ )
407+ if event_coord :
408+ # Make sure event at 3 is included
409+ detector = detector .bin (
410+ wavelength = sc .array (dims = ['wavelength' ], values = [0.0 , 2 , 3.1 ], unit = 'Å' )
411+ )
412+ del detector .coords ['wavelength' ]
413+ else :
414+ detector = detector .bin (
415+ wavelength = sc .array (dims = ['wavelength' ], values = [0.0 , 2 , 3 ], unit = 'Å' )
416+ )
417+ del detector .bins .coords ['wavelength' ]
407418 monitor = sc .DataArray (
408419 sc .array (dims = ['wavelength' ], values = [4.0 , 10.0 ], unit = 'counts' ),
409420 coords = {
@@ -421,13 +432,25 @@ def test_normalize_by_monitor_integrated_ignores_monitor_values_out_of_range():
421432 sc .testing .assert_identical (normalized , expected )
422433
423434
424- def test_normalize_by_monitor_integrated_uses_monitor_values_at_boundary ():
435+ @pytest .mark .parametrize ('event_coord' , [True , False ])
436+ def test_normalize_by_monitor_integrated_uses_monitor_values_at_boundary (
437+ event_coord : bool ,
438+ ):
425439 detector = sc .DataArray (
426- sc .arange ('wavelength' , 3 , unit = 'counts' ),
427- coords = {'wavelength' : sc .arange ('wavelength' , 3.0 , unit = 'Å' )},
428- ).bin (wavelength = sc .array (dims = ['wavelength' ], values = [0.0 , 2 , 3 ], unit = 'Å' ))
429- # "midpoints" at bounds to ensure we include that range.
430- detector .coords ['wavelength' ] = detector .coords ['wavelength' ][::2 ]
440+ sc .arange ('wavelength' , 4 , unit = 'counts' ),
441+ coords = {'wavelength' : sc .arange ('wavelength' , 4.0 , unit = 'Å' )},
442+ )
443+ if event_coord :
444+ # Make sure event at 3 is included
445+ detector = detector .bin (
446+ wavelength = sc .array (dims = ['wavelength' ], values = [0.0 , 2 , 3.1 ], unit = 'Å' )
447+ )
448+ del detector .coords ['wavelength' ]
449+ else :
450+ detector = detector .bin (
451+ wavelength = sc .array (dims = ['wavelength' ], values = [0.0 , 2 , 3 ], unit = 'Å' )
452+ )
453+ del detector .bins .coords ['wavelength' ]
431454 monitor = sc .DataArray (
432455 sc .array (dims = ['wavelength' ], values = [4.0 , 10.0 ], unit = 'counts' ),
433456 coords = {
@@ -450,8 +473,6 @@ def test_normalize_by_monitor_integrated_raises_if_monitor_range_too_narrow():
450473 sc .arange ('wavelength' , 3 , unit = 'counts' ),
451474 coords = {'wavelength' : sc .arange ('wavelength' , 3.0 , unit = 'Å' )},
452475 ).bin (wavelength = sc .array (dims = ['wavelength' ], values = [0.0 , 2 , 3 ], unit = 'Å' ))
453- # "midpoints" at bounds to ensure we include that range.
454- detector .coords ['wavelength' ] = detector .coords ['wavelength' ][::2 ]
455476 monitor = sc .DataArray (
456477 sc .array (dims = ['wavelength' ], values = [4.0 , 10.0 ], unit = 'counts' ),
457478 coords = {
0 commit comments