Packing argument faling with scipy.optimize.curve_fit function

15 views
Skip to first unread message

romain...@gmail.com

unread,
Jan 11, 2019, 4:00:47 AM1/11/19
to SciPy-user
Hello,

I am trying to use and understand the scipy.optimize.curve_fit() function. In particular, I wanted to pass a function with packed parameter (general polynoms). Along the way, I made a simple example which seems to show that it doesn't work as expected. It is very likely that I am missing something, and any help is welcome !

The working example can be found here. One possibly important note is that the not-working function is not vectorized, namely f(a, *p) != [f(val, *p) for val in a], if a is a numpy array.

Many thanks for your help,
Cheers,
Romain

romain...@gmail.com

unread,
Jan 11, 2019, 7:20:07 AM1/11/19
to SciPy-user

The working example can be found here. One possibly important note is that the not-working function is not vectorized, namely f(a, *p) != [f(val, *p) for val in a], if a is a numpy array.

That was indeed the problem. By redefining func = np.vectorized(func), it worked fine.

Reply all
Reply to author
Forward
0 new messages