[Numpy-discussion] numpy.ma bug: need sanity check in masked_where

Stéfan van der Walt stefan@sun.ac...
Tue Mar 18 17:49:32 CDT 2008


Hi Pierre

Thanks for your fix for #703.  Unfortunately, it seems to have broken
some tests:

http://buildbot.scipy.org/builders/Windows_XP_x86_MSVC/builds/276/steps/shell_2/logs/stdio

Regards
Stéfan

On Mon, Mar 17, 2008 at 7:26 PM, Eric Firing <efiring@hawaii.edu> wrote:
> 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