[Numpy-tickets] [NumPy] #906: Deepcopy does not copy _mask attribute of a masked array object

NumPy numpy-tickets@scipy....
Fri Sep 5 10:57:26 CDT 2008


#906: Deepcopy does not copy _mask attribute of a masked array object
----------------------+-----------------------------------------------------
 Reporter:  vladan    |       Owner:  pierregm
     Type:  defect    |      Status:  new     
 Priority:  normal    |   Milestone:  1.2.0   
Component:  numpy.ma  |     Version:  1.1.1   
 Severity:  normal    |    Keywords:          
----------------------+-----------------------------------------------------
 Changing _mask attribute of a deep copy of a masked array also changes the
 original masked array. Example:

 In [1]: import numpy

 In [2]: from copy import deepcopy

 In [3]: mar = numpy.ma.array([0,1,2], mask=[False,True,False])

 In [4]: mar_copy = deepcopy(mar)

 In [5]: mar_copy._mask[1] = False

 In [6]: mar

 Out[6]:
 masked_array(data = [0 1 2],
       mask = [False False False],
       fill_value=999999)

 Interestingly, changing _mask of the original masked array does not change
 a deep copy of that array.

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


More information about the Numpy-tickets mailing list