[Numpy-discussion] copying in nanXXX
Charles R Harris
charlesr.harris@gmail....
Sun Jun 29 19:54:44 CDT 2008
On Sun, Jun 29, 2008 at 6:24 PM, Damian Eads <eads@soe.ucsc.edu> wrote:
> Hi there,
>
> I'm using nansum for some code and noticed it does a bit of copying.
> Specifically, the nanxxx functions copy the input array, create an isnan
> boolean mask, set the nan values to make them insignificant (nansum: 0,
> nanmin: inf, or nanmax: -inf), and then call xxx to compute the statistic.
>
> def nansum(a, axis=None):
> """Sum the array over the given axis, treating NaNs as 0.
> """
> y = array(a,subok=True)
> if not issubclass(y.dtype.type, _nx.integer):
> y[isnan(a)] = 0
> return y.sum(axis)
>
> Unless someone has already done this, I will offer to write C versions
> of these functions. Does anyone else think this is useful?
>
There are several places where numpy code can be made more efficient, even
in the c code. How to go about improving things needs to be discussed at
some point, but I don't think it's the first priority right now. That said,
every bit of code helps. So I think you should open an ticket for
enhancement and attach any code you come up with.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080629/440e8f10/attachment.html
More information about the Numpy-discussion
mailing list