You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After cursing np.ndarray.__add__ , even if I re-curse after storing the original in a variable, the __radd__ method breaks.
Way to reproduce
import numpy as np
import forbiddenfruit
orig = np.ndarray.__add__
forbiddenfruit.curse(np.ndarray, '__add__', lambda x, y: 42)
arr = np.arange(5)
print(arr + 2) # prints 42
print(1 + arr) # prints 42
forbiddenfruit.curse(np.ndarray, '__add__', orig)
arr2 = np.arange(5)
print(arr + 3) # prints [3, 4, 5, 6, 7]
print(4 + arr) # raises: TypeError: descriptor '__add__' requires a 'numpy.ndarray' object but received a 'int'
Questions for cursing __radd__ (and others, such as __rsub__)
Is it possible? Or perhaps dependent on the underlying class?
Do you know where can I find documentation on the nb_* methods so I can find these things out for myself? I attempted to follow common patterns to include __radd__ to the as_number list (wouldve expected nb_radd to be its equivalent) and such to no success
The text was updated successfully, but these errors were encountered:
After cursing
np.ndarray.__add__
, even if I re-curse after storing the original in a variable, the__radd__
method breaks.Way to reproduce
Questions for cursing
__radd__
(and others, such as__rsub__
)__radd__
to theas_number
list (wouldve expectednb_radd
to be its equivalent) and such to no successThe text was updated successfully, but these errors were encountered: