diff options
Diffstat (limited to 'networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py')
-rw-r--r-- | networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py b/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py index 16bab3c0..0cdc2d60 100644 --- a/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py +++ b/networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py @@ -4,7 +4,6 @@ pytest.importorskip("scipy") import networkx as nx from networkx.algorithms.bipartite import spectral_bipartivity as sb -from networkx.testing import almost_equal # Examples from Figure 1 # E. Estrada and J. A. Rodríguez-Velázquez, "Spectral measures of @@ -17,54 +16,54 @@ class TestSpectralBipartivity: G = nx.star_graph(2) G.add_edge(1, 2) - assert almost_equal(sb(G), 0.843, places=3) + assert sb(G) == pytest.approx(0.843, abs=1e-3) G = nx.star_graph(3) G.add_edge(1, 2) - assert almost_equal(sb(G), 0.871, places=3) + assert sb(G) == pytest.approx(0.871, abs=1e-3) G = nx.star_graph(4) G.add_edge(1, 2) - assert almost_equal(sb(G), 0.890, places=3) + assert sb(G) == pytest.approx(0.890, abs=1e-3) def test_k23_like(self): # K2,3-like G = nx.complete_bipartite_graph(2, 3) G.add_edge(0, 1) - assert almost_equal(sb(G), 0.769, places=3) + assert sb(G) == pytest.approx(0.769, abs=1e-3) G = nx.complete_bipartite_graph(2, 3) G.add_edge(2, 4) - assert almost_equal(sb(G), 0.829, places=3) + assert sb(G) == pytest.approx(0.829, abs=1e-3) G = nx.complete_bipartite_graph(2, 3) G.add_edge(2, 4) G.add_edge(3, 4) - assert almost_equal(sb(G), 0.731, places=3) + assert sb(G) == pytest.approx(0.731, abs=1e-3) G = nx.complete_bipartite_graph(2, 3) G.add_edge(0, 1) G.add_edge(2, 4) - assert almost_equal(sb(G), 0.692, places=3) + assert sb(G) == pytest.approx(0.692, abs=1e-3) G = nx.complete_bipartite_graph(2, 3) G.add_edge(2, 4) G.add_edge(3, 4) G.add_edge(0, 1) - assert almost_equal(sb(G), 0.645, places=3) + assert sb(G) == pytest.approx(0.645, abs=1e-3) G = nx.complete_bipartite_graph(2, 3) G.add_edge(2, 4) G.add_edge(3, 4) G.add_edge(2, 3) - assert almost_equal(sb(G), 0.645, places=3) + assert sb(G) == pytest.approx(0.645, abs=1e-3) G = nx.complete_bipartite_graph(2, 3) G.add_edge(2, 4) G.add_edge(3, 4) G.add_edge(2, 3) G.add_edge(0, 1) - assert almost_equal(sb(G), 0.597, places=3) + assert sb(G) == pytest.approx(0.597, abs=1e-3) def test_single_nodes(self): @@ -72,11 +71,11 @@ class TestSpectralBipartivity: G = nx.complete_bipartite_graph(2, 3) G.add_edge(2, 4) sbn = sb(G, nodes=[1, 2]) - assert almost_equal(sbn[1], 0.85, places=2) - assert almost_equal(sbn[2], 0.77, places=2) + assert sbn[1] == pytest.approx(0.85, abs=1e-2) + assert sbn[2] == pytest.approx(0.77, abs=1e-2) G = nx.complete_bipartite_graph(2, 3) G.add_edge(0, 1) sbn = sb(G, nodes=[1, 2]) - assert almost_equal(sbn[1], 0.73, places=2) - assert almost_equal(sbn[2], 0.82, places=2) + assert sbn[1] == pytest.approx(0.73, abs=1e-2) + assert sbn[2] == pytest.approx(0.82, abs=1e-2) |