def test_tanh_types(): with pytest.raises(TypeError): ef.tanh('x') with pytest.raises(TypeError): ef.tanh("1234")
def test_tanh_results(): X = AutoDiff(0.5, 2) f = ef.tanh(X) assert f.val == np.tanh(0.5) assert f.der == np.array([[2/(np.cosh(0.5)**2)]]) assert f.jacobian == np.array([[1/(np.cosh(0.5)**2)]])
def test_tanh_constant_results(): a = ef.tanh(0.5) assert a == np.tanh(0.5)
def test_tanh_results(): X = Dual(0.5, 2) f = ef.tanh(X) assert f.Real == np.tanh(0.5) assert f.Dual == np.array([[2 / (np.cosh(0.5)**2)]])