Add ParameterAnalysis#167
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #167 +/- ##
==========================================
Coverage ? 98.12%
==========================================
Files ? 47
Lines ? 3092
Branches ? 553
==========================================
Hits ? 3034
Misses ? 34
Partials ? 24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
rozyczko
left a comment
There was a problem hiding this comment.
Well written functionality. Just a few minor comments
| list | ||
| A list of all variables from the fit functions. | ||
| """ | ||
| variables = set() |
There was a problem hiding this comment.
Why do you initialize variables as a set but then convert into a list? This potentially loses ordering (which is not really required, anywya) but is confusing. We shouldn't have any duplicates, since the unique_name mechanism prohibits that.
There was a problem hiding this comment.
Because there may be overlapping variables in bindings, see e.g. the test test_get_all_variables_overlapping_variables:
model1 = Gaussian(display_name='model1')
binding1 = FitBinding(parameter_name='parameter1', model=model1)
binding2 = FitBinding(parameter_name='parameter2', model=model1)
parameter_analysis.bindings = [binding1, binding2]
# THEN
variables = parameter_analysis.get_all_variables()
# EXPECT
assert isinstance(variables, list)
assert set(variables) == set(model1.get_all_variables())
assert len(variables) == len(model1.get_all_variables())
(It's more likely to happen with fits to a DiffusionModel)
If there's a smarter way I'm happy to hear it :)
| if not _in_notebook(): | ||
| raise RuntimeError('plot() can only be used in a Jupyter notebook environment.') |
There was a problem hiding this comment.
This makes testing the plot function very awkward (tests must mock _in_notebook). Consider whether this restriction is necessary. Doesn't plopp support non-notebook figures? Maybe it can be used without the notebook.
There was a problem hiding this comment.
The plopp slicer is only supported in notebooks. I agree it's very awkward, but the alternative is not having the slicer and then the logic gets complicated since I need to figure out how to plot the data then.
| def bindings(self) -> list[FitBinding] | None: | ||
| """ |
There was a problem hiding this comment.
self._binding is always a list
def _verify_bindings(self, bindings: FitBinding | list[FitBinding] | None) -> list[FitBinding]:so | None is wrong here.
| FIT_FUNCTION_TYPE = ModelComponent | ComponentCollection | DiffusionModelBase | ||
|
|
There was a problem hiding this comment.
This seems to be unused. Consider removing
| Can be used to fit paramters to ModelComponents, ComponentCollections, or DiffusionModelBase | ||
| objects, and to plot the parameters and fit results. The parameters to be analyzed can be |
To fit the fit result from
Analysisto either aModelComponent,ComponentCollectionorDiffusionModel.