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:
x : number

A scalar value to be cast to int

cast : function [optional]

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

Returns:
x_int : int

x_int = int(cast(x))

Raises:
ParameterError

If cast is provided and is not callable.