def test_sin4(): # AD object with .val=[1,2] x1 = AD(val=[1, 2], index=0, magnitude=2) # AD object with .val=[2,3] x2 = AD(val=[2, 3], index=1, magnitude=2) y = ef.sin(x1 + x2) assert y.val == pytest.approx(np.sin([3, 5])) assert y.der[0] == pytest.approx(np.cos([3, 5]) * 1) assert y.der[1] == pytest.approx(np.cos([3, 5]) * 1)
def test_sin0(): x = 1 assert ef.sin(x) == pytest.approx(np.sin(x))
def test_sin2(): # AD object with .val=[1,2] x = AD(val=[1, 2], index=0, magnitude=1) y = ef.sin(x) assert y.val == pytest.approx(np.sin([1, 2])) assert y.der[0] == pytest.approx(np.cos([1, 2]) * 1)
def test_sin1(): # default AD object with .val=[0.0] x = AD() y = ef.sin(x) assert y.val == pytest.approx(np.sin(0)) assert y.der == pytest.approx(np.cos(0) * 1)