def test_arcsinh_constant_results(): a = ef.arcsinh(5) assert a == np.arcsinh(5) b = ef.arcsinh(-5) assert b == np.arcsinh(-5) c = ef.arcsinh(0) assert c == np.arcsinh(0)
def test_arcsinh_ad_results(): # positive real numbers x = Dual(1, 2) f = ef.arcsinh(x) assert f.Real == np.arcsinh(1) assert f.Dual == np.array([[((2) / np.sqrt((1)**2 + 1))]]) # negative real numbers y = Dual(-1, 2) f = ef.arcsinh(y) assert f.Real == np.arcsinh(-1) assert f.Dual == np.array([[((2) / np.sqrt((-1)**2 + 1))]]) # zero z = Dual(0, 2) f = ef.arcsinh(z) assert f.Real == np.arcsinh(0) assert f.Dual == np.array([[((2) / np.sqrt((0)**2 + 1))]])
def test_arcsinh_ad_results(): # positive real numbers x = AutoDiff(1, 2) f = ef.arcsinh(x) assert f.val == np.arcsinh(1) assert f.der == np.array([[((2)/np.sqrt((1)**2 + 1))]]) assert f.jacobian == np.array([[((1)/np.sqrt((1)**2 + 1))]]) # negative real numbers y = AutoDiff(-1, 2) f = ef.arcsinh(y) assert f.val == np.arcsinh(-1) assert f.der == np.array([[((2)/np.sqrt((-1)**2 + 1))]]) assert f.jacobian == np.array([[((1)/np.sqrt((-1)**2 + 1))]]) # zero z = AutoDiff(0, 2) f = ef.arcsinh(z) assert f.val == np.arcsinh(0) assert f.der == np.array([[((2)/np.sqrt((0)**2 + 1))]]) assert f.jacobian == np.array([[((1)/np.sqrt((0)**2 + 1))]])
def test_arcsinh_types(): with pytest.raises(TypeError): ef.arcsinh('x') with pytest.raises(TypeError): ef.arcsinh("1234")