[Numpy-discussion] masked arrays of structured arrays
Ernest Adrogué
eadrogue at gmx.net
Sat Aug 22 07:58:44 EDT 2009
Hi there,
Here is a structured array with 3 fields each of which has 3 fields
in turn:
In [3]: desc = [('a',int), ('b',int), ('c',int)]
In [4]: desc = [('x',desc), ('y',desc), ('z',desc)]
With a regular ndarray it works just fine:
In [11]: x = np.zeros(2, dtype=desc)
In [12]: x['x']['b'] = 2
In [13]: x['x']['b']
Out[13]: array([2, 2])
However if try the same with a masked array, it fails:
In [14]: x = np.ma.masked_all(2, dtype=desc)
In [15]: x['x']['b'] = 2
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home/ernest/<ipython console> in <module>()
/usr/lib/python2.5/site-packages/numpy/ma/core.pyc in __setitem__(self, indx, value)
1574 if self._mask is nomask:
1575 self._mask = make_mask_none(self.shape, self.dtype)
-> 1576 ndarray.__setitem__(self._mask, indx, getmask(value))
1577 return
1578 #........................................
ValueError: field named b not found.
Any idea of what the problem is?
Ernest
More information about the NumPy-Discussion
mailing list