Caution

You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.9.1.

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.