Skip to content

Sampler._run captures 'original' fit function after MultiFitter has mutated it #266

@rozyczko

Description

@rozyczko

Finding F-H7 in DEEP_ANALYSIS.md (parent #261).

src/easyscience/fitting/sampler.py:299-306:

wrapped = self._fitter._fit_function_wrapper(x_new, flatten=True)  # MultiFitter mutates _fit_function here
original_fit_func = self._fitter.fit_function                      # captures the LAST dataset's function

MultiFitter._fit_function_wrapper (multi_fitter.py:61-63) loops self._fit_function = this_fun, so after the loop _fit_function is the last dataset's function. Fitter.fit captures before wrapping (correct order, fitter.py:299-300); Sampler._run does it backwards. With >= 2 datasets the finally restore installs the wrong function and corrupts subsequent fitter.fit() / evaluate() calls. Single-dataset tests cannot see this.

Fix: capture fit_function before calling _fit_function_wrapper. Add a 2-dataset MultiFitter sampling test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [area] fittingUmbrella for fitting related work[priority] highShould be prioritized soon[scope] bugBug report or fix (major.minor.PATCH)
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions