dpnp.put
- dpnp.put(a, ind, v, /, *, axis=None, mode='wrap')[source]
Puts values of an array into another array along a given axis.
For full documentation refer to
numpy.put.- Parameters:
a ({dpnp.ndarray, usm_ndarray}) -- The array the values will be put into.
ind ({array_like}) -- Target indices, interpreted as integers.
v ({scalar, array_like}) -- Values to be put into a. Must be broadcastable to the result shape
a.shape[:axis] + ind.shape + a.shape[axis+1:].axis ({None, int}, optional) --
The axis along which the values will be placed. If a is 1-D array, this argument is optional.
Default:
None.mode ({'wrap', 'clip'}, optional) --
Specifies how out-of-bounds indices will behave.
'wrap': clamps indices to (
-n <= i < n), then wraps negative indices.'clip': clips indices to (
0 <= i < n).
Default:
'wrap'.
See also
dpnp.putmaskChanges elements of an array based on conditional and input values.
dpnp.placeChange elements of an array based on conditional and input values.
dpnp.put_along_axisPut values into the destination array by matching 1d index and data slices.
Notes
In contrast to
numpy.putwrap mode which wraps indices around the array for cyclic operations,dpnp.putwrap mode clamps indices to a fixed range within the array boundaries (-n <= i < n).Examples
>>> import dpnp as np >>> a = np.arange(5) >>> np.put(a, [0, 2], [-44, -55]) >>> a array([-44, 1, -55, 3, 4])
>>> a = np.arange(5) >>> np.put(a, 22, -5, mode='clip') >>> a array([ 0, 1, 2, 3, -5])