Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions dpnp/dpnp_iface_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,15 +1471,17 @@ def ravel_multi_index(multi_index, dims, mode="raise", order="C"):
multi_index : tuple of {dpnp.ndarray, usm_ndarray}
A tuple of integer arrays, one array for each dimension.
dims : tuple or list of ints
The shape of array into which the indices from ``multi_index`` apply.
The shape of array into which the indices from `multi_index` apply.
mode : {"raise", "wrap" or "clip'}, optional
Specifies how out-of-bounds indices are handled. Can specify either
one mode or a tuple of modes, one mode per index:
- "raise" -- raise an error
- "wrap" -- wrap around
- "clip" -- clip to the range
In "clip" mode, a negative index which would normally wrap will
clip to 0 instead.

- "raise" -- raise an error
- "wrap" -- wrap around
- "clip" -- clip to the range

In ``"clip"`` mode, a negative index which would normally wrap will
clip to 0 instead.
Default: ``"raise"``.
order : {None, "C", "F"}, optional
Determines whether the multi-index should be viewed as indexing in
Expand All @@ -1490,7 +1492,7 @@ def ravel_multi_index(multi_index, dims, mode="raise", order="C"):
-------
raveled_indices : dpnp.ndarray
An array of indices into the flattened version of an array of
dimensions ``dims``.
dimensions `dims`.

See Also
--------
Expand All @@ -1509,6 +1511,7 @@ def ravel_multi_index(multi_index, dims, mode="raise", order="C"):
array([22, 23, 19])
>>> np.ravel_multi_index(arr, (4, 4), mode=("clip", "wrap"))
array([12, 13, 13])

>>> arr = np.array([3, 1, 4, 1])
>>> np.ravel_multi_index(arr, (6, 7, 8, 9))
array(1621)
Expand Down Expand Up @@ -2316,17 +2319,18 @@ def triu_indices_from(arr, k=0):


def unravel_index(indices, shape, order="C"):
"""Converts array of flat indices into a tuple of coordinate arrays.
"""
Converts array of flat indices into a tuple of coordinate arrays.

For full documentation refer to :obj:`numpy.unravel_index`.

Parameters
----------
indices : {dpnp.ndarray, usm_ndarray}
An integer array whose elements are indices into the flattened version
of an array of dimensions ``shape``.
of an array of dimensions `shape`.
shape : tuple or list of ints
The shape of the array to use for unraveling ``indices``.
The shape of the array to use for unraveling `indices`.
order : {None, "C", "F"}, optional
Determines whether the indices should be viewed as indexing in
row-major (C-style) or column-major (Fortran-style) order.
Expand All @@ -2342,10 +2346,9 @@ def unravel_index(indices, shape, order="C"):
:obj:`dpnp.ravel_multi_index` : Converts a tuple of index arrays into an
array of flat indices.


Examples
--------
import dpnp as np
>>> import dpnp as np
>>> np.unravel_index(np.array([22, 41, 37]), (7, 6))
(array([3, 6, 6]), array([4, 5, 1]))
>>> np.unravel_index(np.array([31, 41, 13]), (7, 6), order="F")
Expand Down
Loading