bin_number

ketos.audio.utils.axis.bin_number(x, pos_func, bins, truncate=False, closed_right=False)[source]

Helper function for computing the bin number corresponding to a given axis value.

If the value lies outside the axis range, a negative bin number or a bin number above N-1 will be returned. This behaviour can be changed using the argument ‘truncate’.

Args:
x: array-like

Value

pos_func: function

Calculates the position on the axis of any given input value. The position is a float ranging from 0 (lower edge of first bin) to N (upper edge of last bin) inside the axis range, and assuming negative values or values above N outside the range of the axis.

bins: int

Number of bins

truncate: bool

Return 0 if x is below the lower axis boundary and N-1 if x is above the upper boundary. Default is False.

closed_right: bool

If False, bin is closed on the left and open on the right. If True, bin is open on the left and closed on the right. Default is False. , but they do not need to get involved yet.

Bin number