[SciPy-User] Gradient inputs to SciPy optimize routines
Mon Jul 23 09:36:56 CDT 2012
Den 23. juli 2012 kl. 14:17 skrev The Helmbolds <email@example.com>:
> 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 the documentation says an argument is "array like" it means it can be "any Python sequence that can be coverted to a NumPy array."
Internally, native SciPy routines often work with NumPy arrays represented as C pointers or Fortran arrays. They will do the conversion from Python sequences to NumPy if the documentation says so. The NumPy functions np.ascontiguousarray and np.asfortranarray are often used internally in SciPy for this purpose; that is, they will only make a copy if the argument is not a NumPy ndarray that can be passed safely to C or Fortran. Any Python sequence which is not a C or Fortran contiguous NumPy array will be converted in that process.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User