def test_digitize():
    data = np.arange(9)
    bins = [0, 5, 10]
    left = np.array([1, 1, 1, 1, 1, 2, 2, 2, 2])
    right = np.array([0, 1, 1, 1, 1, 1, 2, 2, 2])

    assert_array_equal(_digitize(data, bins), left)
    assert_array_equal(_digitize(data, bins, True), right)
    assert_raises(NotImplementedError, _digitize, data + 0.1, bins, True)
    assert_raises(NotImplementedError, _digitize, data, [0., 5, 10], True)
Test numpy.digitize() replacement
dataset/ETHPy150Open mne-tools/mne-python/mne/tests/test_fixes.py/test_digitize