[Numpy-discussion] A minor annoyance with MA

PGM pgmdevlist at gmail.com
Tue Aug 29 00:25:25 CDT 2006

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

More information about the Numpy-discussion mailing list