Пример #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_arccos():
    x = CMG(0.5)
    f = CMfunc.arccos(x)
    assert f.val == np.arccos(.5)
    assert np.array_equal(f.grad, np.array([-(1 - .5**2)**(-0.5)]))