dpnp.trim_zeros
- dpnp.trim_zeros(filt, trim='fb')[source]
Trim the leading and/or trailing zeros from a 1-D array.
For full documentation refer to
numpy.trim_zeros
.- Parameters:
filt ({dpnp.ndarray, usm_ndarray}) -- Input 1-D array.
trim (str, optional) -- A string with 'f' representing trim from front and 'b' to trim from back. By defaults, trim zeros from both front and back of the array. Default:
"fb"
.
- Returns:
out -- The result of trimming the input.
- Return type:
dpnp.ndarray
Examples
>>> import dpnp as np >>> a = np.array((0, 0, 0, 1, 2, 3, 0, 2, 1, 0)) >>> np.trim_zeros(a) array([1, 2, 3, 0, 2, 1])
>>> np.trim_zeros(a, 'b') array([0, 0, 0, 1, 2, 3, 0, 2, 1])