librosa.util.tiny¶
- librosa.util.tiny(x)[source]¶
Compute the tiny-value corresponding to an input’s data type.
This is the smallest “usable” number representable in
x.dtype
(e.g., float32).This is primarily useful for determining a threshold for numerical underflow in division or multiplication operations.
- Parameters
- xnumber or np.ndarray
The array to compute the tiny-value for. All that matters here is
x.dtype
- Returns
- tiny_valuefloat
The smallest positive usable number for the type of
x
. Ifx
is integer-typed, then the tiny value fornp.float32
is returned instead.
See also
Examples
For a standard double-precision floating point number:
>>> librosa.util.tiny(1.0) 2.2250738585072014e-308
Or explicitly as double-precision
>>> librosa.util.tiny(np.asarray(1e-5, dtype=np.float64)) 2.2250738585072014e-308
Or complex numbers
>>> librosa.util.tiny(1j) 2.2250738585072014e-308
Single-precision floating point:
>>> librosa.util.tiny(np.asarray(1e-5, dtype=np.float32)) 1.1754944e-38
Integer
>>> librosa.util.tiny(5) 1.1754944e-38