diff --git a/specreduce/tests/test_tracing.py b/specreduce/tests/test_tracing.py index 3e98f96..9b711de 100644 --- a/specreduce/tests/test_tracing.py +++ b/specreduce/tests/test_tracing.py @@ -150,7 +150,7 @@ def test_fit_trace(): with pytest.raises(ValueError, match=r'image is fully masked'): FitTrace(img_all_nans) - # test that warning is raised when many bins are masked + # test that warning is raised when several bins are masked mask = np.zeros(img.shape) mask[:, 100] = 1 mask[:, 20] = 1 @@ -159,3 +159,12 @@ def test_fit_trace(): msg = "All pixels in bins 20, 30, 100 are masked. Falling to trace value from all-bin fit." with pytest.warns(UserWarning, match=msg): FitTrace(nddat) + + # and when many bins are masked + mask = np.zeros(img.shape) + mask[:, 0:21] = 1 + nddat = NDData(data=img, mask=mask, unit=u.DN) + msg = 'All pixels in bins 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ..., 20 are masked. Falling to trace value from all-bin fit.' + with pytest.warns(UserWarning, match=msg): + FitTrace(nddat) + diff --git a/specreduce/tracing.py b/specreduce/tracing.py index 8c53384..426b531 100644 --- a/specreduce/tracing.py +++ b/specreduce/tracing.py @@ -352,7 +352,7 @@ def __post_init__(self): # if there are a ton of bins, we don't want to print them all out print(warn_bins) if len(warn_bins) > 20: - warn_bins = warn_bins[0: 10] + ['...'] + warn_bins[10: 19] + warn_bins = warn_bins[0: 10] + ['...'] + [warn_bins[-1]] warnings.warn(f"All pixels in bin{plural} {', '.join([str(x) for x in warn_bins])}" " are masked. Falling to trace value from all-bin fit.")