Ejemplo n.º 1
0
def test_subtract_controls_01():

    time = np.linspace(0, 10, 11)

    # Define harmonic input
    t_init = 0
    T = 4.
    A = 3.
    phase = np.pi / 2
    f = 0.25

    expected_harm_input = np.zeros([11])
    expected_harm_input[0:5] += np.array([A / 2, 0, -A / 2, 0, A / 2])

    harmonic_input = Harmonic(t_init, T, A, f, phase=phase)

    # Define ramp input
    t_init = 0
    T = 4.
    A = 3.

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

    ramp_input = Ramp(t_init, T, A, offset=0)

    # Subtract both
    composed_input = ramp_input - harmonic_input
    real_input = composed_input(time)

    expected_input = expected_ramp_input - expected_harm_input

    assert_almost_equal(real_input, expected_input)
Ejemplo n.º 2
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, offset=0)
    real_input = ramp_input(time)

    assert_almost_equal(real_input, expected_input)