-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Closed as not planned
Description
float64
does not respect __rmul__()
protocol and does unexpected things instead.
I didn't test, but it might be similar for the other operators.
Reproducing code example:
import numpy as np
x = np.float64(2)
x * (1,)
raises a TypeError
(expected), while __mul__((1,))
correctly returns NotImplemented
.
import numpy as np
class Test(tuple):
def __rmul__(self, other):
return None
x = np.float64(2)
x * Test((1,))
returns array([2])
, what is not correct (None
is the expected result).
On the contrary, 2 * Test((1,))
correctly returns None
.
NumPy/Python version information:
python: 3.8.2
numpy: 1.19.2
Metadata
Metadata
Assignees
Labels
No labels