Skip to content

Fix _NoneLinearLSQFitter having a required extra arg#16982

Merged
astrofrog merged 3 commits intoastropy:mainfrom
Cadair:fix_fitter_args
Sep 12, 2024
Merged

Fix _NoneLinearLSQFitter having a required extra arg#16982
astrofrog merged 3 commits intoastropy:mainfrom
Cadair:fix_fitter_args

Conversation

@Cadair
Copy link
Member

@Cadair Cadair commented Sep 10, 2024

This should address #16673 (comment) but I had to sacrifice the performance of LevMarLSQFitter to the gods of shitty code and backwards compatibility.

If this exercise has taught me anything, it's that fitting.py needs a major (breaking) refactor 🔥.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

closes #16979

We now use the kwargs feature of scipy.optmize.least_squares to pass the
context through, but this means that the old (and should be deprecated)
LevMarLSQFitter doesn't get the performance boost.
@Cadair Cadair requested a review from a team as a code owner September 10, 2024 10:12
@Cadair Cadair requested review from a team and astrofrog and removed request for a team September 10, 2024 10:12
@github-actions
Copy link
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@Cadair Cadair added this to the v7.0.0 milestone Sep 10, 2024
@pllim pllim requested a review from mcara September 10, 2024 17:19
@pllim pllim added Bug Affects-dev PRs and issues that do not impact an existing Astropy release API change PRs and issues that change an existing API, possibly requiring a deprecation period benchmark Run benchmarks for a PR labels Sep 10, 2024
@pllim
Copy link
Member

pllim commented Sep 10, 2024

How much sacrifice are we talking about here?

@mcara , are you satisfied with this fix?

@pllim
Copy link
Member

pllim commented Sep 10, 2024

For once, the benchmark results might be related.

| Change   | Before [7c77a0f3]    | After [060118be]    |   Ratio | Benchmark (Parameter)                                   |
|----------|----------------------|---------------------|---------|---------------------------------------------------------|
| +        | 4.20±0.3ms           | 5.91±0.3ms          |    1.41 | modeling.fitting.time_combined_gauss_1d_LevMarLSQFitter |

SOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.
PERFORMANCE DECREASED.

@mcara
Copy link
Contributor

mcara commented Sep 11, 2024

@mcara , are you satisfied with this fix?

@pllim I think this solves the issue of backward compatibility.

Copy link
Contributor

@mcara mcara left a comment

Choose a reason for hiding this comment

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

LGTM

@pllim
Copy link
Member

pllim commented Sep 11, 2024

I think we're waiting for Tom's comment at #16982 (comment) to be resolved.

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

LGTM

@Cadair
Copy link
Member Author

Cadair commented Sep 12, 2024

:shipit: ?

@astrofrog astrofrog merged commit 84c595e into astropy:main Sep 12, 2024
@Cadair Cadair deleted the fix_fitter_args branch September 12, 2024 09:48
@mcara
Copy link
Contributor

mcara commented Sep 27, 2024

@mcara , are you satisfied with this fix?

@pllim I think this solves the issue of backward compatibility.

Sigh... not really. My bad: I should have run full tests. I didn't notice the change of fitparam_indices. This breaks old code.

@mcara
Copy link
Contributor

mcara commented Sep 27, 2024

https://github.com/spacetelescope/tweakwcs/actions/runs/11073910939/job/30771524455?pr=212#step:10:193

=========================== short test summary info ============================
FAILED tweakwcs/tests/test_linearfit.py::test_levmar2x2_multivariate - TypeError: _LevMarLSQFitter2x2.objective_function() got an unexpected keyword argument 'fit_param_indices'

@mcara
Copy link
Contributor

mcara commented Sep 27, 2024

I fixed the issue on my side so again this is not of importance for me (I think...).

@pllim
Copy link
Member

pllim commented Sep 27, 2024

Thanks for reporting back, @mcara . I opened #17085 follow-up issue that blocks v7.0 release until it is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release API change PRs and issues that change an existing API, possibly requiring a deprecation period benchmark Run benchmarks for a PR Bug modeling no-changelog-entry-needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants