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

Eric Firing efiring@hawaii....
Tue Dec 2 00:59:01 CST 2008


Pierre,

Your change fixed masked_all for the example I gave, but I think it 
introduced a new failure in zeros:


dt = np.dtype([((' Pressure, Digiquartz [db]', 'P'), '<f4'), ((' Depth 
[salt water, m]', 'D'), '<f4'), ((' Temperature [ITS-90, deg C]', 'T'), 
'<f4'), ((' Descent Rate [m/s]', 'w'), '<f4'), ((' Salinity [PSU]', 
'S'), '<f4'), ((' Density [sigma-theta, Kg/m^3]', 'sigtheta'), '<f4'), 
((' Potential Temperature [ITS-90, deg C]', 'theta'), '<f4')])

np.ma.zeros((2,2), dt)


results in:

ValueError                                Traceback (most recent call last)

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

/usr/local/lib/python2.5/site-packages/numpy/ma/core.pyc in 
__call__(self, a, *args, **params)
    4533     #
    4534     def __call__(self, a, *args, **params):
-> 4535         return self._func.__call__(a, *args, 
**params).view(MaskedArray)
    4536
    4537 arange = _convert2ma('arange')

/usr/local/lib/python2.5/site-packages/numpy/ma/core.pyc in 
__array_finalize__(self, obj)
    1548             odtype = obj.dtype
    1549             if odtype.names:
-> 1550                 _mask = getattr(obj, '_mask', 
make_mask_none(obj.shape, odtype))
    1551             else:
    1552                 _mask = getattr(obj, '_mask', nomask)

/usr/local/lib/python2.5/site-packages/numpy/ma/core.pyc in 
make_mask_none(newshape, dtype)
     921         result = np.zeros(newshape, dtype=MaskType)
     922     else:
--> 923         result = np.zeros(newshape, dtype=make_mask_descr(dtype))
     924     return result
     925

/usr/local/lib/python2.5/site-packages/numpy/ma/core.pyc in 
make_mask_descr(ndtype)
     819     if not isinstance(ndtype, np.dtype):
     820         ndtype = np.dtype(ndtype)
--> 821     return np.dtype(_make_descr(ndtype))
     822
     823 def get_mask(a):

/usr/local/lib/python2.5/site-packages/numpy/ma/core.pyc in 
_make_descr(datatype)
     806             descr = []
     807             for name in names:
--> 808                 (ndtype, _) = datatype.fields[name]
     809                 descr.append((name, _make_descr(ndtype)))
     810             return descr

ValueError: too many values to unpack



More information about the Numpy-discussion mailing list