def test_sin(trig_cls, trig_var): f1 = AD.sin(trig_cls) f2 = AD.sin(trig_var) assert f1.func_val == np.sin(np.pi / 4) assert f1.partial_dict['x1'] == np.cos(np.pi / 4) assert f2 == np.sin(np.pi / 4)
def test_trig(ar_pi): assert [AD.sin(ar_pi)[0].func_val, np.round(AD.sin(ar_pi)[1].func_val, 7)] == [1.0, np.round(0.7071067811865476, 7)] assert np.round(AD.sin(ar_pi)[0].partial_dict['p_0'], 7) == np.round(6.123233995736766e-17, 7) assert [ np.round(AD.cos(ar_pi)[0].func_val, 7), np.round(AD.cos(ar_pi)[1].func_val, 7) ] == [np.round(6.123233995736766e-17, 7), np.round(0.7071067811865476, 7)] assert AD.cos(ar_pi)[0].partial_dict['p_0'] == -1.0 assert np.round(AD.tan(ar_pi)[1].func_val, 7) == np.round(0.9999999999999999, 7) assert np.round(AD.tan(ar_pi)[1].partial_dict['p_1'], 7) == np.round(1.9999999999999996, 7)