-
-
Notifications
You must be signed in to change notification settings - Fork 11k
BUG: MaskedArray _optinfo dictionary is not updated when calling __eq__/__ne__ #9279
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
Conversation
While probably right (don't know this stuff well enough to say right away). This requires a test to be merged (the tests are usually in the same folder where the code is in the "tests" subfolder. Also, please try to format your git commit according to our guidelines, such as |
Otherwise, thanks for creating a PR :) |
Why does |
@seberg: I added a simple test and sorry for ignoring your commit message format. |
...allright, I try to bring this issue back to the agenda by providing more details (maybe I should have done this earlier). At the moment I can add items to the _optdict attribute and the dictionary's content is usually propagated to masked arrays created during operations on the original one: x = np.ma.ones(10)
x._optinfo['test'] = True
(x > 4)._optinfo # {'test': True}
(x * 4)._optinfo # {'test': True} Only the __eq__/__ne__ methods behave differently: (x != 4)._optinfo # {}
(x == 4)._optinfo # {} I understand, that this is not a big issue for you, in the end it only affects a hardly documented feature. But it is still an inconsistency with a rather simple fix, that bit me, so I would be happy if this could be merged! |
Ok, if comparison preserves it, then I think I can accept that as an argument to make equality tests do so too |
numpy/ma/tests/test_core.py
Outdated
def test_eq_optinfo(self): | ||
a = array([1,2,2,4]) | ||
a._optinfo["key"] = "value" | ||
assert_equal(a._optinfo["key"], (a == 2)._optinfo["key"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extend this test to a bunch more operations? Arithmetic and comparison would be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or does a test exist for this elsewhere?)
Done... |
Closing in favor of #9540 |
Why did you close this? |
He had created it against his own master, which is tricky stuff. Possibly you can change the backing branch nowadays, not sure. |
@seberg I haven't found a solution to do so... |
The _optinfo dictionary is not updated when calling eq/ne