On Thu, Jun 27, 2024 at 3:48 PM Aaron Meurer wrote:
>
> Apparently the reason this happens is that True, False, and None are
> compared using 'is' in structural pattern matching (see
> https://peps.python.org/pep-0634/#literal-patterns).
>
> There's no way NumPy could avoid this. First off, Python
Apparently the reason this happens is that True, False, and None are
compared using 'is' in structural pattern matching (see
https://peps.python.org/pep-0634/#literal-patterns).
There's no way NumPy could avoid this. First off, Python won't even
let you subclass bool:
>>> class mybool(bool):
...
It is well known that ‘np.bool' is not interchangeable with python ‘bool’, and
in fact 'issubclass(np.bool, bool)’ is false.
On the contrary, numpy floats are subclassing python
floats—'issubclass(np.float64, float) is true—so I’m wondering if the fact that
scalar comparison returns a np.bool b