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
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
def Y(x): return ADmath.sin(x)
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
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
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
def test_ADmath_sinr(): X = np.pi Y = ADmath.sin(X) assert Y == np.sin(np.pi)
def test_ADmath_sin(): X = ADnum(np.pi, der=1) Y = ADmath.sin(X) assert Y.val == np.sin(np.pi) assert Y.der == np.cos(np.pi) assert len(Y.graph) == 1