summaryrefslogtreecommitdiff
path: root/networkx/algorithms/assortativity
diff options
context:
space:
mode:
authorJarrod Millman <jarrod.millman@gmail.com>2019-10-08 22:18:40 -0700
committerJarrod Millman <jarrod.millman@gmail.com>2019-10-12 09:21:57 -0700
commit75e0c43bef21f764c669244fb57f658b4afc94e9 (patch)
tree7ecc0f885d8b80e60508a8b4960dd28e53c189f4 /networkx/algorithms/assortativity
parent4093b6b22d681b701bd4dc5a201e7944cd50e268 (diff)
downloadnetworkx-75e0c43bef21f764c669244fb57f658b4afc94e9.tar.gz
Convert nose.tools.assert_* functions into asserts
Diffstat (limited to 'networkx/algorithms/assortativity')
-rw-r--r--networkx/algorithms/assortativity/tests/test_connectivity.py48
-rw-r--r--networkx/algorithms/assortativity/tests/test_correlation.py6
-rw-r--r--networkx/algorithms/assortativity/tests/test_mixing.py14
-rw-r--r--networkx/algorithms/assortativity/tests/test_neighbor_degree.py30
-rw-r--r--networkx/algorithms/assortativity/tests/test_pairs.py22
5 files changed, 60 insertions, 60 deletions
diff --git a/networkx/algorithms/assortativity/tests/test_connectivity.py b/networkx/algorithms/assortativity/tests/test_connectivity.py
index 701d30f3..feeb1dbe 100644
--- a/networkx/algorithms/assortativity/tests/test_connectivity.py
+++ b/networkx/algorithms/assortativity/tests/test_connectivity.py
@@ -13,80 +13,80 @@ class TestNeighborConnectivity(object):
G = nx.path_graph(4)
answer = {1: 2.0, 2: 1.5}
nd = nx.average_degree_connectivity(G)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
answer = {2: 2.0, 4: 1.5}
nd = nx.average_degree_connectivity(D)
- assert_equal(nd, answer)
+ assert nd == answer
answer = {1: 2.0, 2: 1.5}
D = G.to_directed()
nd = nx.average_degree_connectivity(D, source='in', target='in')
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_degree_connectivity(D, source='in', target='in')
- assert_equal(nd, answer)
+ assert nd == answer
def test_degree_p4_weighted(self):
G = nx.path_graph(4)
G[1][2]['weight'] = 4
answer = {1: 2.0, 2: 1.8}
nd = nx.average_degree_connectivity(G, weight='weight')
- assert_equal(nd, answer)
+ assert nd == answer
answer = {1: 2.0, 2: 1.5}
nd = nx.average_degree_connectivity(G)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
answer = {2: 2.0, 4: 1.8}
nd = nx.average_degree_connectivity(D, weight='weight')
- assert_equal(nd, answer)
+ assert nd == answer
answer = {1: 2.0, 2: 1.8}
D = G.to_directed()
nd = nx.average_degree_connectivity(D, weight='weight', source='in',
target='in')
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_degree_connectivity(D, source='in', target='out',
weight='weight')
- assert_equal(nd, answer)
+ assert nd == answer
def test_weight_keyword(self):
G = nx.path_graph(4)
G[1][2]['other'] = 4
answer = {1: 2.0, 2: 1.8}
nd = nx.average_degree_connectivity(G, weight='other')
- assert_equal(nd, answer)
+ assert nd == answer
answer = {1: 2.0, 2: 1.5}
nd = nx.average_degree_connectivity(G, weight=None)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
answer = {2: 2.0, 4: 1.8}
nd = nx.average_degree_connectivity(D, weight='other')
- assert_equal(nd, answer)
+ assert nd == answer
answer = {1: 2.0, 2: 1.8}
D = G.to_directed()
nd = nx.average_degree_connectivity(D, weight='other', source='in',
target='in')
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_degree_connectivity(D, weight='other', source='in',
target='in')
- assert_equal(nd, answer)
+ assert nd == answer
def test_degree_barrat(self):
G = nx.star_graph(5)
G.add_edges_from([(5, 6), (5, 7), (5, 8), (5, 9)])
G[0][5]['weight'] = 5
nd = nx.average_degree_connectivity(G)[5]
- assert_equal(nd, 1.8)
+ assert nd == 1.8
nd = nx.average_degree_connectivity(G, weight='weight')[5]
assert_almost_equal(nd, 3.222222, places=5)
nd = nx.k_nearest_neighbors(G, weight='weight')[5]
@@ -98,19 +98,19 @@ class TestNeighborConnectivity(object):
G.add_edge(1, 3)
G.add_edge(1, 4)
c = nx.average_degree_connectivity(G)
- assert_equal(c, {1: 0, 3: 1})
+ assert c == {1: 0, 3: 1}
c = nx.average_degree_connectivity(G, source='in', target='in')
- assert_equal(c, {0: 0, 1: 0})
+ assert c == {0: 0, 1: 0}
c = nx.average_degree_connectivity(G, source='in', target='out')
- assert_equal(c, {0: 0, 1: 3})
+ assert c == {0: 0, 1: 3}
c = nx.average_degree_connectivity(G, source='in', target='in+out')
- assert_equal(c, {0: 0, 1: 3})
+ assert c == {0: 0, 1: 3}
c = nx.average_degree_connectivity(G, source='out', target='out')
- assert_equal(c, {0: 0, 3: 0})
+ assert c == {0: 0, 3: 0}
c = nx.average_degree_connectivity(G, source='out', target='in')
- assert_equal(c, {0: 0, 3: 1})
+ assert c == {0: 0, 3: 1}
c = nx.average_degree_connectivity(G, source='out', target='in+out')
- assert_equal(c, {0: 0, 3: 1})
+ assert c == {0: 0, 3: 1}
def test_in_out_weight(self):
G = nx.DiGraph()
@@ -121,7 +121,7 @@ class TestNeighborConnectivity(object):
c = nx.average_degree_connectivity(G, source=s, target=t)
cw = nx.average_degree_connectivity(G, source=s, target=t,
weight='weight')
- assert_equal(c, cw)
+ assert c == cw
@raises(ValueError)
def test_invalid_source(self):
@@ -139,4 +139,4 @@ class TestNeighborConnectivity(object):
# just return the connectivity value itself?
G = nx.trivial_graph()
conn = nx.average_degree_connectivity(G, nodes=0)
- assert_equal(conn, {0: 0})
+ assert conn == {0: 0}
diff --git a/networkx/algorithms/assortativity/tests/test_correlation.py b/networkx/algorithms/assortativity/tests/test_correlation.py
index 2267bfeb..81b61482 100644
--- a/networkx/algorithms/assortativity/tests/test_correlation.py
+++ b/networkx/algorithms/assortativity/tests/test_correlation.py
@@ -65,15 +65,15 @@ class TestAttributeMixingCorrelation(BaseTestAttributeMixing):
def test_attribute_assortativity_undirected(self):
r = nx.attribute_assortativity_coefficient(self.G, 'fish')
- assert_equal(r, 6.0 / 22.0)
+ assert r == 6.0 / 22.0
def test_attribute_assortativity_directed(self):
r = nx.attribute_assortativity_coefficient(self.D, 'fish')
- assert_equal(r, 1.0 / 3.0)
+ assert r == 1.0 / 3.0
def test_attribute_assortativity_multigraph(self):
r = nx.attribute_assortativity_coefficient(self.M, 'fish')
- assert_equal(r, 1.0)
+ assert r == 1.0
def test_attribute_assortativity_coefficient(self):
# from "Mixing patterns in networks"
diff --git a/networkx/algorithms/assortativity/tests/test_mixing.py b/networkx/algorithms/assortativity/tests/test_mixing.py
index 9e135e3d..b6bba292 100644
--- a/networkx/algorithms/assortativity/tests/test_mixing.py
+++ b/networkx/algorithms/assortativity/tests/test_mixing.py
@@ -11,14 +11,14 @@ class TestDegreeMixingDict(BaseTestDegreeMixing):
d_result = {1: {2: 2},
2: {1: 2, 2: 2},
}
- assert_equal(d, d_result)
+ assert d == d_result
def test_degree_mixing_dict_undirected_normalized(self):
d = nx.degree_mixing_dict(self.P4, normalized=True)
d_result = {1: {2: 1.0 / 3},
2: {1: 1.0 / 3, 2: 1.0 / 3},
}
- assert_equal(d, d_result)
+ assert d == d_result
def test_degree_mixing_dict_directed(self):
d = nx.degree_mixing_dict(self.D)
@@ -27,7 +27,7 @@ class TestDegreeMixingDict(BaseTestDegreeMixing):
2: {1: 1, 3: 1},
3: {}
}
- assert_equal(d, d_result)
+ assert d == d_result
def test_degree_mixing_dict_multigraph(self):
d = nx.degree_mixing_dict(self.M)
@@ -35,7 +35,7 @@ class TestDegreeMixingDict(BaseTestDegreeMixing):
2: {1: 1, 3: 3},
3: {2: 3}
}
- assert_equal(d, d_result)
+ assert d == d_result
class TestDegreeMixingMatrix(BaseTestDegreeMixing):
@@ -105,7 +105,7 @@ class TestAttributeMixingDict(BaseTestAttributeMixing):
'red': {'one': 1},
'blue': {'two': 1}
}
- assert_equal(d, d_result)
+ assert d == d_result
def test_attribute_mixing_dict_directed(self):
d = nx.attribute_mixing_dict(self.D, 'fish')
@@ -114,14 +114,14 @@ class TestAttributeMixingDict(BaseTestAttributeMixing):
'red': {},
'blue': {}
}
- assert_equal(d, d_result)
+ assert d == d_result
def test_attribute_mixing_dict_multigraph(self):
d = nx.attribute_mixing_dict(self.M, 'fish')
d_result = {'one': {'one': 4},
'two': {'two': 2},
}
- assert_equal(d, d_result)
+ assert d == d_result
class TestAttributeMixingMatrix(BaseTestAttributeMixing):
diff --git a/networkx/algorithms/assortativity/tests/test_neighbor_degree.py b/networkx/algorithms/assortativity/tests/test_neighbor_degree.py
index c294de48..b3b3cefd 100644
--- a/networkx/algorithms/assortativity/tests/test_neighbor_degree.py
+++ b/networkx/algorithms/assortativity/tests/test_neighbor_degree.py
@@ -9,72 +9,72 @@ class TestAverageNeighbor(object):
G = nx.path_graph(4)
answer = {0: 2, 1: 1.5, 2: 1.5, 3: 2}
nd = nx.average_neighbor_degree(G)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D, source='in', target='in')
- assert_equal(nd, answer)
+ assert nd == answer
def test_degree_p4_weighted(self):
G = nx.path_graph(4)
G[1][2]['weight'] = 4
answer = {0: 2, 1: 1.8, 2: 1.8, 3: 2}
nd = nx.average_neighbor_degree(G, weight='weight')
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D, weight='weight')
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D, weight='weight')
- assert_equal(nd, answer)
+ assert nd == answer
nd = nx.average_neighbor_degree(D, source='out', target='out',
weight='weight')
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D, source='in', target='in',
weight='weight')
- assert_equal(nd, answer)
+ assert nd == answer
def test_degree_k4(self):
G = nx.complete_graph(4)
answer = {0: 3, 1: 3, 2: 3, 3: 3}
nd = nx.average_neighbor_degree(G)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D)
- assert_equal(nd, answer)
+ assert nd == answer
D = G.to_directed()
nd = nx.average_neighbor_degree(D, source='in', target='in')
- assert_equal(nd, answer)
+ assert nd == answer
def test_degree_k4_nodes(self):
G = nx.complete_graph(4)
answer = {1: 3.0, 2: 3.0}
nd = nx.average_neighbor_degree(G, nodes=[1, 2])
- assert_equal(nd, answer)
+ assert nd == answer
def test_degree_barrat(self):
G = nx.star_graph(5)
G.add_edges_from([(5, 6), (5, 7), (5, 8), (5, 9)])
G[0][5]['weight'] = 5
nd = nx.average_neighbor_degree(G)[5]
- assert_equal(nd, 1.8)
+ assert nd == 1.8
nd = nx.average_neighbor_degree(G, weight='weight')[5]
assert_almost_equal(nd, 3.222222, places=5)
diff --git a/networkx/algorithms/assortativity/tests/test_pairs.py b/networkx/algorithms/assortativity/tests/test_pairs.py
index 0d5661f2..7fe4fa00 100644
--- a/networkx/algorithms/assortativity/tests/test_pairs.py
+++ b/networkx/algorithms/assortativity/tests/test_pairs.py
@@ -17,14 +17,14 @@ class TestAttributeMixingXY(BaseTestAttributeMixing):
('blue', 'two'),
('two', 'blue')
])
- assert_equal(attrxy, attrxy_result)
+ assert attrxy == attrxy_result
def test_node_attribute_xy_undirected_nodes(self):
attrxy = sorted(nx.node_attribute_xy(self.G, 'fish',
nodes=['one', 'yellow']))
attrxy_result = sorted([
])
- assert_equal(attrxy, attrxy_result)
+ assert attrxy == attrxy_result
def test_node_attribute_xy_directed(self):
attrxy = sorted(nx.node_attribute_xy(self.D, 'fish'))
@@ -33,7 +33,7 @@ class TestAttributeMixingXY(BaseTestAttributeMixing):
('one', 'red'),
('two', 'blue')
])
- assert_equal(attrxy, attrxy_result)
+ assert attrxy == attrxy_result
def test_node_attribute_xy_multigraph(self):
attrxy = sorted(nx.node_attribute_xy(self.M, 'fish'))
@@ -44,14 +44,14 @@ class TestAttributeMixingXY(BaseTestAttributeMixing):
('two', 'two'),
('two', 'two')
]
- assert_equal(attrxy, attrxy_result)
+ assert attrxy == attrxy_result
def test_node_attribute_xy_selfloop(self):
attrxy = sorted(nx.node_attribute_xy(self.S, 'fish'))
attrxy_result = [('one', 'one'),
('two', 'two')
]
- assert_equal(attrxy, attrxy_result)
+ assert attrxy == attrxy_result
class TestDegreeMixingXY(BaseTestDegreeMixing):
@@ -64,13 +64,13 @@ class TestDegreeMixingXY(BaseTestDegreeMixing):
(2, 2),
(1, 2),
(2, 1)])
- assert_equal(xy, xy_result)
+ assert xy == xy_result
def test_node_degree_xy_undirected_nodes(self):
xy = sorted(nx.node_degree_xy(self.P4, nodes=[0, 1, -1]))
xy_result = sorted([(1, 2),
(2, 1), ])
- assert_equal(xy, xy_result)
+ assert xy == xy_result
def test_node_degree_xy_directed(self):
xy = sorted(nx.node_degree_xy(self.D))
@@ -78,7 +78,7 @@ class TestDegreeMixingXY(BaseTestDegreeMixing):
(2, 3),
(1, 3),
(1, 3)])
- assert_equal(xy, xy_result)
+ assert xy == xy_result
def test_node_degree_xy_multigraph(self):
xy = sorted(nx.node_degree_xy(self.M))
@@ -90,13 +90,13 @@ class TestDegreeMixingXY(BaseTestDegreeMixing):
(3, 2),
(1, 2),
(2, 1)])
- assert_equal(xy, xy_result)
+ assert xy == xy_result
def test_node_degree_xy_selfloop(self):
xy = sorted(nx.node_degree_xy(self.S))
xy_result = sorted([(2, 2),
(2, 2)])
- assert_equal(xy, xy_result)
+ assert xy == xy_result
def test_node_degree_xy_weighted(self):
G = nx.Graph()
@@ -107,4 +107,4 @@ class TestDegreeMixingXY(BaseTestDegreeMixing):
(17, 10),
(17, 7),
(10, 17)])
- assert_equal(xy, xy_result)
+ assert xy == xy_result