Commit 04e7e460 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

update deprecated Equals to Equal

parent ebf850ac
......@@ -2,5 +2,5 @@
export PREVPATH=$PYTHONPATH
export PYTHONPATH=deconvolution/
pytest -s tests
pytest -s tests -Wall
export PYTHONPATH=$PREVPATH
......@@ -18,20 +18,20 @@ class TestD2Graph(unittest.TestCase):
# Evaluate the number of candidate unit d_graphs generated
for node, candidates in d2.d_graphs_per_node.items():
if node == "C" or node == "B2":
self.assertEquals(1, len(candidates))
self.assertEqual(1, len(candidates))
else:
self.assertEquals(0, len(candidates))
self.assertEqual(0, len(candidates))
# Evaluate the index
self.assertEquals(13, len(d2.index))
self.assertEqual(13, len(d2.index))
overlap_key = ('A1', 'A2', 'B0', 'B1', 'B2', 'C')
for dmer, dg_lst in d2.index.items():
if dmer == overlap_key:
self.assertEquals(2, len(d2.index[dmer]))
self.assertNotEquals(d2.index[dmer][0], d2.index[dmer][1])
self.assertEqual(2, len(d2.index[dmer]))
self.assertNotEqual(d2.index[dmer][0], d2.index[dmer][1])
else:
self.assertEquals(1, len(d2.index[dmer]))
self.assertEqual(1, len(d2.index[dmer]))
def test_linear_d2_construction(self):
......@@ -46,7 +46,7 @@ class TestD2Graph(unittest.TestCase):
# Test the number of d-graphs
awaited_d_num = size - 2 * d
self.assertEquals(awaited_d_num, len(d2.all_d_graphs))
self.assertEqual(awaited_d_num, len(d2.all_d_graphs))
# Test index
awaited_index_size = comb(2*d+1, index_k) + (size - (2*d+1)) * comb(2*d, index_k-1)
......@@ -54,7 +54,7 @@ class TestD2Graph(unittest.TestCase):
dmers = [list(x) for x in d2.index]
dmers = [str(x) for x in dmers if len(x) != len(frozenset(x))]
self.assertEquals(awaited_index_size, len(d2.index))
self.assertEqual(awaited_index_size, len(d2.index))
# Test connectivity
# Center node names
......@@ -73,7 +73,7 @@ class TestD2Graph(unittest.TestCase):
dg2 = d2.node_by_idx[y]
awaited_dist = awaited_distances[dg1.center][dg2.center]
self.assertEquals(data["distance"], awaited_dist)
self.assertEqual(data["distance"], awaited_dist)
# # distance tests
# for idx1, neighbors in d2.distances.items():
......@@ -83,7 +83,7 @@ class TestD2Graph(unittest.TestCase):
# dg2 = d2.node_by_idx[idx2]
# awaited_dist = awaited_distances[dg1.center][dg2.center]
# self.assertEquals(dist, awaited_dist)
# self.assertEqual(dist, awaited_dist)
def test_reloading(self):
......@@ -107,14 +107,14 @@ class TestD2Graph(unittest.TestCase):
d2_reloaded.load(fp.name)
# Test the nx graph
self.assertNotEquals(d2_reloaded, None)
self.assertEquals(len(d2_reloaded.nodes()), len(d2.nodes()))
self.assertEquals(len(d2_reloaded.edges()), len(d2.edges()))
self.assertNotEqual(d2_reloaded, None)
self.assertEqual(len(d2_reloaded.nodes()), len(d2.nodes()))
self.assertEqual(len(d2_reloaded.edges()), len(d2.edges()))
# TODO: Verify distances
# Test all_d_graphs
self.assertEquals(len(d2_reloaded.all_d_graphs), len(d2.all_d_graphs))
self.assertEqual(len(d2_reloaded.all_d_graphs), len(d2.all_d_graphs))
# Verify dg idxs
reloaded_idxs = [dg.idx for dg in d2_reloaded.all_d_graphs]
for dg in d2.all_d_graphs:
......
......@@ -12,15 +12,15 @@ class TestDGraph(unittest.TestCase):
center, h1, h2, G = unit_d_graph
# Test basic construction
dg = Dgraph(center)
self.assertEquals(center, dg.center)
self.assertEquals(0, dg.score)
self.assertEqual(center, dg.center)
self.assertEqual(0, dg.score)
# Test adding d-graph sides
dg.put_halves(h1, h2, G)
self.assertEquals(set(h1), set(dg.halves[0]))
self.assertEquals(set(h2), set(dg.halves[1]))
self.assertEquals(dg.connexity[0], {"A0":0,"A1":1,"A2":2})
self.assertEquals(dg.connexity[1], {"B0":0,"B1":1,"B2":2})
self.assertEqual(set(h1), set(dg.halves[0]))
self.assertEqual(set(h2), set(dg.halves[1]))
self.assertEqual(dg.connexity[0], {"A0":0,"A1":1,"A2":2})
self.assertEqual(dg.connexity[1], {"B0":0,"B1":1,"B2":2})
def test_linear_perfect_construction(self):
for d in range(1, 5):
......@@ -38,20 +38,20 @@ class TestDGraph(unittest.TestCase):
# Test the internal arity
awaited_arity = 3*d*d/2 + d/2
self.assertEquals(awaited_arity, len(dg.edges))
self.assertEqual(awaited_arity, len(dg.edges))
def test_optimal_score(self):
center, h1, h2, G = unit_d_graph
dg = Dgraph(center)
dg.put_halves(h1, h2, G)
# Must be the number of transitive edges
self.assertEquals(3, dg.get_optimal_score())
self.assertEqual(3, dg.get_optimal_score())
def test_divergence(self):
center, h1, h2, G = unit_d_graph
dg = Dgraph(center)
dg.put_halves(h1, h2, G)
self.assertEquals(0.0, dg.get_link_divergence())
self.assertEqual(0.0, dg.get_link_divergence())
def test_dg_to_list(self):
center, h1, h2, G = unit_d_graph
......@@ -59,7 +59,7 @@ class TestDGraph(unittest.TestCase):
dg.put_halves(h1, h2, G)
lst = dg.to_ordered_lists()
self.assertEquals([['A0'], ['A1'], ['A2'], ['C'], ['B2'], ['B1'], ['B0']], lst)
self.assertEqual([['A0'], ['A1'], ['A2'], ['C'], ['B2'], ['B1'], ['B0']], lst)
# def test_list_dgraphs(self):
......
......@@ -12,13 +12,13 @@ class TestGraphManipulation(unittest.TestCase):
G = gm.generate_d_graph_chain(size, d)
# Test the size
self.assertEquals(len(G.nodes()), size)
self.assertEqual(len(G.nodes()), size)
# Test arities
for idx in range(d):
self.assertEquals(len(G.edges(idx)), d+idx)
self.assertEquals(len(G.edges(size-idx-1)), d+idx)
self.assertEqual(len(G.edges(idx)), d+idx)
self.assertEqual(len(G.edges(size-idx-1)), d+idx)
for idx in range(d, size-d):
self.assertEquals(len(G.edges(idx)), d*2)
self.assertEqual(len(G.edges(idx)), d*2)
......@@ -31,7 +31,7 @@ class TestGraphManipulation(unittest.TestCase):
H = G.copy()
gm.merge_nodes(H, d+1, d+gap+1)
self.assertEquals(len(H.nodes()), size-1)
self.assertEqual(len(H.nodes()), size-1)
g_nodes = list(G.nodes())
for node in H.nodes():
......@@ -39,13 +39,13 @@ class TestGraphManipulation(unittest.TestCase):
g_neighbors = list(G.neighbors(node))
h_neighbors = list(H.neighbors(node))
if (d+1) in g_neighbors and (d+gap+1) in g_neighbors:
self.assertEquals(len(g_neighbors), len(h_neighbors)+1)
self.assertEqual(len(g_neighbors), len(h_neighbors)+1)
else:
self.assertEquals(len(g_neighbors), len(list(h_neighbors)))
self.assertEqual(len(g_neighbors), len(list(h_neighbors)))
else:
cumulative_neighbors = set(list(G.neighbors(d+1)) + list(G.neighbors(d+gap+1)))
h_neighbors = H.neighbors(f"{d+1}_{d+gap+1}")
self.assertEquals(len(cumulative_neighbors)-2, len(list(h_neighbors)))
self.assertEqual(len(cumulative_neighbors)-2, len(list(h_neighbors)))
......
Markdown is supported
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