From 61505e4a9ccca483a9a68f55137b5dd50b7ed51a Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 21 Nov 2025 06:53:38 -0800 Subject: [PATCH 01/11] Disallow scalar conversion for non-0D arrays --- dpnp/dpnp_array.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 656f099a0c4..273503c22db 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -194,6 +194,7 @@ def __bytes__(self): def __complex__(self, /): """Convert a zero-dimensional array to a Python complex object.""" + self._check_scalar_convertible() return self._array_obj.__complex__() def __contains__(self, value, /): @@ -300,6 +301,7 @@ def __eq__(self, other, /): def __float__(self, /): """Convert a zero-dimensional array to a Python float object.""" + self._check_scalar_convertible() return self._array_obj.__float__() def __floordiv__(self, other, /): @@ -391,6 +393,7 @@ def __index__(self, /): def __int__(self, /): """Convert a zero-dimensional array to a Python int object.""" + self._check_scalar_convertible() return self._array_obj.__int__() def __invert__(self, /): @@ -608,6 +611,14 @@ def __xor__(self, other, /): r"""Return :math:`\text{self ^ value}`.""" return dpnp.bitwise_xor(self, other) + def _check_scalar_convertible(self): + """Raise if array cannot be converted to a Python scalar.""" + if self.ndim != 0: + raise TypeError( + "Only 0-dimensional dpnp.ndarray can be converted " + "to a Python scalar" + ) + @staticmethod def _create_from_usm_ndarray(usm_ary: dpt.usm_ndarray): """ From 320202d999d146958bf4a7cd19e4e703bc760227 Mon Sep 17 00:00:00 2001 From: "vladislav.perevezentsev" Date: Tue, 25 Nov 2025 05:30:05 -0800 Subject: [PATCH 02/11] Add TestPythonScalarConversion --- dpnp/tests/test_ndarray.py | 70 ++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/dpnp/tests/test_ndarray.py b/dpnp/tests/test_ndarray.py index c7e9dc65b99..3a03a8079f9 100644 --- a/dpnp/tests/test_ndarray.py +++ b/dpnp/tests/test_ndarray.py @@ -5,6 +5,7 @@ assert_allclose, assert_array_equal, assert_equal, + assert_raises, assert_raises_regex, ) @@ -17,6 +18,7 @@ get_complex_dtypes, get_float_dtypes, has_support_aspect64, + numpy_version, ) from .third_party.cupy import testing @@ -530,34 +532,50 @@ def test_print_dpnp_zero_shape(): assert result == expected -# Numpy will raise an error when converting a.ndim > 0 to a scalar -# TODO: Discuss dpnp behavior according to these future changes -@pytest.mark.filterwarnings("ignore::DeprecationWarning") -@pytest.mark.parametrize("func", [bool, float, int, complex]) -@pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) -@pytest.mark.parametrize( - "dtype", get_all_dtypes(no_float16=False, no_complex=True) -) -def test_scalar_type_casting(func, shape, dtype): - a = numpy.full(shape, 5, dtype=dtype) - ia = dpnp.full(shape, 5, dtype=dtype) - assert func(a) == func(ia) +class TestPythonScalarConversion: + @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) + @pytest.mark.parametrize( + "dtype", get_all_dtypes(no_float16=False, no_complex=True) + ) + def test_bool_conversion(shape, dtype): + a = numpy.full(shape, 5, dtype=dtype) + ia = dpnp.full(shape, 5, dtype=dtype) + assert bool(a) == bool(ia) + @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) + @pytest.mark.parametrize( + "dtype", get_all_dtypes(no_float16=False, no_complex=True) + ) + def test_bool_method_conversion(shape, dtype): + a = numpy.full(shape, 5, dtype=dtype) + ia = dpnp.full(shape, 5, dtype=dtype) + assert a.__bool__() == ia.__bool__() -# Numpy will raise an error when converting a.ndim > 0 to a scalar -# TODO: Discuss dpnp behavior according to these future changes -@pytest.mark.filterwarnings("ignore::DeprecationWarning") -@pytest.mark.parametrize( - "method", ["__bool__", "__float__", "__int__", "__complex__"] -) -@pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) -@pytest.mark.parametrize( - "dtype", get_all_dtypes(no_float16=False, no_complex=True) -) -def test_scalar_type_casting_by_method(method, shape, dtype): - a = numpy.full(shape, 4.7, dtype=dtype) - ia = dpnp.full(shape, 4.7, dtype=dtype) - assert_allclose(getattr(a, method)(), getattr(ia, method)(), rtol=1e-06) + @pytest.mark.parametrize("func", [float, int, complex]) + @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) + @pytest.mark.parametrize( + "dtype", get_all_dtypes(no_float16=False, no_complex=True) + ) + def test_non_bool_conversion(func, shape, dtype): + a = numpy.full(shape, 5, dtype=dtype) + ia = dpnp.full(shape, 5, dtype=dtype) + assert_raises(TypeError, func(ia)) + + if numpy_version() >= "2.4.0": + assert_raises(TypeError, func(a)) + + @pytest.mark.parametrize("method", ["__float__", "__int__", "__complex__"]) + @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) + @pytest.mark.parametrize( + "dtype", get_all_dtypes(no_float16=False, no_complex=True) + ) + def test_non_bool_method_conversion(method, shape, dtype): + a = numpy.full(shape, 5, dtype=dtype) + ia = dpnp.full(shape, 5, dtype=dtype) + assert_raises(TypeError, getattr(ia, method)()) + + if numpy_version() >= "2.4.0": + assert_raises(TypeError, getattr(a, method)()) @pytest.mark.parametrize("shape", [(1,), (1, 1), (1, 1, 1)]) From db4bd1fcc07eae1c16ecc203f18690ee230aff38 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 25 Nov 2025 08:38:56 -0600 Subject: [PATCH 03/11] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34a0610bd18..13c5b4e27dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * Added support for the `out` keyword to accept a tuple, bringing ufunc signatures into alignment with those in NumPy [#2664](https://github.com/IntelPython/dpnp/pull/2664) * Unified public API definitions in `dpnp.linalg` and `dpnp.scipy` submodules [#2663](https://github.com/IntelPython/dpnp/pull/2663) * Aligned the signature of `dpnp.reshape` function with Python array API by making `shape` a required argument [#2673](https://github.com/IntelPython/dpnp/pull/2673) +* Disallowed conversion of `dpnp.ndarray` with more than one dimension to Python scalars (`int`, `float`, `complex`) to align with NumPy 2.4.0 [#2694](https://github.com/IntelPython/dpnp/pull/2694) ### Deprecated From 11cf1513d257564c964c2878ec0050ecc5f17c15 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 16 Dec 2025 05:37:29 -0800 Subject: [PATCH 04/11] Update TestPythonScalarConversion --- dpnp/tests/test_ndarray.py | 60 +++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/dpnp/tests/test_ndarray.py b/dpnp/tests/test_ndarray.py index 3a03a8079f9..030e35c88ea 100644 --- a/dpnp/tests/test_ndarray.py +++ b/dpnp/tests/test_ndarray.py @@ -532,50 +532,56 @@ def test_print_dpnp_zero_shape(): assert result == expected +@pytest.mark.parametrize("xp", [dpnp, numpy]) class TestPythonScalarConversion: @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize( - "dtype", get_all_dtypes(no_float16=False, no_complex=True) + "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) - def test_bool_conversion(shape, dtype): - a = numpy.full(shape, 5, dtype=dtype) - ia = dpnp.full(shape, 5, dtype=dtype) - assert bool(a) == bool(ia) + def test_bool_conversion(self, xp, shape, dtype): + a = xp.full(shape, 5, dtype=dtype) + assert bool(a) == True @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize( - "dtype", get_all_dtypes(no_float16=False, no_complex=True) + "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) - def test_bool_method_conversion(shape, dtype): - a = numpy.full(shape, 5, dtype=dtype) - ia = dpnp.full(shape, 5, dtype=dtype) - assert a.__bool__() == ia.__bool__() + def test_bool_method_conversion(self, xp, shape, dtype): + a = xp.full(shape, 5, dtype=dtype) + assert a.__bool__() == True + @testing.with_requires("numpy>=2.4") @pytest.mark.parametrize("func", [float, int, complex]) @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize( - "dtype", get_all_dtypes(no_float16=False, no_complex=True) + "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) - def test_non_bool_conversion(func, shape, dtype): - a = numpy.full(shape, 5, dtype=dtype) - ia = dpnp.full(shape, 5, dtype=dtype) - assert_raises(TypeError, func(ia)) - - if numpy_version() >= "2.4.0": - assert_raises(TypeError, func(a)) - + def test_non_bool_conversion(self, xp, func, shape, dtype): + a = xp.full(shape, 5, dtype=dtype) + if len(shape) > 0: + # Non-0D arrays must not be convertible to Python numeric scalars + assert_raises(TypeError, func, a) + else: + # 0D arrays are allowed to convert + expected = 1 if xp.issubdtype(dtype, xp.bool) else 5 + assert func(a) == func(expected) + + @testing.with_requires("numpy>=2.4") @pytest.mark.parametrize("method", ["__float__", "__int__", "__complex__"]) @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize( - "dtype", get_all_dtypes(no_float16=False, no_complex=True) + "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) - def test_non_bool_method_conversion(method, shape, dtype): - a = numpy.full(shape, 5, dtype=dtype) - ia = dpnp.full(shape, 5, dtype=dtype) - assert_raises(TypeError, getattr(ia, method)()) - - if numpy_version() >= "2.4.0": - assert_raises(TypeError, getattr(a, method)()) + def test_non_bool_method_conversion(self, xp, method, shape, dtype): + a = xp.full(shape, 5, dtype=dtype) + if len(shape) > 0: + assert_raises(TypeError, getattr(a, method)) + else: + expected = 1 if xp.issubdtype(dtype, xp.bool) else 5 + func = {"__float__": float, "__int__": int, "__complex__": complex}[ + method + ] + assert getattr(a, method)() == func(expected) @pytest.mark.parametrize("shape", [(1,), (1, 1), (1, 1, 1)]) From 7e07ffe47812ca3a352d660722698352dc356385 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 16 Dec 2025 06:26:15 -0800 Subject: [PATCH 05/11] Apply remarks --- dpnp/tests/test_ndarray.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dpnp/tests/test_ndarray.py b/dpnp/tests/test_ndarray.py index 030e35c88ea..6721f0f7a8d 100644 --- a/dpnp/tests/test_ndarray.py +++ b/dpnp/tests/test_ndarray.py @@ -533,8 +533,8 @@ def test_print_dpnp_zero_shape(): @pytest.mark.parametrize("xp", [dpnp, numpy]) +@pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) class TestPythonScalarConversion: - @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize( "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) @@ -542,7 +542,6 @@ def test_bool_conversion(self, xp, shape, dtype): a = xp.full(shape, 5, dtype=dtype) assert bool(a) == True - @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize( "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) @@ -552,7 +551,6 @@ def test_bool_method_conversion(self, xp, shape, dtype): @testing.with_requires("numpy>=2.4") @pytest.mark.parametrize("func", [float, int, complex]) - @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize( "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) @@ -563,12 +561,11 @@ def test_non_bool_conversion(self, xp, func, shape, dtype): assert_raises(TypeError, func, a) else: # 0D arrays are allowed to convert - expected = 1 if xp.issubdtype(dtype, xp.bool) else 5 + expected = 1 if dtype == xp.bool else 5 assert func(a) == func(expected) @testing.with_requires("numpy>=2.4") @pytest.mark.parametrize("method", ["__float__", "__int__", "__complex__"]) - @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize( "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) @@ -577,7 +574,7 @@ def test_non_bool_method_conversion(self, xp, method, shape, dtype): if len(shape) > 0: assert_raises(TypeError, getattr(a, method)) else: - expected = 1 if xp.issubdtype(dtype, xp.bool) else 5 + expected = 1 if dtype == xp.bool else 5 func = {"__float__": float, "__int__": int, "__complex__": complex}[ method ] From da359b3777d829512fd7be59d16b3be55eef66c7 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 13 Jan 2026 04:11:12 -0800 Subject: [PATCH 06/11] Remove _check_scalar_convertible() --- dpnp/dpnp_array.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 0f11a84b6c6..3148e7757f6 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -196,7 +196,6 @@ def __bytes__(self): def __complex__(self, /): """Convert a zero-dimensional array to a Python complex object.""" - self._check_scalar_convertible() return self._array_obj.__complex__() def __contains__(self, value, /): @@ -303,7 +302,6 @@ def __eq__(self, other, /): def __float__(self, /): """Convert a zero-dimensional array to a Python float object.""" - self._check_scalar_convertible() return self._array_obj.__float__() def __floordiv__(self, other, /): @@ -395,7 +393,6 @@ def __index__(self, /): def __int__(self, /): """Convert a zero-dimensional array to a Python int object.""" - self._check_scalar_convertible() return self._array_obj.__int__() def __invert__(self, /): @@ -613,14 +610,6 @@ def __xor__(self, other, /): r"""Return :math:`\text{self ^ value}`.""" return dpnp.bitwise_xor(self, other) - def _check_scalar_convertible(self): - """Raise if array cannot be converted to a Python scalar.""" - if self.ndim != 0: - raise TypeError( - "Only 0-dimensional dpnp.ndarray can be converted " - "to a Python scalar" - ) - @staticmethod def _create_from_usm_ndarray(usm_ary: dpt.usm_ndarray): """ From 4c29893ae8925c9c3c19240e033aff802990aa46 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 13 Jan 2026 04:12:07 -0800 Subject: [PATCH 07/11] Update TestPythonScalarConversion --- dpnp/tests/test_ndarray.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/dpnp/tests/test_ndarray.py b/dpnp/tests/test_ndarray.py index 6721f0f7a8d..97062ffb2dc 100644 --- a/dpnp/tests/test_ndarray.py +++ b/dpnp/tests/test_ndarray.py @@ -532,6 +532,7 @@ def test_print_dpnp_zero_shape(): assert result == expected +@testing.with_requires("numpy>=2.4") @pytest.mark.parametrize("xp", [dpnp, numpy]) @pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) class TestPythonScalarConversion: @@ -540,16 +541,26 @@ class TestPythonScalarConversion: ) def test_bool_conversion(self, xp, shape, dtype): a = xp.full(shape, 5, dtype=dtype) - assert bool(a) == True + if xp == dpnp and len(shape) > 0: + # dpnp behavior differs from NumPy: + # non-0D singe-element arrays are not convertible to + # Python bool + assert_raises(TypeError, bool, a) + else: + # NumPy allows conversion to Python bool for + # non-0D singe-element arrays + assert bool(a) is True @pytest.mark.parametrize( "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) ) def test_bool_method_conversion(self, xp, shape, dtype): a = xp.full(shape, 5, dtype=dtype) - assert a.__bool__() == True + if xp == dpnp and len(shape) > 0: + assert_raises(TypeError, getattr(a, "__bool__")) + else: + assert a.__bool__() is True - @testing.with_requires("numpy>=2.4") @pytest.mark.parametrize("func", [float, int, complex]) @pytest.mark.parametrize( "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) @@ -557,14 +568,15 @@ def test_bool_method_conversion(self, xp, shape, dtype): def test_non_bool_conversion(self, xp, func, shape, dtype): a = xp.full(shape, 5, dtype=dtype) if len(shape) > 0: - # Non-0D arrays must not be convertible to Python numeric scalars + # Non-0D arrays are not allowed to be converted to + # Python numeric scalars assert_raises(TypeError, func, a) else: - # 0D arrays are allowed to convert + # 0D arrays are allowed to be converted to + # Python numeric scalars expected = 1 if dtype == xp.bool else 5 assert func(a) == func(expected) - @testing.with_requires("numpy>=2.4") @pytest.mark.parametrize("method", ["__float__", "__int__", "__complex__"]) @pytest.mark.parametrize( "dtype", get_all_dtypes(no_none=True, no_float16=False, no_complex=True) From 7fb2c243ed01da2361510e4c0036ab1e2b88b4e5 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 13 Jan 2026 04:33:15 -0800 Subject: [PATCH 08/11] Update tests for new scalar conversion rules --- dpnp/tests/test_indexing.py | 14 ++++++++++---- dpnp/tests/test_ndarray.py | 7 +++---- .../cupy/core_tests/test_ndarray_unary_op.py | 12 ++++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/dpnp/tests/test_indexing.py b/dpnp/tests/test_indexing.py index 07b5488f09e..9a55efe138b 100644 --- a/dpnp/tests/test_indexing.py +++ b/dpnp/tests/test_indexing.py @@ -766,12 +766,18 @@ def test_axis_as_array(self): a = numpy.array([[[1]]]) ia = dpnp.array(a) - result = ia.take([0], axis=ia) - expected = a.take( - [0], axis=1 - ) # numpy raises an error for axis as array + # axis is a 0-D integer array + axis_0d = numpy.array(1) + iaxis_0d = dpnp.array(1) + + result = ia.take([0], axis=iaxis_0d) + expected = a.take([0], axis=axis_0d) assert_array_equal(result, expected) + # axis is not a 0-D integer array + assert_raises(TypeError, ia.take, [0], axis=ia) + assert_raises(TypeError, a.take, [0], axis=a) + def test_mode_raise(self): a = dpnp.array([[1, 2], [3, 4]]) assert_raises(ValueError, a.take, [-1, 4], mode="raise") diff --git a/dpnp/tests/test_ndarray.py b/dpnp/tests/test_ndarray.py index 97062ffb2dc..99cc02d589d 100644 --- a/dpnp/tests/test_ndarray.py +++ b/dpnp/tests/test_ndarray.py @@ -593,11 +593,10 @@ def test_non_bool_method_conversion(self, xp, method, shape, dtype): assert getattr(a, method)() == func(expected) -@pytest.mark.parametrize("shape", [(1,), (1, 1), (1, 1, 1)]) @pytest.mark.parametrize("index_dtype", [dpnp.int32, dpnp.int64]) -def test_array_as_index(shape, index_dtype): - ind_arr = dpnp.ones(shape, dtype=index_dtype) - a = numpy.arange(ind_arr.size + 1) +def test_array_as_index(index_dtype): + ind_arr = dpnp.ones((1,), dtype=index_dtype) + a = dpnp.arange(ind_arr.size + 1) assert a[tuple(ind_arr)] == a[1] diff --git a/dpnp/tests/third_party/cupy/core_tests/test_ndarray_unary_op.py b/dpnp/tests/third_party/cupy/core_tests/test_ndarray_unary_op.py index 3a1e30fc894..651cad1454a 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_ndarray_unary_op.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_ndarray_unary_op.py @@ -25,13 +25,17 @@ def test_bool_scalar(self, dtype): assert not bool(cupy.array(0, dtype=dtype)) def test_bool_one_element_bool(self): - assert bool(cupy.array([True], dtype=numpy.bool_)) - assert not bool(cupy.array([False], dtype=numpy.bool_)) + # Different behavior from CuPy: + # CuPy as NumPy allows conversion to Python bool for + # non-0D singe-element arrays + with self.assertRaises(TypeError): + bool(cupy.array([True], dtype=numpy.bool_)) @testing.for_all_dtypes() def test_bool_one_element(self, dtype): - assert bool(cupy.array([1], dtype=dtype)) - assert not bool(cupy.array([0], dtype=dtype)) + # Different behavior from CuPy + with self.assertRaises(TypeError): + bool(cupy.array([1], dtype=dtype)) @testing.for_all_dtypes() def test_bool_two_elements(self, dtype): From 1f813560187f508e84d0a733333ff0e57be4e13c Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 13 Jan 2026 06:25:12 -0800 Subject: [PATCH 09/11] Update changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39ddd9bfd55..63124bb3542 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,8 +37,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * Added support for the `out` keyword to accept a tuple, bringing ufunc signatures into alignment with those in NumPy [#2664](https://github.com/IntelPython/dpnp/pull/2664) * Unified public API definitions in `dpnp.linalg` and `dpnp.scipy` submodules [#2663](https://github.com/IntelPython/dpnp/pull/2663) * Aligned the signature of `dpnp.reshape` function with Python array API by making `shape` a required argument [#2673](https://github.com/IntelPython/dpnp/pull/2673) -* Disallowed conversion of `dpnp.ndarray` with more than one dimension to Python scalars (`int`, `float`, `complex`) to align with NumPy 2.4.0 [#2694](https://github.com/IntelPython/dpnp/pull/2694) - +* Updated tests to reflect the new scalar conversion rules for non-0D `usm_ndarray` [#2694](https://github.com/IntelPython/dpnp/pull/2694) ### Deprecated * `dpnp.asfarray` is deprecated. Use `dpnp.asarray` with an appropriate dtype instead [#2650](https://github.com/IntelPython/dpnp/pull/2650) From 598a86f5b4ddeb9666a6a60585990470ac2969ee Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 13 Jan 2026 08:40:22 -0800 Subject: [PATCH 10/11] Update TestSpecial for new scalar conversion rules --- .../cupyx/scipy_tests/special_tests/test_erf.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dpnp/tests/third_party/cupyx/scipy_tests/special_tests/test_erf.py b/dpnp/tests/third_party/cupyx/scipy_tests/special_tests/test_erf.py index 1bdee3dbe54..224a0fd0eb6 100644 --- a/dpnp/tests/third_party/cupyx/scipy_tests/special_tests/test_erf.py +++ b/dpnp/tests/third_party/cupyx/scipy_tests/special_tests/test_erf.py @@ -80,10 +80,10 @@ def test_erfinv_behavior(self, dtype): a[:] = 1.0 + 1e-6 a = cupy.scipy.special.erfinv(a) - assert cupy.isnan(a) + assert cupy.isnan(a).item() a[:] = -1.0 - 1e-6 a = cupy.scipy.special.erfinv(a) - assert cupy.isnan(a) + assert cupy.isnan(a).item() a[:] = 1.0 a = cupy.scipy.special.erfinv(a) assert numpy.isposinf(cupy.asnumpy(a)) @@ -98,10 +98,10 @@ def test_erfcinv_behavior(self, dtype): a[:] = 2.0 + 1e-6 a = cupy.scipy.special.erfcinv(a) - assert cupy.isnan(a) + assert cupy.isnan(a).item() a[:] = 0.0 - 1e-6 a = cupy.scipy.special.erfcinv(a) - assert cupy.isnan(a) + assert cupy.isnan(a).item() a[:] = 0.0 a = cupy.scipy.special.erfcinv(a) assert numpy.isposinf(cupy.asnumpy(a)) From c9b460e3ad63e06b850069c144ef7ecf5e5ef055 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 14 Jan 2026 02:26:12 -0800 Subject: [PATCH 11/11] Apply remark --- dpnp/tests/test_ndarray.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dpnp/tests/test_ndarray.py b/dpnp/tests/test_ndarray.py index 99cc02d589d..c58c26fdf97 100644 --- a/dpnp/tests/test_ndarray.py +++ b/dpnp/tests/test_ndarray.py @@ -18,7 +18,6 @@ get_complex_dtypes, get_float_dtypes, has_support_aspect64, - numpy_version, ) from .third_party.cupy import testing