[Numpy-discussion] numpy.gradient() does not return ndarray subclasses

Ryan May rmay31 at gmail.com
Thu Mar 18 14:15:54 EDT 2010


Can I get someone to look at: http://projects.scipy.org/numpy/ticket/1435

Basically, numpy.gradient() uses numpy.zeros() to create an output
array.  This breaks the use of any ndarray subclasses, like masked
arrays, since the function will only return
ndarrays.  I've attached a patch that fixes that problem and has a
simple test checking output types. With this patch, I can use gradient
on masked arrays and get appropriately masked output.

If we could, it'd be nice to get this in for 2.0 so that I (and my
coworkers who found the bug) don't have to use a custom patched
gradient until the next release after that.



Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_gradient_with_subclasses.diff
Type: application/octet-stream
Size: 1200 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100318/843d4059/attachment.obj>

More information about the NumPy-Discussion mailing list