You are viewing an older version (2.4.3).Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / lib / _function_base_impl / _arg_trim_zeros

function

numpy.lib._function_base_impl:_arg_trim_zeros

source: /numpy/lib/_function_base_impl.py:1897

Signature

def _arg_trim_zeros(filt)

Summary

Return indices of the first and last non-zero element.

Parameters

filt : array_like

Input array.

Returns

start, stop : ndarray

Two arrays containing the indices of the first and last non-zero element in each dimension.

Examples

import numpy as np
_arg_trim_zeros(np.array([0, 0, 1, 1, 0]))
✓
(array([2]), array([3]))

See also

trim_zeros

Aliases

  • numpy.lib._function_base_impl._arg_trim_zeros