コード例 #1
0
def test_arccos():
    x = AD(0.5, 3, 'x')
    z = x.arccos()
    print('x=', x)
    print(z)
    assert z.val == [np.arccos(0.5)]
    # np.testing.assert_array_equal(z.der, np.array([-3/np.sqrt(1 - 0.5**2)]))
    assert z.der == [-3 * (1 - 0.5**2)**(-0.5)]
コード例 #2
0
def test_arccos_p1():
    x = AD(1.1, 3, 'x')
    with pytest.raises(ValueError):
        x.arccos()