dpnp.place
- dpnp.place(a, mask, vals)[source]
Change elements of an array based on conditional and input values.
Similar to
dpnp.copyto(a, vals, where=mask), the difference is thatdpnp.placeuses the first N elements of vals, where N is the number ofTruevalues in mask, whiledpnp.copytouses the elements where mask isTrue.Note that
dpnp.extractdoes the exact opposite ofdpnp.place.For full documentation refer to
numpy.place.- Parameters:
a ({dpnp.ndarray, usm_ndarray}) -- Array to put data into.
mask ({array_like, scalar}) -- Boolean mask array. Must have the same size as a.
vals ({array_like, scalar}) -- Values to put into a. Only the first N elements are used, where N is the number of
Truevalues in mask. If vals is smaller than N, it will be repeated, and if elements of a are to be masked, this sequence must be non-empty.
See also
dpnp.copytoCopies values from one array to another.
dpnp.putReplaces specified elements of an array with given values.
dpnp.takeTake elements from an array along an axis.
dpnp.extractReturn the elements of an array that satisfy some condition.
Examples
>>> import dpnp as np >>> a = np.arange(6).reshape(2, 3) >>> np.place(a, a > 2, [44, 55]) >>> a array([[ 0, 1, 2], [44, 55, 44]])