On Mon, Jul 17, 2017 at 10:52 AM, Eric Wieser <wieser.eric+nu...@gmail.com> wrote:
> Here’s a hack that lets you keep using ==: > > class IsCompare: > __array_priority__ = 999999 # needed to make it work on either side of > `==` > def __init__(self, val): self._val = val > def __eq__(self, other): return other is self._val > def __neq__(self, other): return other is not self._val > > a == IsCompare(None) # a is None > a == np.array(IsCompare(None)) # broadcasted a is None > > Frankly, I'd stick with a well-named utility function. It's much more kind to those who have to read the code (e.g. you in 6 months). :-) -- Robert Kern
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion