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
match
/ case
operation: np.bool_
vs bool
#102905
Comments
Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> x = np.bool_(1)
>>> x
True
>>> type(x)
<class 'numpy.bool_'>
>>> isinstance(x, bool)
False
>>> Could be related to the fact that |
match
/ case
operation: np(bool_)
vs bool
match
/ case
operation: np.bool_
vs bool
Quoting PEP: https://peps.python.org/pep-0636/#matching-specific-values
So, it works as it should :) |
Thanks for the reference, I couldn't find it! 🙏 |
Because they are three special singletons :) For example, |
Ok thanks for your answer, I guess it makes sense. I was wondering then what would the most natural way of matching a numpy boolean array be. I think the answer is to view the array with >>> np.True_.astype(object) is True
True Cheers! |
Hello,
Sorry, I'm not sure whether this is an intended behaviour or a bug -- couldn't find definitive answer here.
The following snippet doesn't match as I expected:
Tested on
Python 3.10.6
.Thanks for your time.
Cheers!
The text was updated successfully, but these errors were encountered: