Skip to content

Commit a270259

Browse files
Remove newshape parameter from dpnp.reshape() (#2670)
This PR suggests removing the `newshape` parameter which is deprecated in dpnp 0.17.0 from `dpnp.reshape()` to align with NumPy 2.4.
1 parent 0c92fce commit a270259

File tree

3 files changed

+3
-37
lines changed

3 files changed

+3
-37
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
4646

4747
* Dropped support for Python 3.9 [#2626](https://github.com/IntelPython/dpnp/pull/2626)
4848
* Removed the obsolete interface from DPNP to Numba JIT [#2647](https://github.com/IntelPython/dpnp/pull/2647)
49+
* 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)
4950

5051
### Fixed
5152

dpnp/dpnp_iface_manipulation.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3013,7 +3013,7 @@ def require(a, dtype=None, requirements=None, *, like=None):
30133013
return arr
30143014

30153015

3016-
def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):
3016+
def reshape(a, /, shape=None, order="C", *, copy=None):
30173017
"""
30183018
Gives a new shape to an array without changing its data.
30193019
@@ -3045,10 +3045,6 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):
30453045
Fortran *contiguous* in memory, C-like order otherwise.
30463046
30473047
Default: ``"C"``.
3048-
newshape : int or tuple of ints
3049-
Replaced by `shape` argument. Retained for backward compatibility.
3050-
3051-
Default: ``None``.
30523048
copy : {None, bool}, optional
30533049
If ``True``, then the array data is copied. If ``None``, a copy will
30543050
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):
31173113
31183114
"""
31193115

3120-
if newshape is None and shape is None:
3116+
if shape is None:
31213117
raise TypeError(
31223118
"reshape() missing 1 required positional argument: 'shape'"
31233119
)
31243120

3125-
if newshape is not None:
3126-
if shape is not None:
3127-
raise TypeError(
3128-
"You cannot specify 'newshape' and 'shape' arguments "
3129-
"at the same time."
3130-
)
3131-
# Deprecated in dpnp 0.17.0
3132-
warnings.warn(
3133-
"`newshape` keyword argument is deprecated, "
3134-
"use `shape=...` or pass shape positionally instead. "
3135-
"(deprecated in dpnp 0.17.0)",
3136-
DeprecationWarning,
3137-
stacklevel=2,
3138-
)
3139-
shape = newshape
3140-
31413121
if order is None:
31423122
order = "C"
31433123
elif order in "aA":

dpnp/tests/test_manipulation.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,21 +1124,6 @@ def test_copy(self):
11241124

11251125

11261126
class TestReshape:
1127-
def test_error(self):
1128-
ia = dpnp.arange(10)
1129-
assert_raises(TypeError, dpnp.reshape, ia)
1130-
assert_raises(
1131-
TypeError, dpnp.reshape, ia, shape=(2, 5), newshape=(2, 5)
1132-
)
1133-
1134-
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
1135-
def test_newshape(self):
1136-
a = numpy.arange(10)
1137-
ia = dpnp.array(a)
1138-
expected = numpy.reshape(a, (2, 5))
1139-
result = dpnp.reshape(ia, newshape=(2, 5))
1140-
assert_array_equal(result, expected)
1141-
11421127
@pytest.mark.parametrize("order", [None, "C", "F", "A"])
11431128
def test_order(self, order):
11441129
a = numpy.arange(10)

0 commit comments

Comments
 (0)