Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support callable objects in curve_fit #3418

Open
jl-wynen opened this issue Apr 5, 2024 · 0 comments
Open

Support callable objects in curve_fit #3418

jl-wynen opened this issue Apr 5, 2024 · 0 comments
Labels

Comments

@jl-wynen
Copy link
Member

jl-wynen commented Apr 5, 2024

Currently, this

class Model:
    def __call__(self, x, *, param):
        return x * param

curve_fit(Model(), x, p0={'param': sc.scalar(1)})

raises

ValueError: Fit function must take exactly one positional argument

But this should be allowed.

This comes from the requirement that fit parameters must be passed as keyword arguments. But it limits the use to functions.

Note that curve_fit(Model().__call__, x, p0={'param': sc.scalar(1)}) has the same problem. We need to define a wrapper function or lambda to workaround the limitation.

@jl-wynen jl-wynen added the bug label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant