[Numpy-discussion] argwhere does not accept py list

Pierre GM pgmdevlist@gmail....
Wed Jul 8 13:33:15 CDT 2009


On Jul 8, 2009, at 3:18 AM, Scott Sinclair wrote:

>> 2009/7/8 Robert Kern <robert.kern@gmail.com>:
>> 2009/7/4 Stéfan van der Walt <stefan@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...

Except that a masked value is considered zero in that case:

 >>> a = ma.array([0,1,2,3],mask=[0,0,1,0])
 >>> a.nonzero()
  (array([1, 3]),)

Taking np.asarray instead of np.asanyarray loses the mask, and you end  
up with the wrong result.





More information about the NumPy-Discussion mailing list