[Numpy-tickets] [NumPy] #749: incorrect behaviour when using mask to index masked array

NumPy numpy-tickets@scipy....
Sun Apr 20 15:03:55 CDT 2008


#749: incorrect behaviour when using mask to index masked array
-------------------------+--------------------------------------------------
 Reporter:  mattknox_ca  |       Owner:  somebody
     Type:  defect       |      Status:  new     
 Priority:  normal       |   Milestone:  1.1.0   
Component:  Other        |     Version:  none    
 Severity:  normal       |    Keywords:          
-------------------------+--------------------------------------------------
 Below is some code that illustrates the problem

 =========================================

 import numpy as np

 from numpy import ma


 a = ma.array([55])

 a[0] = ma.masked


 b = ma.array([66])

 print repr(a[a.mask])

 print repr(b[a.mask])


 _idx = a.mask #.copy()

 print repr(_idx)


 a[_idx] = b[_idx]


 # a[0] is equal to 55 still, but should be 66


 print repr(a)

 print repr(b)

 =========================================

 If you change the code such that _idx = a.mask.copy(), then it works
 as expected (ie. a[0] == 66)

 Even wierder is that if you explicitly pass mask=[True] when
 constructing "a", and remove the
 line "a[0] = ma.masked", then it works without needing to copy the
 mask prior to indexing.

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/749>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list