示例#1
0
def test_getbins_2():
    mx = 100
    mn = 0
    bb = cyclecount.getbins(1, mx, mn)
    assert np.allclose(bb, [mn - 0.001 * (mx - mn), mx])
    bb = cyclecount.getbins(1, mx, mn, right=False)
    assert np.allclose(bb, [mn, mx + 0.001 * (mx - mn)])
示例#2
0
def test_getbins_1():
    bb = cyclecount.getbins(4, 12, 4)
    assert np.allclose(bb, [3.992, 6.0, 8.0, 10.0, 12.0])
    bb = cyclecount.getbins(4, 4, 12)
    assert np.allclose(bb, [3.992, 6.0, 8.0, 10.0, 12.0])
    bb = cyclecount.getbins(4, 4, 12, right=False)
    assert np.allclose(bb, [4.0, 6.0, 8.0, 10.0, 12.008])
    assert_raises(ValueError, cyclecount.getbins, 4, 3.0, 3.0)
示例#3
0
def test_getbins_3():
    mx = 20.0
    mn = -5.0
    binpts = [-2.0, 4.0, 5.0, 8.0, 14.0]
    bb = cyclecount.getbins(binpts, mn, mx)
    assert np.allclose(bb, binpts)
    binpts = [0.5, 0.1, -10.0, 100]
    assert_raises(ValueError, cyclecount.getbins, binpts, mn, mx)