-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve test coverage for random_clustered and update function names (#…
…7273) * Improve test_cov for random_clustered * Add match Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Cleanup invalid joint deg seq tests. --------- Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
- Loading branch information
1 parent
74ce63f
commit c855557
Showing
1 changed file
with
18 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
import pytest | ||
|
||
import networkx | ||
import networkx as nx | ||
|
||
|
||
class TestRandomClusteredGraph: | ||
def test_valid(self): | ||
def test_custom_joint_degree_sequence(self): | ||
node = [1, 1, 1, 2, 1, 2, 0, 0] | ||
tri = [0, 0, 0, 0, 0, 1, 1, 1] | ||
joint_degree_sequence = zip(node, tri) | ||
G = networkx.random_clustered_graph(joint_degree_sequence) | ||
G = nx.random_clustered_graph(joint_degree_sequence) | ||
assert G.number_of_nodes() == 8 | ||
assert G.number_of_edges() == 7 | ||
|
||
def test_valid2(self): | ||
G = networkx.random_clustered_graph( | ||
[(1, 2), (2, 1), (1, 1), (1, 1), (1, 1), (2, 0)] | ||
) | ||
def test_tuple_joint_degree_sequence(self): | ||
G = nx.random_clustered_graph([(1, 2), (2, 1), (1, 1), (1, 1), (1, 1), (2, 0)]) | ||
assert G.number_of_nodes() == 6 | ||
assert G.number_of_edges() == 10 | ||
|
||
def test_invalid1(self): | ||
pytest.raises( | ||
(TypeError, networkx.NetworkXError), | ||
networkx.random_clustered_graph, | ||
[[1, 1], [2, 1], [0, 1]], | ||
) | ||
def test_invalid_joint_degree_sequence_type(self): | ||
with pytest.raises(nx.NetworkXError, match="Invalid degree sequence"): | ||
nx.random_clustered_graph([[1, 1], [2, 1], [0, 1]]) | ||
|
||
def test_invalid2(self): | ||
pytest.raises( | ||
(TypeError, networkx.NetworkXError), | ||
networkx.random_clustered_graph, | ||
[[1, 1], [1, 2], [0, 1]], | ||
) | ||
def test_invalid_joint_degree_sequence_value(self): | ||
with pytest.raises(nx.NetworkXError, match="Invalid degree sequence"): | ||
nx.random_clustered_graph([[1, 1], [1, 2], [0, 1]]) | ||
|
||
def test_directed_graph_raises_error(self): | ||
with pytest.raises(nx.NetworkXError, match="Directed Graph not supported"): | ||
nx.random_clustered_graph( | ||
[(1, 2), (2, 1), (1, 1), (1, 1), (1, 1), (2, 0)], | ||
create_using=nx.DiGraph, | ||
) |