Skip to content

Commit 86d501c

Browse files
committed
fix passing single Trace object to Background
* Background(image, trace, width) used to expect trace to be an iterable and interpret the trace as a list of floats, each representing a trace (and therefore raise an error about window overlaps). This syntax is now handled as expected.
1 parent f8c67a9 commit 86d501c

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ API Changes
1010
Bug Fixes
1111
^^^^^^^^^
1212

13+
- Fixed passing a single ``Trace`` object to ``Background`` [#146]
14+
1315

1416
1.2.0
1517
-----

specreduce/background.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def _to_trace(trace):
9393
self.bkg_array = np.zeros(self.image.shape[self.disp_axis])
9494
return
9595

96+
if isinstance(self.traces, Trace):
97+
self.traces = [self.traces]
98+
9699
bkg_wimage = np.zeros_like(self.image, dtype=np.float64)
97100
for trace in self.traces:
98101
trace = _to_trace(trace)

specreduce/tests/test_background.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def test_background():
3838
# test that creating a one_sided background works
3939
Background.one_sided(image, trace, bkg_sep, width=bkg_width)
4040

41+
# test that passing a single trace works
42+
bg = Background(image, trace, width=bkg_width)
43+
4144
# test that image subtraction works
4245
sub1 = image - bg1
4346
sub2 = bg1.sub_image(image)

0 commit comments

Comments
 (0)