Skip to content

MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning #15168

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 1 commit into from
Sep 4, 2019

Conversation

tacaswell
Copy link
Member

This is a workaround to https://bugs.python.org/issue37980

I see failures on this locally, but we do not see these failures on the azure pre-release, not sure why.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant

@tacaswell
Copy link
Member Author

force-pushed to fix spelling 🙄

@tacaswell tacaswell changed the title MNT: explicitly cast np.bool_ -> bool to prevent derpcation warnings MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning Sep 2, 2019
@tacaswell
Copy link
Member Author

ok, I figured out why the python preview is not failing on azure, we are installing py3.8b4, but in the tests are falling back to py3.6.8.

@tacaswell
Copy link
Member Author

This seems to be hitting https://bugs.python.org/issue37074 which looks like it has been fixed, but not an a tagged pre-release yet.

@tacaswell tacaswell force-pushed the mnt_py38_npbool_warnings branch from f87f7b4 to 6df091f Compare September 3, 2019 19:49
This is a workaround to https://bugs.python.org/issue37980

- np.bool raises a warning if you try to use it as an index (by
  warning in its `__index__` method
- in py38 python/cpython#11952 python changes
  the code path used to convert `np.bool_` -> int for as it is used in
  `sorted` so it now goes through the `__index__` code path
- this causes a bunch of spurious warnings to come out of Matplotlib.
@tacaswell tacaswell force-pushed the mnt_py38_npbool_warnings branch from 6df091f to 3c93e41 Compare September 4, 2019 15:57
@tacaswell
Copy link
Member Author

I just force-pushed a commit with in-line comments of why we are doing extra work, will open a PR later today with the "fix" to the azure pre-release python.

@tacaswell
Copy link
Member Author

Although there is a chance that CPython will fix this before py3.8 is released, there is also a chance that they will decide that this is a NumPy problem so I think we should defensively merge this so we do not have to hold any release on a decision being made upstream (either in NumPy or Python).

@jklymak jklymak merged commit b965c4d into matplotlib:master Sep 4, 2019
@lumberbot-app
Copy link

lumberbot-app bot commented Sep 4, 2019

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v2.2.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 b965c4d4603caac702fa2530ac88d35dd3bb4df9
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #15168: MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning'
  1. Push to a named branch :
git push YOURFORK v2.2.x:auto-backport-of-pr-15168-on-v2.2.x
  1. Create a PR against branch v2.2.x, I would have named this PR:

"Backport PR #15168 on branch v2.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Sep 4, 2019
tacaswell added a commit that referenced this pull request Sep 4, 2019
…168-on-v3.1.x

Backport PR #15168 on branch v3.1.x (MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning)
@tacaswell tacaswell deleted the mnt_py38_npbool_warnings branch September 4, 2019 19:46
@tacaswell tacaswell modified the milestones: v2.2.5, v3.1.2 Sep 5, 2019
@tacaswell
Copy link
Member Author

this code path is not in 2.2.x, these changes came in via 7f7b048 which is only in 3.1.1+

@QuLogic
Copy link
Member

QuLogic commented Sep 7, 2019

FTR, this works for Python 3.8.0b4: https://koji.fedoraproject.org/koji/taskinfo?taskID=37504715

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 this pull request may close these issues.

4 participants