[Numpy-discussion] cephes.arraymap & multipack

Jon Moody jbmoody at oakland.edu
Mon Feb 5 10:56:02 CST 2001


On Sun, Feb 04, 2001 at 02:45:51AM +0000, John J. Lee wrote:
> Not sure aboout the latter, but couldn't the former just be done by
> slicing?  How does this relate to ufuncs?

I'm probably being a little foggy on the distinction between the
ufuncs (element-wise operations on arrays) and the array functions
that sometimes allow you to specify an axis along which to apply the
function.

The problem I'm having with multipack.leastsq() is that the python
function I supply as the model for the fit is expected to return a 1-d
array or a single value.

So if, for example, the independent variable is a 1-d array of shape
(4,) and the data is a 3-d array of shape (4,256,256), to apply
leastsq() along axis 0 you have to either loop in python or set things
up so that you can map(leastsq, ....).  

It seems this kind of thing should properly be in the wrapper, and I
would guess it should be in the C half of the wrapper for speed,
unless there's some clever way to phrase it using native Numeric
functions from python.

> 
> They were only intended to be simple wrappings around the FORTRAN / C I
> think, so I suspect Travis would say 'feel free to add it'.

Maybe I should try.  Is there any general objection (don't all barf at
once) to using Fortran for an wrapper via pyfort (I don't know C)?

--
Jon Moody





More information about the Numpy-discussion mailing list