def test_draw_nodes(test_data): for d in test_data: gpm = GenotypePhenotypeMap(genotype=d["genotype"], phenotype=d["phenotype"]) G = gpmap.GenotypePhenotypeGraph() G.add_gpm(gpm) fig, ax = plt.subplots(figsize=(10, 10)) # Make sure it draws something. nodes = draw_nodes(G, flattened(G), ax) ax.plot # <- will throw attribute error if this is not right len(nodes)
def test__nx_wrapper(test_data): gpm = GenotypePhenotypeMap(genotype=["AA", "AB", "BA", "BB"]) G = gpmap.GenotypePhenotypeGraph() G.add_gpm(gpm) pos = flattened(G) fig, ax = plt.subplots(figsize=(10, 10)) # Should throw warning even though bad arg. with pytest.warns(UserWarning): ret = _nx_wrapper(nx.draw_networkx_nodes, G=G, pos=pos, ax=ax, not_a_real_argument=10)
def test_pos(test_data): # requires G with pytest.raises(TypeError): pos.flattened() # pass dumb argument with pytest.raises(ValueError): pos.flattened("stupid") for d in test_data: gpm = GenotypePhenotypeMap(genotype=d["genotype"], wildtype=d["wildtype"], phenotype=d["phenotype"]) G = GenotypePhenotypeGraph() # test check for loaded dataset. with pytest.raises(ValueError): pos.flattened(G) # Load in data G.add_gpm(gpm) # Should work ret = pos.flattened(G) # Check basic sanity of returns assert type(ret) is dict for k in ret: G.nodes[k] assert type(ret[k]) is list assert len(ret[k]) == 2 # Check for bad scale values with pytest.raises(ValueError): pos.flattened(G,scale=0) with pytest.raises(ValueError): pos.flattened(G,scale=-1) # these should work ret = pos.flattened(G,scale=10.0) assert type(ret) is dict ret = pos.flattened(G,scale=22.3) assert type(ret) is dict # make sure it takes vertical parameter. not really testing if it has # effect (test for graphs are annoying... ) ret = pos.flattened(G,scale=1,vertical=True) assert type(ret) is dict