Skip to content

Commit

Permalink
Quit converting numerical constants to NumPy scalars when using NumPy…
Browse files Browse the repository at this point in the history
… > 2.
  • Loading branch information
alexnick83 committed Feb 3, 2025
1 parent f623270 commit fd1e221
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dace/frontend/python/newast.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import numpy
import sympy

numpy_version = int(numpy.version.version.split('.')[0])

# register replacements in oprepo
import dace.frontend.python.replacements
from dace.frontend.python.replacements import _sym_type, broadcast_to, broadcast_together
Expand Down Expand Up @@ -4918,9 +4920,9 @@ def visit_Num(self, node: NumConstant):
return node.n

def visit_Constant(self, node: ast.Constant):
if isinstance(node.value, bool):
if isinstance(node.value, bool) and numpy_version < 2:
return dace.bool_(node.value)
if isinstance(node.value, (int, float, complex)):
if isinstance(node.value, (int, float, complex)) and numpy_version < 2:
return dtypes.dtype_to_typeclass(type(node.value))(node.value)
if isinstance(node.value, (str, bytes)):
return StringLiteral(node.value)
Expand Down

0 comments on commit fd1e221

Please sign in to comment.