Skip to content
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 making `shape` a required argument [#2673](https://github.com/IntelPython/dpnp/pull/2673)

### Deprecated

Expand All @@ -46,6 +47,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`, 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

Expand Down
29 changes: 1 addition & 28 deletions dpnp/dpnp_iface_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, order="C", *, copy=None):
"""
Gives a new shape to an array without changing its data.

Expand All @@ -3028,8 +3028,6 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, 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"``
Expand All @@ -3045,10 +3043,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
Expand Down Expand Up @@ -3117,27 +3111,6 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):

"""

if newshape is None and 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":
Expand Down
15 changes: 0 additions & 15 deletions dpnp/tests/test_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading