Skip to content

Commit

Permalink
Merge pull request #146 from kecnry/bg-single-trace
Browse files Browse the repository at this point in the history
BUG: fix passing single Trace object to Background
  • Loading branch information
kecnry authored Oct 14, 2022
2 parents f8c67a9 + 86d501c commit 67b6b8b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ API Changes
Bug Fixes
^^^^^^^^^

- Fixed passing a single ``Trace`` object to ``Background`` [#146]


1.2.0
-----
Expand Down
3 changes: 3 additions & 0 deletions specreduce/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def _to_trace(trace):
self.bkg_array = np.zeros(self.image.shape[self.disp_axis])
return

if isinstance(self.traces, Trace):
self.traces = [self.traces]

bkg_wimage = np.zeros_like(self.image, dtype=np.float64)
for trace in self.traces:
trace = _to_trace(trace)
Expand Down
3 changes: 3 additions & 0 deletions specreduce/tests/test_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def test_background():
# test that creating a one_sided background works
Background.one_sided(image, trace, bkg_sep, width=bkg_width)

# test that passing a single trace works
bg = Background(image, trace, width=bkg_width)

# test that image subtraction works
sub1 = image - bg1
sub2 = bg1.sub_image(image)
Expand Down

0 comments on commit 67b6b8b

Please sign in to comment.