Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
cshanahan1 committed Dec 4, 2023
1 parent a334e98 commit 3b4aab6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion specreduce/tests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

2 changes: 1 addition & 1 deletion specreduce/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down

0 comments on commit 3b4aab6

Please sign in to comment.