-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add n_submodels shared method to compound models #5747
Conversation
Test that CompoundModel.get_n_submodels() properly returns the number | ||
of components. | ||
""" | ||
g2 = Gaussian1D() + Gaussian1D() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also test that non-compound model return 1, or is that non-applicable? @nden?
docs/modeling/compound-models.rst
Outdated
@@ -176,6 +176,12 @@ In a future version it may be possible to "freeze" a compound model, so that | |||
from the user's perspective it is treated as a single model. However, as this | |||
is the default behavior it is good to be aware of. | |||
|
|||
One is also able to get the number of components (also known as submodels) in | |||
a compound model by using ``get_n_submodels`` method:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mention of "method" and its name needs to be corrected to reflect the correct new property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pllim
Also need a change log for v2.0 under new feature. |
add changelog entry
LGTM 👍 |
@mirca 👍 for using a |
@nden It makes a lot of sense to me that this should work with single models too :) |
@nden Let me know if the changes suffice, thanks! |
astropy/modeling/core.py
Outdated
Return the number of components in a single model, which is | ||
obviously 1. | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Blank line not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pllim
LGTM 👍 |
Looks good! Thanks @mirca! |
This PR adds a
propertyshared method calledn_submodels
to_CompoundModel
which provides a clearer way to get the number of components in a compound model.Fix #4093
cc @pllim @nden