librosa.util.localmin
- librosa.util.localmin(x, *, axis=0)[source]
Find local minima in an array
An element
x[i]
is considered a local minimum if the following conditions are met:x[i] < x[i-1]
x[i] <= x[i+1]
Note that the first condition is strict, and that the first element
x[0]
will never be considered as a local minimum.- Parameters:
- xnp.ndarray [shape=(d1,d2,…)]
input vector or array
- axisint
axis along which to compute local minimality
- Returns:
- mnp.ndarray [shape=x.shape, dtype=bool]
indicator array of local minimality along
axis
See also
Examples
>>> x = np.array([1, 0, 1, 2, -1, 0, -2, 1]) >>> librosa.util.localmin(x) array([False, True, False, False, True, False, True, False])
>>> # Two-dimensional example >>> x = np.array([[1,0,1], [2, -1, 0], [2, 1, 3]]) >>> librosa.util.localmin(x, axis=0) array([[False, False, False], [False, True, True], [False, False, False]])
>>> librosa.util.localmin(x, axis=1) array([[False, True, False], [False, True, False], [False, True, False]])