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

Fix for Astropy v7.0 incompatibility (#229) #232

Merged
merged 7 commits into from
Nov 27, 2024

Conversation

hpparvi
Copy link
Contributor

@hpparvi hpparvi commented Nov 15, 2024

This PR fixes Issue #229 by increasing the absolute and relative tolerances of assert_allclose in test_fit_trace_all_nan_col. An absolute tolerance of 0.05 pixels should be sufficient to test that the tracing methods work correctly but leave enough room for any minor variations in the results caused by the changes in the LevMarLSQFitter between Astropy v6 and v7.

Fix #229

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.33%. Comparing base (ef38dc0) to head (c053b33).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
specreduce/tracing.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #232      +/-   ##
==========================================
- Coverage   83.36%   83.33%   -0.03%     
==========================================
  Files          13       13              
  Lines        1136     1140       +4     
==========================================
+ Hits          947      950       +3     
- Misses        189      190       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pllim
Copy link
Member

pllim commented Nov 15, 2024

Please rebase to pick up the other CI fix.

@pllim
Copy link
Member

pllim commented Nov 15, 2024

The broader question, though, is whether specreduce should still be using a fitter that is no longer recommended by core astropy library (astropy/astropy#16983).

…e' tests again. They don't matter in practise when we set the absolute tolerances to 0.05 pix.
@hpparvi
Copy link
Contributor Author

hpparvi commented Nov 15, 2024

The broader question, though, is whether specreduce should still be using a fitter that is no longer recommended by core astropy library (astropy/astropy#16983).

It probably shouldn't. Fixing this should be relatively trivial, and I can do it either in this PR or a separate one.

@pllim
Copy link
Member

pllim commented Nov 15, 2024

Actually I am wondering also if relaxing tolerance is even needed if you switch fitter class.

…ropy.modeling.fitting.LevMarLSQFitter` in `specreduce.tracing.FitTrace`.
@hpparvi
Copy link
Contributor Author

hpparvi commented Nov 15, 2024

It seems still to be required. I've changed the fitter and run the tests, and the results still differ slightly (at a 0.01-pixel level).

@hpparvi
Copy link
Contributor Author

hpparvi commented Nov 15, 2024

The change to LMLSQFitter leads to a deprecation warning: "Using LMLSQFitter for models with bounds is now deprecated since astropy 7.0", so I've also given the TRFLSQFitter and DogBoxLSQFitter a try. The latter works quite well in the tests, but the former results in some larger discrepancies (>0.3 pix). I can either change the test to ignore the deprecation warning, or change the code to use DogBoxLSQFitter with slightly increased error tolerances.

Any preferences? Considering the future, I'd prefer to go with DogBoxLSQFitter.

@pllim
Copy link
Member

pllim commented Nov 15, 2024

I'll defer to specreduce maintainers on which fitters to replace the old one with. Thanks!

@hpparvi
Copy link
Contributor Author

hpparvi commented Nov 26, 2024

Any opinions, @cshanahan1, @kecnry, @tepickering? I think we can adopt DogBoxLSQFitter without any problems.

@pllim
Copy link
Member

pllim commented Nov 26, 2024

Also astropy 7.0 is already released, so this is a 🔥 now. If you don't hear back, I'd say you make a decision in your role as project manager and ping me to merge since I don't think you can merge yet?

@tepickering
Copy link
Contributor

agreed this is top priority to fix ASAP. i'd go ahead and make the switch to DogBoxLSQFitter.

…an_cols because the truth values were calculated with a different fitting method.
@hpparvi
Copy link
Contributor Author

hpparvi commented Nov 26, 2024

agreed this is top priority to fix ASAP. i'd go ahead and make the switch to DogBoxLSQFitter.

Thanks @tepickering! I've changed the fitting method and also added a check to use LinearLSQFitter for linear trace models like Chebyshev1D.

@pllim, this PR should be ready to merge now. I haven't been granted a maintainer status quite yet, but the two-week comment period is over now without any opposing comments (astropy/astropy.github.com#639), so this should change soon.

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Thanks!

@pllim
Copy link
Member

pllim commented Nov 26, 2024

Does this need a change log?

Copy link
Contributor

@tepickering tepickering left a comment

Choose a reason for hiding this comment

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

thanks for catching all this! i like adding the checks to help choose the optimal fitter.

@tepickering
Copy link
Contributor

Does this need a change log?

i think so since it's a pretty significant change to how model fitting is done. once that's added, i can go ahead and merge.

@hpparvi
Copy link
Contributor Author

hpparvi commented Nov 26, 2024

Does this need a change log?

Good point! I've added the changes to the change log under v1.4.2.

@pllim
Copy link
Member

pllim commented Nov 26, 2024

Since Tim said he would merge, I'll give him the honors. But if he is MIA, please ping me again because I can also merge but would rather let package maintainers do this. Thanks, all!

@tepickering tepickering merged commit 739eba1 into astropy:main Nov 27, 2024
11 of 12 checks passed
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.

astropy v7.0 incompatibility in TestMasksTracing.test_fit_trace_all_nan_cols
3 participants