[Numpy-discussion] A minor annoyance with MA

Paul Dubois pfdubois at gmail.com
Tue Aug 29 17:20:44 CDT 2006


Whatever the current state of the implementation, the original intention was
that ma be, where it makes sense, a "drop-in" replacement for numpy arrays.
Being retired I don't read this list all that carefully but I did see some
subjects concerning axis defaults (about the 98th time we have had that
discussion I suppose) and perhaps ma and numpy got out of sync, even if they
were in sync to begin with.

For sum, x.sum() should be the sum of the entire array, no? And that implies
a default of None, doesn't it? So a default of zero or one would be wrong.

Oh well, back to my nap.

On 28 Aug 2006 22:26:54 -0700, PGM <pgmdevlist at gmail.com> wrote:
>
> Folks,
> I keep running into the following problem since some recent update (I'm
> currently running 1.0b3, but the problem occurred roughly around 0.9.8):
>
> >>> import numpy.core.ma as MA
> >>> x=MA.array([[1],[2]],mask=False)
> >>> x.sum(None)
> /usr/lib64/python2.4/site-packages/numpy/core/ma.py in reduce(self,
> target,
> axis, dtype)
>     393                 m.shape = (1,)
>     394         if m is nomask:
> --> 395             return masked_array (self.f.reduce (t, axis))
>     396         else:
>     397             t = masked_array (t, m)
>
> TypeError: an integer is required
> #................................
>
> Note that x.sum(0) and x.sum(1)  work fine. I know some consensus seems to
> be
> lacking with MA, but still, I can't see why axis=None is not recognized.
>
> Corollary: with masked array, the default axis for sum is 0, when it's
> None
> for regular arrays. Is there a reason for this inconsistency ?
>
> Thanks a lot
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060829/0dfad1c8/attachment-0001.html 


More information about the Numpy-discussion mailing list