-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Labels
Description
Currently scipp.curve_fit ignores if an argument to the model function has a default value or not:
from functools import partial
import scipp as sc
def model(x, a, b=2):
return a * x + b
x = sc.linspace('x', 0, 10, 100)
y = model(x, a=0.5, b=2)
da = sc.DataArray(y, coords={'x': x})
popt, _ = sc.curve_fit(['x'], model, da, p0={'a': 1.0})
# Both a and b are among the parameters
#DataGroup(sizes={}, keys=[
# b: DataArray({}),
# a: DataArray({}),
#])This is different from the scipy.optimize.curve_fit implementation where default arguments are ignored.
It would be good to do the same thing everywhere. I don't really see strong reasons for doing it either way. It's conceptually simpler (imo) to just say that the function doesn't care about if an argument has a default value or not. But it can also lead to surprises, for example when using partial since keyword arguments set by partial can still be overridden, and thus using partial with scipp.curve_fit does nothing.