[Numpy-discussion] bug in ma.masked_all()?

Eric Firing efiring@hawaii....
Mon Dec 1 17:09:59 CST 2008


ma.masked_all does not seem to work with fancy dtypes and more then one 

In [1]:import numpy as np

In [2]:dt = np.dtype({'names': ['a', 'b'], 'formats': ['f', 'f']})

In [3]:x = np.ma.masked_all((2,), dtype=dt)

In [4]:x
masked_array(data = [(--, --) (--, --)],
       mask = [(True, True) (True, True)],
       fill_value=(1.0000000200408773e+20, 1.0000000200408773e+20))

In [5]:x = np.ma.masked_all((2,2), dtype=dt)
TypeError                                 Traceback (most recent call last)

/home/efiring/<ipython console> in <module>()

/usr/local/lib/python2.5/site-packages/numpy/ma/extras.pyc in 
masked_all(shape, dtype)
      78     """
      79     a = masked_array(np.empty(shape, dtype),
---> 80                      mask=np.ones(shape, bool))
      81     return a

/usr/local/lib/python2.5/site-packages/numpy/ma/core.pyc in __new__(cls, 
data, mask, dtype, copy, subok, ndmin, fill_value, keep_mask, hard_mask, 
flag, shrink, **options)
    1304             except TypeError:
    1305                 mask = np.array([tuple([m]*len(mdtype)) for m 
in mask],
-> 1306                                  dtype=mdtype)
    1307             # Make sure the mask and the data have the same shape
    1308             if mask.shape != _data.shape:

TypeError: expected a readable buffer object



More information about the Numpy-discussion mailing list