[Numpy-discussion] Scalar-ndarray arguments passed to not_equal
Thu Feb 11 14:31:08 CST 2010
On Thu, Feb 11, 2010 at 12:21 PM, Friedrich Romstedt
> Hi Keith,
> 2010/2/11 Keith Goodman <email@example.com>:
>> Is there some way to tell numpy to use my __eq__ instead of its own?
>> That would solve my problem. I had a similar problem with __radd__
>> which was solved by setting __array_priority__ = 10. But that doesn't
>> work in this case.
> It's quite simple, but hidden in the forest of documentation (though
> it mentiones it, and quite in detail).
> numpy.set_numeric_ops(equal = my_equal_callable_object)
> Note that you should _not_ simply use a function:
> def equal(a, b):
Hey! You broke my numpy :)
>> def addbug(x, y):
...: return x - y
>> old_funcs = np.set_numeric_ops(add=addbug)
>> np.array() + np.array()
That is brilliant! Thanks again.
More information about the NumPy-Discussion