[Numpy-discussion] Scalar-ndarray arguments passed to not_equal
Keith Goodman
kwgoodman@gmail....
Thu Feb 11 14:31:08 CST 2010
On Thu, Feb 11, 2010 at 12:21 PM, Friedrich Romstedt
<friedrichromstedt@gmail.com> wrote:
> Hi Keith,
>
> 2010/2/11 Keith Goodman <kwgoodman@gmail.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).
>
> Use:
>
> 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([1]) + np.array([1])
array([0])
That is brilliant! Thanks again.
More information about the NumPy-Discussion
mailing list