8000 Class _arraymethod in ma.core is a descriptor, yet mutable. · Issue #5247 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
markshannon opened this issue Oct 29, 2014 · 2 comments · Fixed by #6588
Closed

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

markshannon opened this issue Oct 29, 2014 · 2 comments · Fixed by #6588

Comments

@markshannon
Copy link

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)
@pv
Copy link
Member
pv commented Oct 29, 2014

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

8000

@pv
Copy link
Member
pv commented Oct 29, 2014

jjhelmus added a commit to jjhelmus/numpy that referenced this issue Oct 30, 2015
Replace the _arraymethod class in ma.core with a function factory which
returns class method wrappers around basic array methods. These methods are
bound to the MaskedArray instance and are immutable.

Previously _arraymethod was a class which would incorrectly operate on the
MaskedArray object which last accessed the particular named function.

closes numpy#5247
jaimefrio pushed a commit to jaimefrio/numpy that referenced this issue Mar 22, 2016
Replace the _arraymethod class in ma.core with a function factory which
returns class method wrappers around basic array methods. These methods are
bound to the MaskedArray instance and are immutable.

Previously _arraymethod was a class which would incorrectly operate on the
MaskedArray object which last accessed the particular named function.

closes numpy#5247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0