@@ -409,8 +409,12 @@ def test_extract_dataset_below_bin() -> None:
409409 expected_data = np .array ([np .nan , np .nan , np .nan , np .nan , 16 ])
410410 np .testing .assert_allclose (ds_out [var ].isel (cross_track = 0 ).data .squeeze (), expected_data )
411411 # - With strict=True, it fails if all bins are the last range gate
412- with pytest .raises (ValueError ):
413- extract_dataset_below_bin (ds , bins = bins , strict = True )
412+ # with pytest.raises(ValueError):
413+ # extract_dataset_below_bin(ds, bins=bins, strict=True)
414+ ds_out = extract_dataset_below_bin (ds , bins = bins , strict = True )
415+ expected_data = np .array ([np .nan , np .nan , np .nan , np .nan , np .nan ])
416+ np .testing .assert_allclose (ds_out [var ].isel (cross_track = 0 ).data .squeeze (), expected_data )
417+
414418 # - With strict=True and some valid bins (at cross_track_idx=0), it works
415419 ds [bins ].data [0 ] = bin_value
416420 ds_out = extract_dataset_below_bin (ds , bins = bins , strict = True )
@@ -572,8 +576,12 @@ def test_extract_dataset_above_bin() -> None:
572576 expected_data = np .array ([0 , np .nan , np .nan , np .nan , np .nan ])
573577 np .testing .assert_allclose (ds_out [var ].isel (cross_track = 0 ).data .squeeze (), expected_data )
574578 # - With strict=True, it fails if all bins are the first range gate
575- with pytest .raises (ValueError ):
576- extract_dataset_above_bin (ds , bins = bins , strict = True )
579+ # with pytest.raises(ValueError):
580+ # extract_dataset_above_bin(ds, bins=bins, strict=True)
581+ ds_out = extract_dataset_above_bin (ds , bins = bins , strict = True )
582+ expected_data = np .array ([np .nan , np .nan , np .nan , np .nan , np .nan ])
583+ np .testing .assert_allclose (ds_out [var ].isel (cross_track = 0 ).data .squeeze (), expected_data )
584+
577585 # - With strict=True and some valid bins (at cross_track_idx=0), it works
578586 ds [bins ].data [0 ] = bin_value
579587 ds_out = extract_dataset_above_bin (ds , bins = bins , strict = True )
@@ -672,15 +680,19 @@ def test_get_bin_dataarray() -> None:
672680 cross_track_size = cross_track_size ,
673681 along_track_size = along_track_size ,
674682 )
675- with pytest .raises (ValueError ) as excinfo :
676- get_bin_dataarray (ds , bins = "nan_bins" )
677- assert "All range bin indices are NaN" in str (excinfo .value )
683+ da_bin , da_mask = get_bin_dataarray (ds , bins = "nan_bins" )
684+ assert (da_bin == 5 ).all ().item ()
685+ assert da_mask .all ().item () # mask is all True
686+
687+ # with pytest.raises(ValueError) as excinfo:
688+ # get_bin_dataarray(ds, bins="nan_bins")
689+ # assert "All range bin indices are NaN" in str(excinfo.value)
678690
679691 # Test mixture of invalid values
680692 ds ["nan_bins" ].data [0 ] = range_size + 1
681693 with pytest .raises (ValueError ) as excinfo :
682694 get_bin_dataarray (ds , bins = "nan_bins" )
683- assert "All range bin indices are invalid " in str (excinfo .value )
695+ assert "Some range bin indices are outside " in str (excinfo .value )
684696
685697
686698def test_get_height_dataarray ():
0 commit comments