11 Mar
2020
11 Mar
'20
10:22 p.m.
On Wed, 11 Mar 2020 at 18:08, Serhiy Storchaka
There is a precedence (although not in the stdlib): NumPy array with dtype=bool.
import numpy bool(numpy.array([False, False])) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Actually, this is the behaviour of ndarray with any dtype. And IMHO ithis is quite.... terrible? I was so used to have False for an empty iterable that ndarray surprised me. I had to add a boolean() function in my little msutils module, that works also for ndarrays. And the reason ndarray do this is because it also override __eq__(): https://github.com/numpy/numpy/issues/15573