Skip to content

Replace getmask with getmaskarray#24118

Closed
oscargus wants to merge 1 commit into
matplotlib:mainfrom
oscargus:getmaskarray
Closed

Replace getmask with getmaskarray#24118
oscargus wants to merge 1 commit into
matplotlib:mainfrom
oscargus:getmaskarray

Conversation

@oscargus

@oscargus oscargus commented Oct 7, 2022

Copy link
Copy Markdown
Member

PR Summary

Related to #24115

There seems to be a change in numpy 1.24 where sometimes getmask does not return an array. By using getmaskarray an array is guaranteed to be returned.

This PR is a bit speculative. It should not break anything, but may not really help as it may be that this change is never triggered (with current test data). On the other hand, it may help for certain input data (not clear which).

Will be interesting to see test coverage for the changes as experience shows that not all the masked stuff is tested everyhwhere.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@oscargus oscargus marked this pull request as ready for review October 7, 2022 10:14
@oscargus

oscargus commented Oct 7, 2022

Copy link
Copy Markdown
Member Author

Everything seems tested and passes.

@tacaswell tacaswell added this to the v3.7.0 milestone Oct 7, 2022
@tacaswell

Copy link
Copy Markdown
Member

I propose we merge this to main.

If we have more issues with masked arrays and new numpy we have this in our backpocket to backport if needed but we do not put speculative changes on the bug-fix branch.

@tacaswell

Copy link
Copy Markdown
Member

I am weakly against merging this. In all of these cases we are grabbing the mask, but then passing it straight back into numpy. If there is no mask (which numpy internally stores as numpy's version of False), then there is no need to pay the cost to expand that to an array of bools to pass it back into numpy.

I do think we should take the simplifications where we in-line the getmask calls.

@oscargus

oscargus commented Oct 7, 2022

Copy link
Copy Markdown
Member Author

Sure, we can just let it hang around and see if anything shows up.

I realize that the case which broke is quite different from these, so it may very well be that it is OK to pass a scalar mask here.

I'll try to remind myself of it when 3.7 is closing in and create a PR with the inlining if not merged by then.

@oscargus oscargus marked this pull request as draft October 12, 2022 07:00
@tacaswell tacaswell modified the milestones: v3.7.0, future releases Oct 21, 2022
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@github-actions github-actions Bot added the status: inactive Marked by the “Stale” Github Action label Jun 1, 2026
@timhoffm

timhoffm commented Jun 1, 2026

Copy link
Copy Markdown
Member

I close this as not worth pursuing.

There's the larger idea that we should get rid of internally using masked arrays and instead use regular arrays with NaNs. That would simplify logic and increase performance a bit, see #31008.

@timhoffm timhoffm closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: inactive Marked by the “Stale” Github Action status: needs rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants