Skip to content

Wrong dtype after temporary elision #9109

@seberg

Description

@seberg

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions