summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Barnowski <rossbar@berkeley.edu>2022-10-05 22:38:23 -0700
committerJarrod Millman <jarrod.millman@gmail.com>2022-11-01 10:25:11 -0700
commit59ba90c70ef4ff1a9136f4e39dba5529c3e64c3e (patch)
tree06ae82c869566657c2a81403e42b136f33c90293
parent040a84fdfc59aef5e9af96488dbd7f30efc90d19 (diff)
downloadnetworkx-59ba90c70ef4ff1a9136f4e39dba5529c3e64c3e.tar.gz
Fix warnings from running tests in randomized order (#6014)
* Use toarray instead of .A for sparse array conversion. Missed this example in the test suite during the sparse cleanup. * Fix crosstalk of axis object between tests. This now raises a dep warning for mpl 3.6 and will result in explicit exceptions in the future.
-rw-r--r--networkx/drawing/tests/test_pylab.py7
-rw-r--r--networkx/generators/tests/test_expanders.py2
2 files changed, 5 insertions, 4 deletions
diff --git a/networkx/drawing/tests/test_pylab.py b/networkx/drawing/tests/test_pylab.py
index 33ce4e85..f642dcc4 100644
--- a/networkx/drawing/tests/test_pylab.py
+++ b/networkx/drawing/tests/test_pylab.py
@@ -485,18 +485,19 @@ def test_multigraph_edgelist_tuples():
def test_alpha_iter():
pos = nx.random_layout(barbell)
+ fig = plt.figure()
# with fewer alpha elements than nodes
- plt.subplot(131)
+ fig.add_subplot(131) # Each test in a new axis object
nx.draw_networkx_nodes(barbell, pos, alpha=[0.1, 0.2])
# with equal alpha elements and nodes
num_nodes = len(barbell.nodes)
alpha = [x / num_nodes for x in range(num_nodes)]
colors = range(num_nodes)
- plt.subplot(132)
+ fig.add_subplot(132)
nx.draw_networkx_nodes(barbell, pos, node_color=colors, alpha=alpha)
# with more alpha elements than nodes
alpha.append(1)
- plt.subplot(133)
+ fig.add_subplot(133)
nx.draw_networkx_nodes(barbell, pos, alpha=alpha)
diff --git a/networkx/generators/tests/test_expanders.py b/networkx/generators/tests/test_expanders.py
index 738773fd..822eeee0 100644
--- a/networkx/generators/tests/test_expanders.py
+++ b/networkx/generators/tests/test_expanders.py
@@ -30,7 +30,7 @@ def test_margulis_gabber_galil_graph():
# Eigenvalues are already sorted using the scipy eigvalsh,
# but the implementation in numpy does not guarantee order.
- w = sorted(sp.linalg.eigvalsh(adjacency_matrix(g).A))
+ w = sorted(sp.linalg.eigvalsh(adjacency_matrix(g).toarray()))
assert w[-2] < 5 * np.sqrt(2)