diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fba11c9b71..96d007e325c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This release is compatible with NumPy 2.4.5. * Reimplemented `dpnp.eye` and `dpnp.tensor.eye` with a branchless kernel [gh-2937](https://github.com/IntelPython/dpnp/pull/2937) * Cleaned up Python bindings for indexing functions, renaming `usm_ndarray_take` and `usm_ndarray_put` to `py_take` and `py_put` and refactoring validation [gh-2935](https://github.com/IntelPython/dpnp/pull/2935) * Fixed some tests which expected lists from `dpctl` functions which now return tuples (i.e., `dpctl.SyclDevice.create_sub_devices`) [gh-2945](https://github.com/IntelPython/dpnp/pull/2945) +* Clarified support for negative axes in `dpnp.transpose`/`dpnp.permute_dims` documentation [#2940](https://github.com/IntelPython/dpnp/pull/2940) ### Deprecated diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 899379e837e..00401c6c790 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -2384,6 +2384,7 @@ def transpose(self, *axes): * ``tuple or list of ints``: `i` in the `j`-th place in the tuple/list means that the array’s `i`-th axis becomes the transposed array’s `j`-th axis. + Negative indices can also be used to specify axes. * ``n ints``: same as an n-tuple/n-list of the same integers (this form is intended simply as a “convenience” alternative to the tuple form). diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index b96d36a40e6..14a190993ed 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -3908,6 +3908,7 @@ def transpose(a, axes=None): axes : {None, tuple or list of ints}, optional If specified, it must be a tuple or list which contains a permutation of [0, 1, ..., N-1] where N is the number of axes of `a`. + Negative indices can also be used to specify axes. The `i`'th axis of the returned array will correspond to the axis numbered ``axes[i]`` of the input. If not specified or ``None``, defaults to ``range(a.ndim)[::-1]``, which reverses the order of @@ -3951,6 +3952,10 @@ def transpose(a, axes=None): >>> np.transpose(a).shape (5, 4, 3, 2) + >>> a = np.arange(3*4*5).reshape((3, 4, 5)) + >>> np.transpose(a, (-1, 0, -2)).shape + (5, 3, 4) + """ dpnp.check_supported_arrays_type(a)