Skip to content

Add ParameterAnalysis#167

Open
henrikjacobsenfys wants to merge 19 commits intodevelopfrom
parameter-analysis
Open

Add ParameterAnalysis#167
henrikjacobsenfys wants to merge 19 commits intodevelopfrom
parameter-analysis

Conversation

@henrikjacobsenfys
Copy link
Copy Markdown
Member

@henrikjacobsenfys henrikjacobsenfys commented Apr 27, 2026

To fit the fit result from Analysis to either a ModelComponent, ComponentCollection or DiffusionModel.

@henrikjacobsenfys henrikjacobsenfys added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] medium Normal/default priority labels Apr 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 98.87640% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@7dbad54). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/easydynamics/analysis/parameter_analysis.py 98.41% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #167   +/-   ##
==========================================
  Coverage           ?   98.12%           
==========================================
  Files              ?       47           
  Lines              ?     3092           
  Branches           ?      553           
==========================================
  Hits               ?     3034           
  Misses             ?       34           
  Partials           ?       24           
Flag Coverage Δ
integration 46.89% <25.46%> (?)
unittests 98.12% <98.87%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@henrikjacobsenfys henrikjacobsenfys marked this pull request as ready for review April 27, 2026 19:50
@henrikjacobsenfys henrikjacobsenfys marked this pull request as draft April 28, 2026 11:52
henrikjacobsenfys and others added 6 commits April 28, 2026 14:33
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@henrikjacobsenfys henrikjacobsenfys marked this pull request as ready for review May 4, 2026 13:27
henrikjacobsenfys and others added 2 commits May 4, 2026 15:27
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@henrikjacobsenfys henrikjacobsenfys linked an issue May 5, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well written functionality. Just a few minor comments

list
A list of all variables from the fit functions.
"""
variables = set()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

@henrikjacobsenfys henrikjacobsenfys May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Comment on lines +207 to +208
if not _in_notebook():
raise RuntimeError('plot() can only be used in a Jupyter notebook environment.')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +96 to +97
def bindings(self) -> list[FitBinding] | None:
"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self._binding is always a list

def _verify_bindings(self, bindings: FitBinding | list[FitBinding] | None) -> list[FitBinding]:

so | None is wrong here.

Comment on lines +23 to +24
FIT_FUNCTION_TYPE = ModelComponent | ComponentCollection | DiffusionModelBase

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be unused. Consider removing

Comment on lines +30 to +31
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paramters -> parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] medium Normal/default priority [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ParameterAnalysis

2 participants