Skip to content

Resolve deprecated usage of bitwise operators on Python Boolean types #1072

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

emmanuel-ferdman
Copy link

PR Summary

This small PR resolves the deprecation warnings coming from the bitwise operators on Python Boolean types:

/Users/runner/work/porespy/porespy/test/unit/test_filters.py:28: DeprecationWarning: Bitwise inversion '~' on bool is deprecated and will be removed in Python 3.16. This returns the bitwise inversion of the underlying int object and is usually not what you expect from negating a bool. Use the 'not' operator for boolean negation or ~int(x) if you really want the bitwise inversion of the underlying int.

See CI logs for more information.

@jgostick
Copy link
Member

I appreciate the PR @emmanuel-ferdman, but I'm a bit surprized this is only happen in one place. I just searched the code base for if ~ and found this usage is also on:

line 389 of _injection.py
line 81 of _ibip_gpu.py

I wonder what other search strings would turn up something?

@jgostick
Copy link
Member

Just searching for ~ returns 217 usages. We use this regularly to invert numpy boolean images (which I really hope is not going to be deprecated!).

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.

2 participants