[Numpy-discussion] np.equal

Fernando Perez fperez.net@gmail....
Mon Dec 7 01:01:48 CST 2009


2009/12/6 josef.pktd <josef.pktd@gmail.com>:
>>>> np.equal(np.arange(5),'a')
> NotImplemented

Why is NotImplemented a *return* value?  Normally NotImplementedError
is a raised exception, but if it's not implemented, it shouldn't be
returned as a value.

For one thing, it leads to absurdities like the following being possible:

In [6]: if np.equal(np.random.rand(5),'a'):
   ...:     print("Array equal to 'a'")
   ...:
   ...:
Array equal to 'a'

In [7]: if np.equal(np.random.rand(5),'a'):
    print("Array equal to 'a'")
   ...:
   ...:
Array equal to 'a'

In practice, it's as if np.equal() for not implemented cases returns
True always (since bool(NotImplemented)==True).

Cheers,

f


More information about the NumPy-Discussion mailing list