[SciPy-User] Gradient inputs to SciPy optimize routines
Mon Jul 23 07:17:21 CDT 2012
Oh, so that's what's going on!!
All the optimize routines assume that the gradients are supplied in the form of one-dimensional (1D or one-axis) numpy arrays, and that the Hessians are supplied in the form of two-axis (2D or two-dimensional) numpy arrays. [Has terminology settled on always using 'nD' in place of 'n-dimensional' and 'n-axis'? 'nD' is shorter.]
But to find that out I had to examine the code for `rosen_der`, and discover that its return value was a numpy array.
Now, how far is this generalizable? Is it true that _all_ native SciPy routines require numpy arrays as inputs? Is it true that _none_ of the native SciPy routines _ever_ take ordinary Python sequences as input? Is it true that _all_ native SciPy routines return numpy arrays and _never_ an ordinary Python sequence?
If those broad generalizations are true, then perhaps it should be stated (even emphasized) in the documentation. If not true, then maybe it would be a good idea to flag this as a possible "gotcha" -- one that might signal its presence by an error message of the form "bad operation for : '...', where '...' is some ordinary Python sequence such as a list or tuple.
Also, if the broad generalization is not true, then maybe SciPy routines could themselves check the input type and do something appropriate, such as:
1. Tacitly convert whatever they receive to the type they want to use in the body of the routine, or
2. Provide the user with an error message stating that the input type is wrong and what input type is
2645 E Southern Ave A241
Tempe AZ 85282
CELL Igor: 480-438-3918
CELL Alf: 602-568-6948 (but not often turned on)
> From: Warren Weckesser <firstname.lastname@example.org>
>To: The Helmbolds <email@example.com>; SciPy Users List <firstname.lastname@example.org>
>Cc: Ralf Gommers <email@example.com>
>Sent: Sunday, July 22, 2012 4:38 PM
>Subject: Re: [SciPy-User] Documentation
>On Sun, Jul 22, 2012 at 6:11 PM, The Helmbolds <firstname.lastname@example.org> wrote:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User