[Numpy-discussion] Scalar-ndarray arguments passed to not_equal

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Feb 11 15:47:33 EST 2010


On Thu, Feb 11, 2010 at 3:43 PM,  <josef.pktd at gmail.com> wrote:
> On Thu, Feb 11, 2010 at 3:40 PM, Keith Goodman <kwgoodman at gmail.com> wrote:
>> On Thu, Feb 11, 2010 at 12:32 PM, Friedrich Romstedt
>> <friedrichromstedt at gmail.com> wrote:
>>>> 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])
>>> Yea, that's what I meant.  Great.
>>>
>>> :-) :-)
>>
>> Who needs to type np.dot when you can do:
>>
>>>> def dotmult(x, y):
>>   ....:     return np.dot(x, y)
>>   ....:
>>>> old_funcs = np.set_numeric_ops(multiply=dotmult)
>>>>
>>>> np.array([1, 2, 3]) * np.array([1, 2, 3])
>>   14
>>
>> I can see many bugs coming my way...
>
> especially if this is global monkey patching, there might be some
> surprised users

If this is global it won't work, because only the last package that
changes it wins. ??

Josef

>
> Josef
> (Ruby, here we come)
>
>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>



More information about the NumPy-Discussion mailing list