Added a utility function to copy a model with new parameter values#16806
Closed
astrofrog wants to merge 3 commits intoastropy:mainfrom
Closed
Added a utility function to copy a model with new parameter values#16806astrofrog wants to merge 3 commits intoastropy:mainfrom
astrofrog wants to merge 3 commits intoastropy:mainfrom
Conversation
…t preserving e.g. constraints
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.
|
Contributor
|
👋 Thank you for your draft pull request! Do you know that you can use |
Cadair
reviewed
Aug 6, 2024
Comment on lines
+373
to
+376
| # HACK: for some models, there are additional non-parameter arguments. | ||
| # We hard-code the fix for some models. | ||
| if isinstance(model, (models.Polynomial1D, models.Polynomial2D)): | ||
| args = (model.degree,) |
Member
There was a problem hiding this comment.
This is the major problem with this approach. We can't hard code these attributes for all models (I have custom DKIST ones for example), so we would need to generalise this or come up with a different solution.
1 task
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.
This is an experimental PR which aims to solve #16593 and is an alternative to #16593
With this PR, we can copy a model, replacing the parameter values with new ones. If the new parameter values are arrays, all existing parameters are also broadcasted to the same array shape. Example usage:
Putting this up for discussion with @Cadair, @nden and @perrygreenfield