From c38d1f73d4a01b7ea0b8a16b0c780f62c488e961 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 4 Jul 2024 15:07:59 +0200 Subject: [PATCH 01/16] Setup now forces NumPy version 2 or higher. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d385abb9e1..3f8aaa9cb3 100644 --- a/setup.py +++ b/setup.py @@ -73,7 +73,7 @@ }, include_package_data=True, install_requires=[ - 'numpy < 2.0', 'networkx >= 2.5', 'astunparse', 'sympy >= 1.9', 'pyyaml', 'ply', 'websockets', 'jinja2', + 'numpy >= 2.0', 'networkx >= 2.5', 'astunparse', 'sympy >= 1.9', 'pyyaml', 'ply', 'websockets', 'jinja2', 'fparser >= 0.1.3', 'aenum >= 3.1', 'dataclasses; python_version < "3.7"', 'dill', 'pyreadline;platform_system=="Windows"', 'typing-compat; python_version < "3.8"' ] + cmake_requires, From e6d2afa797033df3e9b9b5fea3371efef8eef05b Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 4 Jul 2024 15:59:02 +0200 Subject: [PATCH 02/16] Removed version restriction. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3f8aaa9cb3..f0ecba933b 100644 --- a/setup.py +++ b/setup.py @@ -73,7 +73,7 @@ }, include_package_data=True, install_requires=[ - 'numpy >= 2.0', 'networkx >= 2.5', 'astunparse', 'sympy >= 1.9', 'pyyaml', 'ply', 'websockets', 'jinja2', + 'numpy', 'networkx >= 2.5', 'astunparse', 'sympy >= 1.9', 'pyyaml', 'ply', 'websockets', 'jinja2', 'fparser >= 0.1.3', 'aenum >= 3.1', 'dataclasses; python_version < "3.7"', 'dill', 'pyreadline;platform_system=="Windows"', 'typing-compat; python_version < "3.8"' ] + cmake_requires, From c35dc745e9b57d1430f9ced0faafaf228a6cadb7 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 4 Jul 2024 17:22:56 +0200 Subject: [PATCH 03/16] Unparsing a NumPy scalar value should now return a number instead of a call with NumPy v2.0 or higher. --- dace/frontend/python/astutils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dace/frontend/python/astutils.py b/dace/frontend/python/astutils.py index c9a400e5f1..fef4ea4c3b 100644 --- a/dace/frontend/python/astutils.py +++ b/dace/frontend/python/astutils.py @@ -230,6 +230,12 @@ def subscript_to_ast_slice_recursive(node): class ExtUnparser(astunparse.Unparser): + + def _Constant(self, t): + # NOTE: This is needed since NumPy 2.0 to avoid unparsing NumPy scalars as calls, e.g. `numpy.int32(1)` + if isinstance(t.value, numbers.Number): + self.write(str(t.value)) + def _Subscript(self, t): self.dispatch(t.value) self.write('[') From 4cd62d7f85c47482873ec3c5c364173dcf9b2ea7 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 4 Jul 2024 18:13:09 +0200 Subject: [PATCH 04/16] Call parent class method if constant isn't a number. --- dace/frontend/python/astutils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dace/frontend/python/astutils.py b/dace/frontend/python/astutils.py index fef4ea4c3b..9350ad2cdc 100644 --- a/dace/frontend/python/astutils.py +++ b/dace/frontend/python/astutils.py @@ -235,6 +235,8 @@ def _Constant(self, t): # NOTE: This is needed since NumPy 2.0 to avoid unparsing NumPy scalars as calls, e.g. `numpy.int32(1)` if isinstance(t.value, numbers.Number): self.write(str(t.value)) + else: + super()._Constant(t) def _Subscript(self, t): self.dispatch(t.value) From 7365e978563dd813bf3a1dfcd2850c6b9887827c Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 4 Jul 2024 18:13:37 +0200 Subject: [PATCH 05/16] Swapped PyFV3 repository. --- .github/workflows/pyFV3-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyFV3-ci.yml b/.github/workflows/pyFV3-ci.yml index 2b98327381..6efccaffa2 100644 --- a/.github/workflows/pyFV3-ci.yml +++ b/.github/workflows/pyFV3-ci.yml @@ -23,7 +23,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - repository: 'NOAA-GFDL/PyFV3' + repository: 'alexnick83/PyFV3' ref: 'ci/DaCe' submodules: 'recursive' path: 'pyFV3' From 605cb34d1ff6bb05a65579625badd44360ff6107 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 11 Jul 2024 12:29:02 +0200 Subject: [PATCH 06/16] Added support for NumPy v2 complex sign definition. --- dace/frontend/python/replacements.py | 2 +- dace/runtime/include/dace/math.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dace/frontend/python/replacements.py b/dace/frontend/python/replacements.py index 8c123f6bfe..fd7fcc98c9 100644 --- a/dace/frontend/python/replacements.py +++ b/dace/frontend/python/replacements.py @@ -2441,7 +2441,7 @@ def _matmult(visitor: ProgramVisitor, sdfg: SDFG, state: SDFGState, op1: str, op operator=None, inputs=["__in1"], outputs=["__out"], - code="__out = sign(__in1)", + code="__out = sign_numpy_2(__in1)" if np.lib.NumpyVersion(np.__version__) >= '2.0.0b1' else "__out = sign(__in1)", reduce=None, initial=np.sign.identity), heaviside=dict(name="_numpy_heaviside_", diff --git a/dace/runtime/include/dace/math.h b/dace/runtime/include/dace/math.h index 0a9d153767..7d01593259 100644 --- a/dace/runtime/include/dace/math.h +++ b/dace/runtime/include/dace/math.h @@ -288,6 +288,16 @@ template static DACE_CONSTEXPR DACE_HDFI std::complex sign(const std::complex& x) { return (x.real() != 0) ? std::complex(sign(x.real()), 0) : std::complex(sign(x.imag()), 0); } +// Numpy v2.0 or higher for complex inputs: sign(x) = x / abs(x) +template +static DACE_CONSTEXPR DACE_HDFI T sign_numpy_2(const T& x) { + return T( (T(0) < x) - (x < T(0)) ); + // return (x < 0) ? -1 : ( (x > 0) ? 1 : 0); +} +template +static DACE_CONSTEXPR DACE_HDFI std::complex sign_numpy_2(const std::complex& x) { + return (x.real() != 0 && x.imag() != 0) ? x / std::abs(x) : std::complex(0, 0); +} // Computes the Heaviside step function template From 6a3ef5f78d3b03c9cb94e4db52ef72d452968d42 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 11 Jul 2024 12:29:32 +0200 Subject: [PATCH 07/16] Using all instead of alltrue for NumPy v2 or higher. --- tests/numpy/unop_test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/numpy/unop_test.py b/tests/numpy/unop_test.py index 537c63cfb8..fbfcd17629 100644 --- a/tests/numpy/unop_test.py +++ b/tests/numpy/unop_test.py @@ -29,7 +29,10 @@ def test_not(): B = np.zeros((5, 5), dtype=np.int64).astype(np.bool_) regression = np.logical_not(A) nottest(A, B) - assert np.alltrue(B == regression) + if np.lib.NumpyVersion(np.__version__) >= '2.0.0b1': + assert np.all(B == regression) + else: + assert np.alltrue(B == regression) if __name__ == '__main__': From fd1e2210049db04f4a30c83a241e76436fd0397f Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Mon, 3 Feb 2025 16:29:55 +0100 Subject: [PATCH 08/16] Quit converting numerical constants to NumPy scalars when using NumPy > 2. --- dace/frontend/python/newast.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dace/frontend/python/newast.py b/dace/frontend/python/newast.py index a46376ccfc..91a9cc9d23 100644 --- a/dace/frontend/python/newast.py +++ b/dace/frontend/python/newast.py @@ -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 @@ -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) From ae5338e7c12cc795904a85ab09558a5a7c2bb73b Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Mon, 3 Feb 2025 16:30:32 +0100 Subject: [PATCH 09/16] Using np.nan instead of np.NaN --- tests/numpy/ufunc_test.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/numpy/ufunc_test.py b/tests/numpy/ufunc_test.py index e187247511..2d8d55bed0 100644 --- a/tests/numpy/ufunc_test.py +++ b/tests/numpy/ufunc_test.py @@ -978,7 +978,7 @@ def test_ufunc_isfinite_c(): @compare_numpy_output(check_dtype=True) def ufunc_isfinite_c(A: dace.complex64[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isfinite(A) args = dace.Config.get('compiler', 'cpu', 'args') @@ -997,7 +997,7 @@ def test_ufunc_isfinite_f(): @compare_numpy_output(check_dtype=True) def ufunc_isfinite_f(A: dace.float32[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isfinite(A) args = dace.Config.get('compiler', 'cpu', 'args') @@ -1017,7 +1017,7 @@ def ufunc_isfinite_f(A: dace.float32[10]): @compare_numpy_output(validation_func=lambda a: np.isfinite(a)) def test_ufunc_isfinite_u(A: dace.uint32[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isfinite(A) @@ -1026,7 +1026,7 @@ def test_ufunc_isinf_c(): @compare_numpy_output(check_dtype=True) def ufunc_isinf_c(A: dace.complex64[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isinf(A) args = dace.Config.get('compiler', 'cpu', 'args') @@ -1045,7 +1045,7 @@ def test_ufunc_isinf_f(): @compare_numpy_output(check_dtype=True) def ufunc_isinf_f(A: dace.float32[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isinf(A) args = dace.Config.get('compiler', 'cpu', 'args') @@ -1065,7 +1065,7 @@ def ufunc_isinf_f(A: dace.float32[10]): @compare_numpy_output(validation_func=lambda a: np.isinf(a)) def test_ufunc_isinf_u(A: dace.uint32[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isinf(A) @@ -1074,7 +1074,7 @@ def test_ufunc_isnan_c(): @compare_numpy_output(check_dtype=True) def ufunc_isnan_c(A: dace.complex64[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isnan(A) args = dace.Config.get('compiler', 'cpu', 'args') @@ -1093,7 +1093,7 @@ def test_ufunc_isnan_f(): @compare_numpy_output(check_dtype=True) def ufunc_isnan_f(A: dace.float32[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isnan(A) args = dace.Config.get('compiler', 'cpu', 'args') @@ -1113,7 +1113,7 @@ def ufunc_isnan_f(A: dace.float32[10]): @compare_numpy_output(validation_func=lambda a: np.isnan(a)) def test_ufunc_isnan_u(A: dace.uint32[10]): A[0] = np.inf - A[1] = np.NaN + A[1] = np.nan return np.isnan(A) From b267a5f194f4fbb675245da7ff3e6f0b6127f775 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Mon, 3 Feb 2025 16:39:13 +0100 Subject: [PATCH 10/16] Adapted `_result_type` method for NumPy 2. --- dace/frontend/python/replacements.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/dace/frontend/python/replacements.py b/dace/frontend/python/replacements.py index ac371abe2a..c8758496f5 100644 --- a/dace/frontend/python/replacements.py +++ b/dace/frontend/python/replacements.py @@ -26,6 +26,8 @@ import numpy as np import sympy as sp +numpy_version = int(np.version.version.split('.')[0]) + Size = Union[int, dace.symbolic.symbol] Shape = Sequence[Size] if TYPE_CHECKING: @@ -1680,22 +1682,28 @@ def _result_type(arguments: Sequence[Union[str, Number, symbolic.symbol, sp.Basi datatypes = [] dtypes_for_result = [] + dtypes_for_result_np2 = [] for arg in arguments: if isinstance(arg, (data.Array, data.Stream)): datatypes.append(arg.dtype) dtypes_for_result.append(arg.dtype.type) + dtypes_for_result_np2.append(arg.dtype.type) elif isinstance(arg, data.Scalar): datatypes.append(arg.dtype) dtypes_for_result.append(_representative_num(arg.dtype)) + dtypes_for_result_np2.append(arg.dtype.type) elif isinstance(arg, (Number, np.bool_)): datatypes.append(dtypes.dtype_to_typeclass(type(arg))) dtypes_for_result.append(arg) + dtypes_for_result_np2.append(arg) elif symbolic.issymbolic(arg): datatypes.append(_sym_type(arg)) dtypes_for_result.append(_representative_num(_sym_type(arg))) + dtypes_for_result_np2.append(_sym_type(arg).type) elif isinstance(arg, dtypes.typeclass): datatypes.append(arg) dtypes_for_result.append(_representative_num(arg)) + dtypes_for_result_np2.append(arg.type) else: raise TypeError("Type {t} of argument {a} is not supported".format(t=type(arg), a=arg)) @@ -1728,8 +1736,11 @@ def _result_type(arguments: Sequence[Union[str, Number, symbolic.symbol, sp.Basi elif (operator in ('Fabs', 'Cbrt', 'Angles', 'SignBit', 'Spacing', 'Modf', 'Floor', 'Ceil', 'Trunc') and coarse_types[0] == 3): raise TypeError("ufunc '{}' not supported for complex input".format(operator)) + elif operator in ('Ceil', 'Floor', 'Trunc') and coarse_types[0] < 2 and numpy_version < 2: + result_type = dace.float64 + casting[0] = _cast_str(result_type) elif (operator in ('Fabs', 'Rint', 'Exp', 'Log', 'Sqrt', 'Cbrt', 'Trigonometric', 'Angles', 'FpBoolean', - 'Spacing', 'Modf', 'Floor', 'Ceil', 'Trunc') and coarse_types[0] < 2): + 'Spacing', 'Modf') and coarse_types[0] < 2): result_type = dace.float64 casting[0] = _cast_str(result_type) elif operator in ('Frexp'): @@ -1809,7 +1820,10 @@ def _result_type(arguments: Sequence[Union[str, Number, symbolic.symbol, sp.Basi result_type = dace.float64 # All other arithmetic operators and cases of the above operators else: - result_type = _np_result_type(dtypes_for_result) + if numpy_version >= 2: + result_type = _np_result_type(dtypes_for_result_np2) + else: + result_type = _np_result_type(dtypes_for_result) if dtype1 != result_type: left_cast = _cast_str(result_type) From 4882b0405b317a1584378d5a332a016976b76ea8 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Wed, 5 Feb 2025 12:29:37 +0100 Subject: [PATCH 11/16] Added special treatment of floor, ceil, trunk for NumPy 2.0.x. --- dace/frontend/python/replacements.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dace/frontend/python/replacements.py b/dace/frontend/python/replacements.py index c8758496f5..c31c06900e 100644 --- a/dace/frontend/python/replacements.py +++ b/dace/frontend/python/replacements.py @@ -27,6 +27,7 @@ import sympy as sp numpy_version = int(np.version.version.split('.')[0]) +numpy_minor_version = int(np.version.version.split('.')[1]) Size = Union[int, dace.symbolic.symbol] Shape = Sequence[Size] @@ -1736,7 +1737,8 @@ def _result_type(arguments: Sequence[Union[str, Number, symbolic.symbol, sp.Basi elif (operator in ('Fabs', 'Cbrt', 'Angles', 'SignBit', 'Spacing', 'Modf', 'Floor', 'Ceil', 'Trunc') and coarse_types[0] == 3): raise TypeError("ufunc '{}' not supported for complex input".format(operator)) - elif operator in ('Ceil', 'Floor', 'Trunc') and coarse_types[0] < 2 and numpy_version < 2: + elif (operator in ('Ceil', 'Floor', 'Trunc') and coarse_types[0] < 2 and + not (numpy_version > 1 and numpy_minor_version > 0)): result_type = dace.float64 casting[0] = _cast_str(result_type) elif (operator in ('Fabs', 'Rint', 'Exp', 'Log', 'Sqrt', 'Cbrt', 'Trigonometric', 'Angles', 'FpBoolean', From 4fec01979259ffa199ee5e7107137e907716f1a3 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Wed, 5 Feb 2025 13:55:16 +0100 Subject: [PATCH 12/16] Use str instead of repr when unparsing numbers. --- dace/codegen/cppunparse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dace/codegen/cppunparse.py b/dace/codegen/cppunparse.py index e5e5a57f09..5b92580245 100644 --- a/dace/codegen/cppunparse.py +++ b/dace/codegen/cppunparse.py @@ -751,7 +751,7 @@ def _Repr(self, t): def _Num(self, t): t_n = t.value if sys.version_info >= (3, 8) else t.n - repr_n = repr(t_n) + repr_n = str(t_n) # For complex values, use ``dtype_to_typeclass`` if isinstance(t_n, complex): dtype = dtypes.dtype_to_typeclass(complex) From 1e8b25ac103c716164a14c775abc98740450e189 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 6 Feb 2025 15:08:13 +0100 Subject: [PATCH 13/16] Reverted repository used for pyFV3 testing. --- .github/workflows/pyFV3-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyFV3-ci.yml b/.github/workflows/pyFV3-ci.yml index bdbe32da75..2f587e9894 100644 --- a/.github/workflows/pyFV3-ci.yml +++ b/.github/workflows/pyFV3-ci.yml @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - repository: 'alexnick83/PyFV3' + repository: 'NOAA-GFDL/PyFV3' ref: 'ci/DaCe' submodules: 'recursive' path: 'pyFV3' From d5c9a673c0433c853b50f01f4f9b99f9b529e6ce Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 6 Feb 2025 15:13:44 +0100 Subject: [PATCH 14/16] Making NumPy version checking consistent. --- dace/frontend/python/newast.py | 6 +++--- dace/frontend/python/replacements.py | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dace/frontend/python/newast.py b/dace/frontend/python/newast.py index 91a9cc9d23..ef0abdd9a5 100644 --- a/dace/frontend/python/newast.py +++ b/dace/frontend/python/newast.py @@ -38,7 +38,7 @@ import numpy import sympy -numpy_version = int(numpy.version.version.split('.')[0]) +numpy_version = numpy.lib.NumpyVersion(numpy.__version__) # register replacements in oprepo import dace.frontend.python.replacements @@ -4920,9 +4920,9 @@ def visit_Num(self, node: NumConstant): return node.n def visit_Constant(self, node: ast.Constant): - if isinstance(node.value, bool) and numpy_version < 2: + if isinstance(node.value, bool) and numpy_version < '2.0.0': return dace.bool_(node.value) - if isinstance(node.value, (int, float, complex)) and numpy_version < 2: + if isinstance(node.value, (int, float, complex)) and numpy_version < '2.0.0': return dtypes.dtype_to_typeclass(type(node.value))(node.value) if isinstance(node.value, (str, bytes)): return StringLiteral(node.value) diff --git a/dace/frontend/python/replacements.py b/dace/frontend/python/replacements.py index c31c06900e..5740adceaa 100644 --- a/dace/frontend/python/replacements.py +++ b/dace/frontend/python/replacements.py @@ -26,8 +26,7 @@ import numpy as np import sympy as sp -numpy_version = int(np.version.version.split('.')[0]) -numpy_minor_version = int(np.version.version.split('.')[1]) +numpy_version = np.lib.NumpyVersion(np.__version__) Size = Union[int, dace.symbolic.symbol] Shape = Sequence[Size] @@ -1737,8 +1736,7 @@ def _result_type(arguments: Sequence[Union[str, Number, symbolic.symbol, sp.Basi elif (operator in ('Fabs', 'Cbrt', 'Angles', 'SignBit', 'Spacing', 'Modf', 'Floor', 'Ceil', 'Trunc') and coarse_types[0] == 3): raise TypeError("ufunc '{}' not supported for complex input".format(operator)) - elif (operator in ('Ceil', 'Floor', 'Trunc') and coarse_types[0] < 2 and - not (numpy_version > 1 and numpy_minor_version > 0)): + elif operator in ('Ceil', 'Floor', 'Trunc') and coarse_types[0] < 2 and numpy_version < '2.1.0': result_type = dace.float64 casting[0] = _cast_str(result_type) elif (operator in ('Fabs', 'Rint', 'Exp', 'Log', 'Sqrt', 'Cbrt', 'Trigonometric', 'Angles', 'FpBoolean', @@ -1822,7 +1820,7 @@ def _result_type(arguments: Sequence[Union[str, Number, symbolic.symbol, sp.Basi result_type = dace.float64 # All other arithmetic operators and cases of the above operators else: - if numpy_version >= 2: + if numpy_version >= '2.0.0': result_type = _np_result_type(dtypes_for_result_np2) else: result_type = _np_result_type(dtypes_for_result) From 0c462a6a098af26ac1afc96ec2445472e3518862 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 6 Feb 2025 15:15:32 +0100 Subject: [PATCH 15/16] Use cached NumPy version. --- dace/frontend/python/replacements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dace/frontend/python/replacements.py b/dace/frontend/python/replacements.py index 5740adceaa..5323641895 100644 --- a/dace/frontend/python/replacements.py +++ b/dace/frontend/python/replacements.py @@ -2715,7 +2715,7 @@ def _matmult(visitor: ProgramVisitor, sdfg: SDFG, state: SDFGState, op1: str, op operator=None, inputs=["__in1"], outputs=["__out"], - code="__out = sign_numpy_2(__in1)" if np.lib.NumpyVersion(np.__version__) >= '2.0.0b1' else "__out = sign(__in1)", + code="__out = sign_numpy_2(__in1)" if numpy_version >= '2.0.0' else "__out = sign(__in1)", reduce=None, initial=np.sign.identity), heaviside=dict(name="_numpy_heaviside_", From 6fd119badd72bff2e14b3013de09767c7ea57b8a Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Thu, 6 Feb 2025 16:04:36 +0100 Subject: [PATCH 16/16] Using version 2.0.0 for consistency. --- tests/numpy/unop_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/numpy/unop_test.py b/tests/numpy/unop_test.py index fbfcd17629..1076efbd6d 100644 --- a/tests/numpy/unop_test.py +++ b/tests/numpy/unop_test.py @@ -29,7 +29,7 @@ def test_not(): B = np.zeros((5, 5), dtype=np.int64).astype(np.bool_) regression = np.logical_not(A) nottest(A, B) - if np.lib.NumpyVersion(np.__version__) >= '2.0.0b1': + if np.lib.NumpyVersion(np.__version__) >= '2.0.0': assert np.all(B == regression) else: assert np.alltrue(B == regression)