Skip to content

Commit

Permalink
only handle pow+int specially
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Sep 13, 2024
1 parent c3c41cf commit 76b3e66
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pytato/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,12 @@ def cast_to_result_type(
assert result_dtype != np.bool_

expr = TypeCast(result_dtype, expr)
elif isinstance(expr, (complex,)) and not isinstance(expr, np.generic):
# See https://github.com/inducer/pytato/pull/247 and
# https://github.com/inducer/pytato/issues/542
expr = np.dtype(type(expr)).type(expr)
return expr
elif isinstance(expr, SCALAR_CLASSES):
# See https://github.com/inducer/pytato/issues/542
# on why pow() + integers is handled separately
if (op != prim.Power and np.issubdtype(type(expr), np.integer)
and not np.issubdtype(result_dtype, np.integer)):
expr = result_dtype.type(expr)

return expr

Expand Down

0 comments on commit 76b3e66

Please sign in to comment.