Skip to content

Commit

Permalink
Problem: numpy raised TypeError: Cannot cast ufunc add output from dt…
Browse files Browse the repository at this point in the history
…ype('complex128') to dtype('float64') with casting rule 'same_kind'

Solution: use numpy.add(x,y,out=x, casting='unsafe') to cast from complex to float if necessary
  • Loading branch information
Sebastian Walter committed Jun 30, 2016
1 parent c6afb7d commit f563d86
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions algopy/utpm/algorithms.py
Expand Up @@ -1190,9 +1190,9 @@ def _dot(cls, x_data, y_data, out = None):
for d in range(D):
for p in range(P):
for c in range(d+1):
z_data[d,p,...] += numpy.dot(
x_data[c,p,...],
y_data[d-c,p,...])
tmp = numpy.dot(x_data[c,p,...],
y_data[d-c,p,...])
numpy.add(z_data[d,p,...], tmp, out=z_data[d,p, ...], casting='unsafe')

return out

Expand Down

0 comments on commit f563d86

Please sign in to comment.