-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Wrong dtype after temporary elision #9109
Copy link
Copy link
Closed
Milestone
Description
REported By Jens Jørgen Mortensen on the mailing list:
import numpy as np
s = (27, 27, 27)
x = np.ones(s, complex)
y = np.zeros(s)
y += abs(x * 2.0)**2
#Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
#TypeError: Cannot cast ufunc add output from dtype('complex128') to dtype('float64') with casting rule #'same_kind'
but it works for abs(x). So my guess is the temporary of x * 2.0 must be modified in place in the abs, which results in the wrong output type. So the temporary elision seems to think it can reuse the array when it should not in this case. Ping @juliantaylor.
Reactions are currently unavailable