示例#1
0
def test_digitize_bins_decreasing():
    x = np.sin(np.linspace(0, 10 * np.pi, 1000))
    bins = np.linspace(1, -1, 10)
    indices_np = np.digitize(x, bins)
    indices_mp = mp.digitize(x, bins)
    assert indices_np.dtype == indices_mp.dtype
    assert indices_np.ndim == indices_mp.ndim
    assert indices_np.shape == indices_mp.shape
    assert np.array_equal(indices_np, indices_mp)
示例#2
0
def test_digitize_bins_decreasing_right(right):
    x = np.array([1, 1, 2, 2, 3, 4])
    bins = np.linspace(4, 1, 4)
    indices_np = np.digitize(x, bins, right)
    indices_mp = mp.digitize(x, bins, right)
    assert indices_np.dtype == indices_mp.dtype
    assert indices_np.ndim == indices_mp.ndim
    assert indices_np.shape == indices_mp.shape
    assert np.array_equal(indices_np, indices_mp)
示例#3
0
def test_digitize_x_list():
    x = [1, 1, 2, 2, 3, 4]
    bins = np.linspace(1, 4, 4)
    indices_np = np.digitize(x, bins)
    indices_mp = mp.digitize(x, bins)
    assert indices_np.dtype == indices_mp.dtype
    assert indices_np.ndim == indices_mp.ndim
    assert indices_np.shape == indices_mp.shape
    assert np.array_equal(indices_np, indices_mp)