Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: fix comparisons between masked and unmasked structured arrays #24556

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

Merged
merged 2 commits into from
Aug 27, 2023

Conversation

mhvk
Copy link
Contributor

@mhvk mhvk commented Aug 26, 2023

Fixes #24554, where it was noted that currently comparing a masked structured array with an unmasked one fails:

import numpy as np
a = np.array([(1., 2.), (3., 4.)], "f8,f8")
ma = np.ma.MaskedArray(a)
ma == a
# TypeError: Cannot compare structured or void to non-void arrays.

While looking at the code, it seemed obvious that a correction to the mask shape done inside an if statement should really be outside. A quick test confirmed that. So, the second commit fixes that too. I can make it 2 PRs if need be (but am trying to just be done...)

Not sure about the milestone. I put 1.26.0, but that may be too late. This definitely is not very urgent, since the bug has been there for years.

@mhvk mhvk added this to the 1.26.0 release milestone Aug 26, 2023
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Aug 26, 2023
@mattip mattip merged commit 0ec93b0 into numpy:main Aug 27, 2023
@mhvk mhvk deleted the ma_comparison_fixes branch August 27, 2023 09:21
@rgommers
Copy link
Member

CircleCI was actually failing here. Would you mind fixing in a follow-up PR @mhvk?

@mhvk
Copy link
Contributor Author

mhvk commented Aug 27, 2023

Oops, sorry! Testing is slow enough that I fear I only ran the regular tests, not doctests, and I hadn't had a chance to look at CI before this was merged. Anyway, fix (and added test) in #24559

@mhvk
Copy link
Contributor Author

mhvk commented Aug 27, 2023

OK, doctests should be fixed in main again...

@rgommers
Copy link
Member

Thanks!

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Aug 28, 2023
@charris charris removed this from the 1.26.0 release milestone Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: masked structured arrays cannot be compared to their unmasked counterparts
4 participants