def compute_bin_indices(X_part, bin_limits=None, n_bins=20):
    if bin_limits is None:
        bin_limits = []
        for variable_data in range(X_part.shape[1]):
            bin_limits.append(numpy.linspace(numpy.min(variable_data), numpy.max(variable_data), n_bins + 1)[1: -1])

    bin_indices = numpy.zeros(len(X_part), dtype=numpy.int)
    for axis, bin_limits_axis in enumerate(bin_limits):
        bin_indices *= (len(bin_limits_axis) + 1)
        bin_indices += numpy.searchsorted(bin_limits_axis, X_part[:, axis])

    return bin_indices
linear broadening
dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/metrics_utils.py/compute_bin_indices--crossover with--dataset/ETHPy150Open xraypy/xraylarch/plugins/math/convolution1D.py/conv