Skip to content

Question for issue like "'bool_' object cannot be converted to 'PyBool'"? #2078

Answered by davidhewitt
dbsxdbsx asked this question in Questions
Discussion options

You must be logged in to vote

I'm afraid that I don't have knowledge of your code, so don't know why a specific environment is producing numpy.bool_ values.

PyO3's rejection of this type is unsuprising, as numpy.bool_ does not inherit from bool:

>>> numpy.bool_.__mro__
(<class 'numpy.bool_'>, <class 'numpy.generic'>, <class 'object'>)
>>> bool.__mro__
(<class 'bool'>, <class 'int'>, <class 'object'>)
>>> issubclass(bool, int)
True
>>> issubclass(numpy.bool_, bool)
False

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dbsxdbsx
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2077 on December 27, 2021 09:14.