Commit b82c96d6 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

update tests

parent 04e7e460
...@@ -33,13 +33,11 @@ class TestD2Graph(unittest.TestCase): ...@@ -33,13 +33,11 @@ class TestD2Graph(unittest.TestCase):
else: else:
self.assertEqual(1, len(d2.index[dmer])) self.assertEqual(1, len(d2.index[dmer]))
def test_linear_d2_construction(self): def test_linear_d2_construction(self):
for d in range(1, 10): for d in range(1, 10):
size = 2 * d + 3 size = 2 * d + 3
index_k = 2 * d - 1 index_k = 2 * d - 1
G = gm.generate_d_graph_chain(size, d) G = gm.generate_d_graph_chain(size, d)
d2 = D2Graph(G) d2 = D2Graph(G)
d2.construct_from_barcodes(index_size=index_k, verbose=False) d2.construct_from_barcodes(index_size=index_k, verbose=False)
...@@ -49,7 +47,7 @@ class TestD2Graph(unittest.TestCase): ...@@ -49,7 +47,7 @@ class TestD2Graph(unittest.TestCase):
self.assertEqual(awaited_d_num, len(d2.all_d_graphs)) self.assertEqual(awaited_d_num, len(d2.all_d_graphs))
# Test index # Test index
awaited_index_size = comb(2*d+1, index_k) + (size - (2*d+1)) * comb(2*d, index_k-1) awaited_index_size = comb(2 * d + 1, index_k) + (size - (2 * d + 1)) * comb(2 * d, index_k - 1)
if len(d2.index) != awaited_index_size: if len(d2.index) != awaited_index_size:
dmers = [list(x) for x in d2.index] dmers = [list(x) for x in d2.index]
dmers = [str(x) for x in dmers if len(x) != len(frozenset(x))] dmers = [str(x) for x in dmers if len(x) != len(frozenset(x))]
...@@ -59,15 +57,15 @@ class TestD2Graph(unittest.TestCase): ...@@ -59,15 +57,15 @@ class TestD2Graph(unittest.TestCase):
# Test connectivity # Test connectivity
# Center node names # Center node names
c1 = d c1 = d
c2 = d+1 c2 = d + 1
c3 = d+2 c3 = d + 2
# Connectivity matrix # Connectivity matrix
awaited_distances = { awaited_distances = {
c1:{c2:2, c3:4}, c1: {c2: 2, c3: 4},
c2:{c1:2, c3:2}, c2: {c1: 2, c3: 2},
c3:{c1:4, c2:2} c3: {c1: 4, c2: 2}
} }
for x, y, data in d2.edges(data=True): for x, y, data in d2.edges(data=True):
dg1 = d2.node_by_idx[x] dg1 = d2.node_by_idx[x]
dg2 = d2.node_by_idx[y] dg2 = d2.node_by_idx[y]
...@@ -81,11 +79,10 @@ class TestD2Graph(unittest.TestCase): ...@@ -81,11 +79,10 @@ class TestD2Graph(unittest.TestCase):
# for idx2, dist in neighbors.items(): # for idx2, dist in neighbors.items():
# dg2 = d2.node_by_idx[idx2] # dg2 = d2.node_by_idx[idx2]
# awaited_dist = awaited_distances[dg1.center][dg2.center] # awaited_dist = awaited_distances[dg1.center][dg2.center]
# self.assertEqual(dist, awaited_dist) # self.assertEqual(dist, awaited_dist)
def test_reloading(self): def test_reloading(self):
# Parameters # Parameters
d = 3 d = 3
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment