コード例 #1
0
def test_get_labels():
    X = ADnum(1, der=1)
    Y = ADmath.sin(X) + 3
    labs = ADgraph.get_labels(Y)
    assert labs[X] == 'X0'
    assert labs[Y] == 'X2'
    assert len(labs) == 4
コード例 #2
0
def test_get_colorsandsizes():
    X = ADnum(1, der=1)
    Y = ADmath.sin(X) + 3
    labs = ADgraph.get_labels(Y)
    G = ADgraph.gen_graph(Y)
    cols = ADgraph.get_colors(G, Y)
    sizes = ADgraph.get_sizes(G, Y, labs)
    assert len(cols) == 4
    assert len(sizes) == 4
コード例 #3
0
def test_ADmath_tanh():
    f = ADmath.tanh(ADnum(-5, der=1))
    assert f.val == np.tanh(-5)
    assert f.der == 1 / (np.cosh(-5)**2)
    assert len(f.graph) == 1
コード例 #4
0
def test_gen_table():
    X = ADnum(1, der=1)
    Y = ADmath.sin(X) + 3
    dat = ADgraph.gen_table(Y)
    assert type(dat) == pandas.core.frame.DataFrame
コード例 #5
0
def test_2xe2x():
    x = ADnum(2, der=1)
    f = 2 * x * ADmath.exp(2 * x)
    assert f.val == 4 * np.exp(4)
    assert f.der == 2 * np.exp(4.0) + 8 * np.exp(4)
コード例 #6
0
def test_5x2lnx():
    x = ADnum(1, der=1)
    f = 5 * x**2 * ADmath.log(x)
    assert f.val == 0.0
    assert f.der == 10 * 1.0 * np.log(1.0) + 5 * 1.0
コード例 #7
0
def test_ADmath_sqrtr():
    f = ADmath.sqrt(40)
    assert f == np.sqrt(40)
コード例 #8
0
def test_ADmath_expr():
    f = ADmath.exp(-3)
    assert f == np.exp(-3)
コード例 #9
0
def test_ADmath_tanr():
    f = ADmath.tan(4)
    assert f == np.tan(4)
コード例 #10
0
def test_ADmath_cosr():
    f = ADmath.cos(4)
    assert f == np.cos(4)
コード例 #11
0
def test_ADmath_sinr():
    X = np.pi
    Y = ADmath.sin(X)
    assert Y == np.sin(np.pi)
コード例 #12
0
def test_ADmath_sqrt():
    f = ADmath.sqrt(ADnum(40, der=1))
    assert f.val == np.sqrt(40)
    assert f.der == 1 / (2 * np.sqrt(40))
    assert len(f.graph) == 1
コード例 #13
0
def test_ADmath_logistic():
    f = ADmath.logistic(ADnum(0, der=1))
    assert f.val == .5
    assert f.der == .25
コード例 #14
0
def test_ADmath_log():
    f = ADmath.log(ADnum(72, der=1))
    assert f.val == np.log(72)
    assert f.der == 1 / 72
    assert len(f.graph) == 1
コード例 #15
0
def test_ADmath_exp():
    f = ADmath.exp(ADnum(-3, der=1))
    assert f.val == np.exp(-3)
    assert f.der == np.exp(-3)
    assert len(f.graph) == 1
コード例 #16
0
def test_ADmath_coshr():
    f = ADmath.cosh(3)
    assert f == np.cosh(3)
コード例 #17
0
def test_ADmath_tanhr():
    f = ADmath.tanh(-5)
    assert f == np.tanh(-5)
コード例 #18
0
def test_ADmath_cscr():
    f = ADmath.csc(5)
    assert f == 1 / np.sin(5)
コード例 #19
0
def test_ADmath_logr():
    f = ADmath.log(72)
    assert f == np.log(72)
コード例 #20
0
def test_ADmath_secr():
    f = ADmath.sec(6)
    assert f == 1 / np.cos(6)
コード例 #21
0
def test_xex():
    x = ADnum(2, der=1)
    f = x * ADmath.exp(x)
    assert f.val == 2.0 * np.exp(2.0)
    assert f.der == np.exp(2.0) + 2.0 * np.exp(2.0)
コード例 #22
0
def test_ADmath_cotr():
    f = ADmath.cot(1)
    assert f == 1 / np.tan(1)
コード例 #23
0
def test_sinxcosx():
    x = ADnum(0, der=1)
    f = ADmath.sin(x) * ADmath.cos(x)
    assert f.val == np.sin(0) * np.cos(0)
    assert f.der == -(np.sin(0)**2) + np.cos(0)**2
コード例 #24
0
def test_ADmath_arcsinr():
    f = ADmath.arcsin(.2)
    assert f == np.arcsin(.2)
コード例 #25
0
def test_ADmath_arccosr():
    f = ADmath.arccos(.3)
    assert f == np.arccos(.3)
コード例 #26
0
def test_ADmath_arctanr():
    f = ADmath.arctan(1)
    assert f == np.arctan(1)
コード例 #27
0
def test_draw_graph():
    X = ADnum(1, der=1)
    Y = ADmath.sin(X) + 3
    fig = ADgraph.draw_graph(Y)
    assert type(fig) == matplotlib.figure.Figure
コード例 #28
0
def test_ADmath_sinhr():
    f = ADmath.sinh(2)
    assert f == np.sinh(2)
コード例 #29
0
 def Y(x):
     return ADmath.sin(x)
コード例 #30
0
def test_ADmath_cosh():
    f = ADmath.cosh(ADnum(3, der=1))
    assert f.val == np.cosh(3)
    assert f.der == np.sinh(3)
    assert len(f.graph) == 1