dpnp.clip
- dpnp.clip(a, /, min=None, max=None, *, out=None, order='K', **kwargs)[source]
Clip (limit) the values in an array.
For full documentation refer to
numpy.clip.- Parameters:
a ({dpnp.ndarray, usm_ndarray}) -- Array containing elements to clip.
min ({None, dpnp.ndarray, usm_ndarray}) --
Minimum and maximum value. If
None, clipping is not performed on the corresponding edge. If both min and max areNone, the elements of the returned array stay the same. Both are broadcast against a.Default :
None.max ({None, dpnp.ndarray, usm_ndarray}) --
Minimum and maximum value. If
None, clipping is not performed on the corresponding edge. If both min and max areNone, the elements of the returned array stay the same. Both are broadcast against a.Default :
None.out ({None, dpnp.ndarray, usm_ndarray}, optional) --
The results will be placed in this array. It may be the input array for in-place clipping. out must be of the right shape to hold the output. Its type is preserved.
Default :
None.order ({None, "C", "F", "A", "K"}, optional) --
Memory layout of the newly output array, if parameter out is
None. If order isNone, the default value"K"will be used.Default:
"K".
- Returns:
out -- An array with the elements of a, but where values < min are replaced with min, and those > max with max.
- Return type:
dpnp.ndarray
Limitations
Keyword argument kwargs is currently unsupported. Otherwise
NotImplementedErrorexception will be raised.Examples
>>> import dpnp as np >>> a = np.arange(10) >>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> np.clip(a, 1, 8) array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8]) >>> np.clip(a, 8, 1) array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) >>> np.clip(a, 3, 6, out=a) array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6]) >>> a array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
>>> a = np.arange(10) >>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> min = np.array([3, 4, 1, 1, 1, 4, 4, 4, 4, 4]) >>> np.clip(a, min, 8) array([3, 4, 2, 3, 4, 5, 6, 7, 8, 8])