Skip to content

Class _arraymethod in ma.core is a descriptor, yet mutable. #5247

Closed
@markshannon

Description

@markshannon

This leads to "interesting" behaviour:

>>> from numpy.ma.core import MaskedArray
>>> import numpy as np
>>> z = np.zeros(5)
>>> z
array([ 0.,  0.,  0.,  0.,  0.])
>>> o = np.ones(5)
>>> o
array([ 1.,  1.,  1.,  1.,  1.])
>>> mz = MaskedArray(z)
>>> mz
masked_array(data = [ 0.  0.  0.  0.  0.],
             mask = False,
       fill_value = 1e+20)

>>> mo = MaskedArray(o)
>>> mo
masked_array(data = [ 1.  1.  1.  1.  1.],
             mask = False,
       fill_value = 1e+20)

>>> mocopy = mo.copy
>>> mocopy()
masked_array(data = [ 1.  1.  1.  1.  1.],
             mask = False,
       fill_value = 1e+20)

>>> mz.copy
<numpy.ma.core._arraymethod object at 0x29fff10>
>>> mocopy()
masked_array(data = [ 0.  0.  0.  0.  0.],
             mask = False,
       fill_value = 1e+20)

>>> mo.copy
<numpy.ma.core._arraymethod object at 0x29fff10>
>>> mocopy()
masked_array(data = [ 1.  1.  1.  1.  1.],
             mask = False,
       fill_value = 1e+20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions