Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added filter_non_finite flag to fit_lines #1078

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cshanahan1
Copy link
Contributor

This PR adds the 'filter_non_finite' flag to specutils.fitting.fit_lines. By default, this flag is False, and it can only be True if the fitter is a LevMarLSQFitter. This fixes an issue when there are non-finite values in the weights array, and allows the fit to proceed with these filtered out.

@codecov
Copy link

codecov bot commented Sep 11, 2023

Codecov Report

Merging #1078 (c54c9cf) into main (85d07a9) will decrease coverage by 0.02%.
The diff coverage is 60.00%.

@@            Coverage Diff             @@
##             main    #1078      +/-   ##
==========================================
- Coverage   70.72%   70.71%   -0.02%     
==========================================
  Files          64       64              
  Lines        4485     4490       +5     
==========================================
+ Hits         3172     3175       +3     
- Misses       1313     1315       +2     
Files Changed Coverage Δ
specutils/fitting/fitmodels.py 67.82% <60.00%> (-0.14%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -377,7 +382,7 @@ def fit_lines(spectrum, model, fitter=fitting.LevMarLSQFitter(calc_uncertainties

def _fit_lines(spectrum, model, fitter=fitting.LevMarLSQFitter(calc_uncertainties=True),
exclude_regions=None, weights=None, window=None, get_fit_info=False,
ignore_units=False, **kwargs):
ignore_units=False, filter_non_finite=False, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need to add filter_non_finite to the kwargs in the LevMarLSQFitter, looks like tests are failing because other fitters don't expect that keyword argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good point, I thought I caught this by setting it to False when the fitter isn't LevMarLSQFitter but those fitters won't expect the flag at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants