示例#1
0
def test_ramp_wrong_not_scalar_offset():
    t_init = 0
    T = 5.
    A = 1.5
    time = np.linspace(0, 10, 11)
    var = np.ones_like(time)
    offset = var

    with pytest.raises(TypeError) as excinfo:
        ramp(t_init, T, A, time, offset=offset)
示例#2
0
def test_ramp_wrong_not_scalar_offset():
    t_init = 0
    T = 5.
    A = 1.5
    time = np.linspace(0, 10, 11)
    var = np.ones_like(time)
    offset = var

    with pytest.raises(TypeError) as excinfo:
        ramp(t_init, T, A, time, offset=offset)
示例#3
0
def test_ramp():
    t_init = 0
    T = 4.
    A = 3.
    time = np.linspace(0, 10, 11)

    expected_input = np.zeros([11])
    expected_input[0:5] = np.array([0, A / 4, A / 2, 3 * A / 4, A])

    ramp_input = ramp(t_init, T, A, time, offset=0, var=None)

    assert_almost_equal(ramp_input, expected_input)
示例#4
0
def test_ramp():
    t_init = 0
    T = 4.
    A = 3.
    time = np.linspace(0, 10, 11)

    expected_input = np.zeros([11])
    expected_input[0:5] = np.array([0, A/4, A/2, 3*A/4, A])

    ramp_input = ramp(t_init, T, A, time, offset=0, var=None)

    assert_almost_equal(ramp_input, expected_input)
示例#5
0
def test_ramp_var():
    t_init = 0
    T = 4.
    A = 3.
    time = np.linspace(0, 10, 11)
    var = np.ones_like(time)
    var[0::2] = -1

    expected_input = var.copy()
    expected_input[0:5] += np.array([0, A / 4, A / 2, 3 * A / 4, A])

    ramp_input = ramp(t_init, T, A, time, offset=0, var=var)

    assert_almost_equal(ramp_input, expected_input)
示例#6
0
def test_ramp_var():
    t_init = 0
    T = 4.
    A = 3.
    time = np.linspace(0, 10, 11)
    var = np.ones_like(time)
    var[0::2] = -1

    expected_input = var.copy()
    expected_input[0:5] += np.array([0, A/4, A/2, 3*A/4, A])

    ramp_input = ramp(t_init, T, A, time, offset=0, var=var)

    assert_almost_equal(ramp_input, expected_input)