Class _arraymethod in ma.core is a descriptor, yet mutable. · Issue #5247 · numpy/numpy · GitHub
Skip to content

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

Closed

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)

Activity

  1. pv commented on Oct 29, 2014

    @pv
    Member

    Nasty, looks like this will also introduce a race condition in threaded
    programs...

  2. pv commented on Oct 29, 2014

    @pv
    Member
  3. added a commit that references this issue on Oct 30, 2015
    db85ede
  4. added a commit that references this issue on Mar 22, 2016
    c64938a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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