[Numpy-discussion] numpy.ma bug: need sanity check in masked_where
Eric Firing
efiring@hawaii....
Mon Mar 17 13:26:06 CDT 2008
Pierre,
I just tripped over what boils down to the sequence given below. It
would be useful if the error in line 53 were trapped right away; as it
is, it results in a masked array that looks reasonable but fails in a
non-obvious way.
Eric
In [52]:x = [1,2]
In [53]:y = ma.masked_where(False, x)
In [54]:y
Out[54]:
masked_array(data = [1 2],
mask = False,
fill_value=999999)
In [55]:y[1]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/home/efiring/<ipython console> in <module>()
/usr/local/lib/python2.5/site-packages/numpy/ma/core.pyc in
__getitem__(self, indx)
1307 if not getattr(dout,'ndim', False):
1308 # Just a scalar............
-> 1309 if m is not nomask and m[indx]:
1310 return masked
1311 else:
IndexError: 0-d arrays can't be indexed
More information about the Numpy-discussion
mailing list