-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
leastsq needlessly appends extra dimension for scalar problems #8532
Comments
I think this is due to the conversion of |
At this point, I would favor simply documentation-only fix as no doubt there is code out there relying on the current behavior, so it cannot just be changed. The issue is that in general these routines work only on 1D vectors and don't preserve the input shape, so the current behavior is not immediately considered a bug. If they generally preserved the input shape one could argue differently, but this is not the case. |
Ah, you're right: It's the flatten() at https://github.com/scipy/scipy/blob/master/scipy/optimize/minpack.py#L377. |
I think some change required in line 279 also, may be similar to this
|
This is being addressed in #8666 |
I've added a wrapper function for this in scipyx, so I guess everyone's happy now. 😃 |
When treating a scalar problem, leastsq needlessly appends an extra dimension to the argument of the function to be minimized as well as the result. MCVE:
Output:
Expected output:
As a consequence of this, many codes have to select the "first" element in a scalar problem
I personally ran into this when trying to clean up my
f(x)
which involvesdot
s and such, and wondered why things likewouldn't work. (It was the superfluous dimension in
theta
that had the dot product fail.)The text was updated successfully, but these errors were encountered: