Skip to content

Commit f56a43f

Browse files
authored
Resolve failures in tests while running with numpy 2.0 (#2328)
The PR proposes to resolve faults in dpnp tests when running towards numpy 2.0. The affected tests assume numpy fixes released in 2.1 version, so the tests logic has to be updated to align with expected numpy behavior depending on the version used.
1 parent 37e9176 commit f56a43f

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

dpnp/tests/test_manipulation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ def test_ndarray(self):
11051105
result = ia.reshape((2, 5))
11061106
assert_array_equal(result, expected)
11071107

1108-
@testing.with_requires("numpy>=2.0")
1108+
@testing.with_requires("numpy>=2.1")
11091109
def test_copy(self):
11101110
a = numpy.arange(10).reshape(2, 5)
11111111
ia = dpnp.array(a)

dpnp/tests/test_mathematical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2445,10 +2445,10 @@ def test_out(self, func_params, dtype):
24452445

24462446
assert result is dp_out
24472447
# numpy.ceil, numpy.floor, numpy.trunc always return float dtype for
2448-
# NumPy < 2.0.0 while output has the dtype of input for NumPy >= 2.0.0
2448+
# NumPy < 2.1.0 while output has the dtype of input for NumPy >= 2.1.0
24492449
# (dpnp follows the latter behavior except for boolean dtype where it
24502450
# returns int8)
2451-
if numpy_version() < "2.0.0" or dtype == numpy.bool:
2451+
if numpy_version() < "2.1.0" or dtype == numpy.bool:
24522452
check_type = False
24532453
else:
24542454
check_type = True

dpnp/tests/test_strides.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ def test_1arg(func, dtype, stride):
101101
result = getattr(dpnp, func)(ia)
102102
expected = getattr(numpy, func)(a)
103103

104-
# numpy.ceil, numpy.floor, numpy.trunc always return float dtype for NumPy < 2.0.0
105-
# while for NumPy >= 2.0.0, output has the dtype of input (dpnp follows this behavior)
106-
if numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0":
104+
# numpy.ceil, numpy.floor, numpy.trunc always return float dtype for
105+
# NumPy < 2.1.0 while for NumPy >= 2.1.0, output has the dtype of input
106+
# (dpnp follows this behavior)
107+
if numpy_version() < "2.1.0":
107108
check_type = False
108109
else:
109110
check_type = True

0 commit comments

Comments
 (0)