espnet2.train.preprocessor.any_allzero
Less than 1 minute
espnet2.train.preprocessor.any_allzero
espnet2.train.preprocessor.any_allzero(signal)
Check if any of the elements in the input signal are all zeros.
This function evaluates whether any given element in a signal (which can be a single array or a list/tuple of arrays) consists entirely of zeros. It uses NumPy’s allclose function to check for numerical closeness to zero, which is particularly useful for floating-point comparisons.
- Parameters:
- signal (Union *[*np.ndarray , list , tuple ]) – The input signal, which can be
- array (a NumPy)
- list (a)
- tuple (or a tuple. Each element of the list or)
- zeros. (should be an array that is to be checked for being all)
- Returns: Returns True if any element in the input signal is all zeros; otherwise returns False.
- Return type: bool
Examples
>>> any_allzero(np.array([0.0, 0.0, 0.0]))
True
>>> any_allzero(np.array([1.0, 0.0, 0.0]))
False
>>> any_allzero([np.array([0.0, 0.0]), np.array([1.0, 2.0])])
True
>>> any_allzero([np.array([1.0, 2.0]), np.array([3.0, 4.0])])
False
>>> any_allzero((np.array([0.0, 0.0]), np.array([1.0, 2.0])))
True
NOTE
This function uses NumPy’s allclose which allows for a numerical tolerance when checking if values are close to zero.