[SciPy-User] Gradient inputs to SciPy optimize routines

The Helmbolds helmrp at yahoo.com
Mon Jul 23 08:17:21 EDT 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
    required 

Bob
The Helmbolds
2645 E Southern Ave A241
Tempe AZ 85282
Email: helmrp at yahoo.com
VOX: 480-831-3611
CELL Igor: 480-438-3918
CELL Alf: 602-568-6948 (but not often turned on)


>________________________________
> From: Warren Weckesser <warren.weckesser at enthought.com>
>To: The Helmbolds <helmrp at yahoo.com>; SciPy Users List <scipy-user at scipy.org> 
>Cc: Ralf Gommers <ralf.gommers at googlemail.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 <helmrp at yahoo.com> wrote:
>
><snip> <snip>
>
> 
>>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120723/20bc376b/attachment.html>


More information about the SciPy-User mailing list