librosa.util.valid_int

librosa.util.valid_int(x, *, cast=None)[source]

Ensure that an input value is integer-typed. This is primarily useful for ensuring integrable-valued array indices.

Parameters:
xnumber

A scalar value to be cast to int

castfunction [optional]

A function to modify x before casting. Default: np.floor

Returns:
x_intint

x_int = int(cast(x))

Raises:
ParameterError

If cast is provided and is not callable.