def val_to_bin_bounded(edges, x):
    """Convert axis coordinate to bin index."""
    nbins = len(edges) - 1
    ibin = val_to_bin(edges, x)
    ibin[ibin < 0] = 0
    ibin[ibin > nbins - 1] = nbins - 1
    return ibin
def val_to_bin_bounded ( edges , x ) : nbins = len ( edges ) - 1 ibin = val_to_bin ( edges , x ) ibin [ ibin < 0 ] = 0 ibin [ ibin > nbins - 1 ] = nbins - 1 return ibin
Convert axis coordinate to bin index.