scipy_residual_to_lmfit¶
-
class
utilipy.data_utils.fitting.
scipy_residual_to_lmfit
(func: Optional[Callable] = None, param_order: Optional[Sequence] = None)[source]¶ Bases:
ObjectProxy
Decorator to make scipy residual functions compatible with lmfit.
(see https://lmfit.github.io/lmfit-py/fitting.html)
- Parameters
- param_orderlist of strs
the variable order used by lmfit the strings are the names of the lmfit parameters must be in the same order as the scipy residual function
- Returns
- scipy_residual_to_lmfitclass
internally constructed class
Notes
the function can be called as normal add a .lmfit function for use in lmfit minimizations see https://lmfit.github.io/lmfit-py/fitting.html
>>> @scipy_residual_to_lmfit(param_order=['amp', 'phase', 'freq', 'decay']) ... def residual(variables, x, data, eps_data): ... amp, phase, freq, decay = variables ... # calculate residual here ... return res
Todo
since using ObjectProxy, make it compatible with bound functions see https://wrapt.readthedocs.io/en/latest/wrappers.html
Initialize Proxy.
Methods Summary
__call__
(*args, **kwargs)Call scipy residual.
decorator
(param_order)Decorator.
lmfit
(params, *args, **kwargs)lmfit
version of function.Methods Documentation