Repository navigation
Fix for masked arrays and fitting when peak_method=gaussian - #329
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #329 +/- ##
=======================================
Coverage 92.54% 92.54%
=======================================
Files 18 18
Lines 2348 2348
=======================================
Hits 2173 2173
Misses 175 175 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cshanahan1
force-pushed
the
masked-fit-trace
branch
from
November 17, 2026 19:47
79e5be5 to
0c2add5
Compare
kecnry
approved these changes
Nov 18, 2026
kecnry
left a comment
Member
There was a problem hiding this comment.
LGTM - and confirmed that tests in the dev runner that are failing in other PRs are passing here. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FitTrace with peak_method="gaussian" fails with
TypeError: Inputs of typenumpy.ma.MaskedArrayare not supported.when fitting against data/masks where scipy's stricter array-API input validation is active (SCIPY_ARRAY_API=1, which will become the default in the next scipy release and is currently causing test failures in jdaviz dev tests).
In FitTrace._fit_trace(), the calculation of
ztotis done fromimg(ztot = img.mean(axis=self._disp_axis)), andimgis always constructed as a masked array and soztotremains a masked array when going through the fitter.The fix is to exclude masked values before passing to the fitter, which is consistent with what is done elsewhere in specreduce with fitting (e.g
fitter(profile_i, ilum2[~z_i.mask], z_i.data[~z_i.mask]), as well as in extract.py).Existing tests already cover this scenario (and fail with scipy dev)