コード例 #1
0
def test_CMfunc_constant():
    assert CMfunc.sin(2) == np.sin(2)
    assert CMfunc.cos(5) == np.cos(5)
    assert CMfunc.tan(9) == np.tan(9)
    assert CMfunc.arcsin(.5) == np.arcsin(.5)
    assert CMfunc.arccos(.4) == np.arccos(.4)
    assert CMfunc.arctan(.1) == np.arctan(.1)
    assert CMfunc.exp(3) == np.exp(3)
    assert CMfunc.log(
        74088, 42) == np.log(74088) / np.log(42)  #using alternative base

    print('passed constants test')
コード例 #2
0
def test_arctan():
    x = CMG(3)
    f = CMfunc.arctan(x)
    assert f.val == np.arctan(3)
    assert np.array_equal(f.grad, np.array([(1 + 3**2)**(-2)]))