def test_sinusoid_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: sinusoid(t_init, T, A, time, offset=offset)
def test_sinusoid_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: sinusoid(t_init, T, A, time, offset=offset)
def test_sinusoid_wrong_size_var(): t_init = 0 T = 5. A = 1.5 time = np.linspace(0, 10, 11) var = np.ones([10]) with pytest.raises(ValueError) as excinfo: sinusoid(t_init, T, A, time, offset=0, var=var) assert ("ValueError: var and time must have the same size" in excinfo.exconly())
def test_sinusoid_wrong_size_var(): t_init = 0 T = 5. A = 1.5 time = np.linspace(0, 10, 11) var = np.ones([10]) with pytest.raises(ValueError) as excinfo: sinusoid(t_init, T, A, time, offset=0, var=var) assert ("ValueError: var and time must have the same size" in excinfo.exconly())
def test_sinusoid(): 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 / 2, 0, -A / 2, 0]) sinusoid_input = sinusoid(t_init, T, A, time) assert_almost_equal(sinusoid_input, expected_input)
def test_sinusoid(): 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/2, 0, -A/2, 0]) sinusoid_input = sinusoid(t_init, T, A, time) assert_almost_equal(sinusoid_input, expected_input)
def test_sinusoid_phase(): t_init = 0 T = 4. A = 3. time = np.linspace(0, 10, 11) phase = np.pi / 2 expected_input = np.zeros([11]) expected_input[0:5] += np.array([A / 2, 0, -A / 2, 0, A / 2]) sinusoid_input = sinusoid(t_init, T, A, time, phase=phase) assert_almost_equal(sinusoid_input, expected_input)
def test_sinusoid_offset(): t_init = 0 T = 4. A = 3. time = np.linspace(0, 10, 11) offset = 1 expected_input = np.zeros([11]) + offset expected_input[0:5] += np.array([0, A / 2, 0, -A / 2, 0]) sinusoid_input = sinusoid(t_init, T, A, time, offset=offset) assert_almost_equal(sinusoid_input, expected_input)
def test_sinusoid_phase(): t_init = 0 T = 4. A = 3. time = np.linspace(0, 10, 11) phase= np.pi/2 expected_input = np.zeros([11]) expected_input[0:5] += np.array([A/2, 0, -A/2, 0, A/2]) sinusoid_input = sinusoid(t_init, T, A, time, phase=phase) assert_almost_equal(sinusoid_input, expected_input)
def test_sinusoid_offset(): t_init = 0 T = 4. A = 3. time = np.linspace(0, 10, 11) offset = 1 expected_input = np.zeros([11]) + offset expected_input[0:5] += np.array([0, A/2, 0, -A/2, 0]) sinusoid_input = sinusoid(t_init, T, A, time, offset=offset) assert_almost_equal(sinusoid_input, expected_input)
def test_sinusoid_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 / 2, 0, -A / 2, 0]) sinusoid_input = sinusoid(t_init, T, A, time, offset=0, var=var) assert_almost_equal(sinusoid_input, expected_input)
def test_sinusoid_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/2, 0, -A/2, 0]) sinusoid_input = sinusoid(t_init, T, A, time, offset=0, var=var) assert_almost_equal(sinusoid_input, expected_input)