From d1b328fe4e6b5bc107bcc439002e2952dc10a53f Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Mon, 17 Nov 2025 03:01:39 -0800 Subject: [PATCH 1/3] Remove the newshape parameter from dpnp.reshape --- dpnp/dpnp_iface_manipulation.py | 24 ++---------------------- dpnp/tests/test_manipulation.py | 15 --------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index d56c8ebbf5ec..cfd0bdca637a 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -3013,7 +3013,7 @@ def require(a, dtype=None, requirements=None, *, like=None): return arr -def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None): +def reshape(a, /, shape=None, order="C", *, copy=None): """ Gives a new shape to an array without changing its data. @@ -3045,10 +3045,6 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None): Fortran *contiguous* in memory, C-like order otherwise. Default: ``"C"``. - newshape : int or tuple of ints - Replaced by `shape` argument. Retained for backward compatibility. - - Default: ``None``. copy : {None, bool}, optional If ``True``, then the array data is copied. If ``None``, a copy will only be made if it's required by ``order``. For ``False`` it raises @@ -3117,27 +3113,11 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None): """ - if newshape is None and shape is None: + if shape is None: raise TypeError( "reshape() missing 1 required positional argument: 'shape'" ) - if newshape is not None: - if shape is not None: - raise TypeError( - "You cannot specify 'newshape' and 'shape' arguments " - "at the same time." - ) - # Deprecated in dpnp 0.17.0 - warnings.warn( - "`newshape` keyword argument is deprecated, " - "use `shape=...` or pass shape positionally instead. " - "(deprecated in dpnp 0.17.0)", - DeprecationWarning, - stacklevel=2, - ) - shape = newshape - if order is None: order = "C" elif order in "aA": diff --git a/dpnp/tests/test_manipulation.py b/dpnp/tests/test_manipulation.py index 25ac9445aaf9..373817466f5b 100644 --- a/dpnp/tests/test_manipulation.py +++ b/dpnp/tests/test_manipulation.py @@ -1124,21 +1124,6 @@ def test_copy(self): class TestReshape: - def test_error(self): - ia = dpnp.arange(10) - assert_raises(TypeError, dpnp.reshape, ia) - assert_raises( - TypeError, dpnp.reshape, ia, shape=(2, 5), newshape=(2, 5) - ) - - @pytest.mark.filterwarnings("ignore::DeprecationWarning") - def test_newshape(self): - a = numpy.arange(10) - ia = dpnp.array(a) - expected = numpy.reshape(a, (2, 5)) - result = dpnp.reshape(ia, newshape=(2, 5)) - assert_array_equal(result, expected) - @pytest.mark.parametrize("order", [None, "C", "F", "A"]) def test_order(self, order): a = numpy.arange(10) From 06e77d59c903c37e7bd7708ca70f58fd780f90fc Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Mon, 17 Nov 2025 03:02:03 -0800 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cf88d9266d2..e79d1867f79f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * Dropped support for Python 3.9 [#2626](https://github.com/IntelPython/dpnp/pull/2626) * Removed the obsolete interface from DPNP to Numba JIT [#2647](https://github.com/IntelPython/dpnp/pull/2647) +* Removed the `newshape` parameter from `dpnp.reshape` [#2670](https://github.com/IntelPython/dpnp/pull/2670) ### Fixed From 5240ea6438a17ab46cc978c68278078961441fb9 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Mon, 17 Nov 2025 04:02:11 -0800 Subject: [PATCH 3/3] Apply remark --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e79d1867f79f..2bb33ea48054 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,7 +46,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * Dropped support for Python 3.9 [#2626](https://github.com/IntelPython/dpnp/pull/2626) * Removed the obsolete interface from DPNP to Numba JIT [#2647](https://github.com/IntelPython/dpnp/pull/2647) -* Removed the `newshape` parameter from `dpnp.reshape` [#2670](https://github.com/IntelPython/dpnp/pull/2670) +* Removed the `newshape` parameter from `dpnp.reshape`, which has been deprecated since dpnp 0.17.0. Pass it positionally or use `shape=` on newer versions [#2670](https://github.com/IntelPython/dpnp/pull/2670) ### Fixed