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 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_plot_ADnum(): X = ADnum(1, der=1) def Y(x): return ADmath.sin(x) fig = ADgraph.plot_ADnum(Y) assert type(fig) == matplotlib.figure.Figure
def test_gen_graph(): d = {'y': [('x', 'test')]} Y = ADnum(1, der=1, graph=d) G = ADgraph.gen_graph(Y) assert 'y' in G assert 'x' in G assert type(G) == nx.classes.digraph.DiGraph assert G.number_of_nodes() == 2 assert G.number_of_edges() == 1
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_reverse_graph(): d = {'y': [('x', 'test')]} rd = {'x': [('y', 'test')]} Y = ADnum(1, der=1, graph=d) rg = ADgraph.reverse_graph(Y) assert rd == rg