-
Notifications
You must be signed in to change notification settings - Fork 76
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
model fitting tweaks and cleanup #1947
Conversation
e4b8074
to
291c32d
Compare
- Linear1D model component now estimates slope and intercept. [#1947] | ||
|
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.
I think all the other changes are just internal and don't affect users - do we still want those listed in the change log somewhere?
291c32d
to
b12718f
Compare
* dataset and subset components handle caching on their own, we don't need other caching at the plugin level * we now apply the subset with a mask and so don't need to cache and pass the window along to specutils
b12718f
to
d72736a
Compare
Codecov ReportBase: 91.79% // Head: 91.79% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1947 +/- ##
=======================================
Coverage 91.79% 91.79%
=======================================
Files 140 140
Lines 14950 14943 -7
=======================================
- Hits 13723 13717 -6
+ Misses 1227 1226 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
I don't think we need a change log for things users don't care about.
I also don't know how I should feel that no tests are affected by this.
I hardly use this plugin, so please tell me how I should review this in terms of usage workflow, or other devs can do it... 😬 |
Ok, agreed. I did add another bugfix entry since this fixes parameter initialization to handle the selected subset correctly.
Model fitting has decent coverage already and this really mostly removes redundant code that has no affect on those tests.
There are only two things that should change when using the model fitting plugin when compared to main:
|
@@ -683,15 +659,15 @@ def _fit_model_to_spectrum(self, add_data): | |||
models_to_fit = self._reinitialize_with_fixed() | |||
|
|||
# Apply masks from selected spectral subsets | |||
self._apply_subset_masks(self._spectrum1d, self.spectral_subset) | |||
masked_spectrum = self._apply_subset_masks(self.dataset.selected_obj, self.spectral_subset) |
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.
Do you intend to return a subset masked copy of self.dataset.selected_obj
as masked_spectrum
? If so, I think this might not do exactly what you're expecting, since the _apply_subset_masks
method is still updating or creating a mask attribute on self.dataset.selected_obj
.
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.
self.dataset.selected_obj
is a cached property, so I think this is safe (but since its cached, I guess maybe that could cause an issue). Do you think I need to manually deepcopy somewhere to prevent multiple masks from being applied on top of each other? Can you reproduce a case where that happens?
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.
ah, you're right, this does cause a problem. I'll push an update that makes a deepcopy within _apply_subset_masks
.
otherwise subsets will just be applied on top of each other instead of the original non-masked spectrum
141b62a
to
d356521
Compare
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.
I don't grok the internals, but linear estimate seems to work as advertised. And the tests pass. So approval from me. Thanks!
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.
Looks good to me. The estimates being based on the selected subset makes things so much easier, I was able to fit a gaussian successfully without updating any parameters from the initial estimates, which is a great change.
Description
This pull request cleans up some duplicating caching and subset handling in model fitting while working on the solution to #1910 (whose actual fix is blocked by significant subset refactoring). It also improves on the intializer of
Linear1D
to estimate both the slope and intercept.Change log entry
CHANGES.rst
? If you want to avoid merge conflicts,list the proposed change log here for review and add to
CHANGES.rst
before merge. If no, maintainershould add a
no-changelog-entry-needed
label.Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.