scipy_residual_to_lmfit

class utilipy.data_utils.fitting.scipy_residual_to_lmfit(func: Optional[Callable] = None, var_order: Optional[list] = None)[source]

Bases: ObjectProxy

decorator to make scipy residual functions compatible with lmfit.

(see https://lmfit.github.io/lmfit-py/fitting.html)

Parameters
var_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(var_order=['amp', 'phase', 'freq', 'decay'])
... def residual(vars, x, data, eps_data):
...     amp, phase, freq, decay = vars
...     # calculate residual here
...     return res

Initialize Proxy.

Methods Summary

decorator(var_order)

Decorator.

lmfit(params, *args, **kwargs)

lmfit version of function.

Methods Documentation

classmethod decorator(var_order: list) Callable[source]

Decorator.

lmfit(params: Any, *args: Any, **kwargs: Any) Any[source]

lmfit version of function.