From d1b328fe4e6b5bc107bcc439002e2952dc10a53f Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Mon, 17 Nov 2025 03:01:39 -0800 Subject: [PATCH 1/6] 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/6] 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/6] 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 From b272936a3721b61ea76e3ccda5622eda2bc4ac5a Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Mon, 17 Nov 2025 04:25:56 -0800 Subject: [PATCH 4/6] Make shape parameter non-default in dpnp.reshape() --- dpnp/dpnp_iface_manipulation.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index cfd0bdca637a..7d4eddab6e44 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", *, copy=None): +def reshape(a, /, shape, order="C", *, copy=None): """ Gives a new shape to an array without changing its data. @@ -3028,8 +3028,6 @@ def reshape(a, /, shape=None, order="C", *, copy=None): an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions. - - Default: ``None``. order : {None, "C", "F", "A"}, optional Read the elements of `a` using this index order, and place the elements into the reshaped array using this index order. ``"C"`` @@ -3113,11 +3111,6 @@ def reshape(a, /, shape=None, order="C", *, copy=None): """ - if shape is None: - raise TypeError( - "reshape() missing 1 required positional argument: 'shape'" - ) - if order is None: order = "C" elif order in "aA": From 218f455c7b1b74784321e8295edcb27283dcd43e Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Mon, 17 Nov 2025 04:38:00 -0800 Subject: [PATCH 5/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bb33ea48054..da9b5e017439 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * Refactored `dpnp.fft` and `dpnp.random` submodules by removing wildcard imports and defining explicit public exports [#2649](https://github.com/IntelPython/dpnp/pull/2649) * 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 requiring an explicit `shape` argument [#2673](https://github.com/IntelPython/dpnp/pull/2673) ### Deprecated From 7350ddf695bdc0867aafaebac5f5b9d5c5963a40 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 18 Nov 2025 01:41:29 -0800 Subject: [PATCH 6/6] Clarify changelog line --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da9b5e017439..91de5ddcea56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * Refactored `dpnp.fft` and `dpnp.random` submodules by removing wildcard imports and defining explicit public exports [#2649](https://github.com/IntelPython/dpnp/pull/2649) * 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 requiring an explicit `shape` argument [#2673](https://github.com/IntelPython/dpnp/pull/2673) +* 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) ### Deprecated