def val_to_edge(edges, x):
    """Convert axis coordinate to bin index."""
    edges = np.array(edges)
    w = edges[1:] - edges[:-1]
    w = np.insert(w, 0, w[0])
    ibin = np.digitize(np.array(x, ndmin=1), edges - 0.5 * w) - 1
    ibin[ibin < 0] = 0
    return ibin
def val_to_edge ( edges , x ) : edges = np . array ( edges ) w = edges [ 1 : ] - edges [ : - 1 ] w = np . insert ( w , 0 , w [ 0 ] ) ibin = np . digitize ( np . array ( x , ndmin = 1 ) , edges - 0.5 * w ) - 1 ibin [ ibin < 0 ] = 0 return ibin
Convert axis coordinate to bin index.