Skip to content

Commit e364baf

Browse files
committed
Added KosmosTrace tests for coverage
1 parent 6822430 commit e364baf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

specreduce/tests/test_tracing.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def test_kosmos_trace():
100100
tg = KosmosTrace(img, peak_method='gaussian')
101101
tc = KosmosTrace(img, peak_method='centroid')
102102
tm = KosmosTrace(img, peak_method='max')
103-
# traces should all be close to 100 (note this passes with the current set values, but if
104-
# changing the seed, noise, etc, then this test might need to be updated)
103+
# traces should all be close to 100
104+
# (values may need to be updated on changes to seed, noise, etc.)
105105
assert np.max(abs(tg.trace-100)) < sigma_pix
106106
assert np.max(abs(tc.trace-100)) < 3 * sigma_pix
107107
assert np.max(abs(tm.trace-100)) < 6 * sigma_pix
@@ -116,6 +116,14 @@ def test_kosmos_trace():
116116
img_win_nans = img.copy()
117117
img_win_nans[guess - window:guess + window] = np.nan
118118

119+
# ensure a low bin number is rejected
120+
with pytest.raises(ValueError, match='bins must be >= 4'):
121+
KosmosTrace(img, bins=3)
122+
123+
# ensure number of bins greater than number of dispersion pixels is rejected
124+
with pytest.raises(ValueError, match=r'bins must be <*'):
125+
KosmosTrace(img, bins=ncols)
126+
119127
# error on trace of otherwise valid image with all-nan window around guess
120128
try:
121129
KosmosTrace(img_win_nans, guess=guess, window=window)

0 commit comments

Comments
 (0)