Repository navigation
Conversation
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.
|
1 task
Member
Author
| poly.c1.value = 2 | ||
| poly.c2.value = 3 | ||
|
|
||
| assert_allclose(poly.parameters, [1, 2, 3]) |
Contributor
There was a problem hiding this comment.
assert_array_equal seems more appropriate to me since there no floating point arithmetic is involved (and 1, 2 and 3 have exact floating point representations)
| param_metrics[name]["size"] = param_size | ||
| total_size += param_size | ||
| self._parameters = np.empty(total_size, dtype=np.float64) | ||
| if self._parameters is None or self._parameters.size != total_size: |
Contributor
There was a problem hiding this comment.
I would add a comment here to explain the reason this is conditional (perfs)
| param_metrics[name]["size"] = param_size | ||
| total_size += param_size | ||
| self._parameters = np.empty(total_size, dtype=np.float64) | ||
| if self._parameters is None or self._parameters.size != total_size: |
neutrinoceros
approved these changes
Jul 15, 2024
…rs were set using .value and shape was not preserved
Co-authored-by: Clément Robert <[email protected]>
astrofrog
force-pushed
the
fix-parameters-to-array
branch
from
July 23, 2024 22:35
c99d6b2 to
4387cf0
Compare
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.
It is currently possible to change the shape of parameters on a model by setting
Parameter.value:This is actually really helpful in order to solve #16593. However, one runs into a couple of bugs when doing this:
this is incorrect, as it should now be
[1, 2, 3]. And when fitting:These two bugs have the same root cause -
Model._parameters_to_arrayassumes that the parameter shape never changes. The fix is simple: when calling_parameters_to_array, we call_initialize_slices, but we can be smart and avoid re-allocatingself._parametersif the total size hasn't changed for performance.In the process I noticed some code duplication which I've removed in #16709