[Numpy-discussion] argwhere does not accept py list

Scott Sinclair scott.sinclair.za at gmail.com
Wed Jul 8 03:18:46 EDT 2009


> 2009/7/8 Robert Kern <robert.kern at gmail.com>:
> 2009/7/4 Stéfan van der Walt <stefan at sun.ac.za>:
>> Thanks, Scott.  This should now be fixed in SVN.
>
> You should probably change that to asanyarray() before the masked
> array crowd gets upset. :-)

I hadn't thought about that, but I'm don't think it matters in this
case. MaskedArray.nonzero() returns a tuple of ndarrays...

>>> import numpy as np
>>> a = np.ma.array([4,0,2,1,3])
>>> a
masked_array(data = [4 0 2 1 3],
             mask = False,
       fill_value = 999999)

>>> np.asarray(a)
array([4, 0, 2, 1, 3])
>>> np.asarray(a).nonzero()
(array([0, 2, 3, 4]),)
>>> np.asanyarray(a)
masked_array(data = [4 0 2 1 3],
             mask = False,
       fill_value = 999999)
>>> np.asanyarray(a).nonzero()
(array([0, 2, 3, 4]),)

Cheers,
Scott



More information about the NumPy-Discussion mailing list