Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main]
pull_request:
branches: [main]
branches: [main, dev]

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
- dev

jobs:
test:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
- dev

jobs:
test:
Expand Down
6 changes: 3 additions & 3 deletions tests/algorithms/test_assortativity.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def test_degree_assortativity(edgelist1, edgelist5):
xgi.degree_assortativity(H)

# test wrong kind
with pytest.raises(XGIError):
with pytest.raises(ValueError):
xgi.degree_assortativity(H1, kind="no-idea")
with pytest.raises(XGIError):
with pytest.raises(ValueError):
xgi.degree_assortativity(H1, kind="no-idea", exact=True)


Expand All @@ -88,7 +88,7 @@ def test_choose_degrees(edgelist1, edgelist6):
_choose_degrees(e, k)

# invalid choice function
with pytest.raises(XGIError):
with pytest.raises(ValueError):
e = H1.edges.members(0)
_choose_degrees(e, k, "test")

Expand Down
7 changes: 4 additions & 3 deletions tests/algorithms/test_simpliciality.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

import xgi
from xgi.utils.trie import Trie


def test_edit_simpliciality(
Expand Down Expand Up @@ -287,7 +288,7 @@ def test_simplicial_fraction(


def test_is_simplex(sc1_with_singletons, h_missing_one_singleton):
t = xgi.Trie()
t = Trie()
edges = sc1_with_singletons.edges.members()
t.build_trie(edges)

Expand All @@ -297,7 +298,7 @@ def test_is_simplex(sc1_with_singletons, h_missing_one_singleton):
assert is_simplex(t, {1, 2, 3}, min_size=1)
assert is_simplex(t, {1, 2}, min_size=1)

t = xgi.Trie()
t = Trie()
edges = h_missing_one_singleton.edges.members()
t.build_trie(edges)

Expand Down Expand Up @@ -376,7 +377,7 @@ def test_powerset():

def test_count_missing_subfaces(h_missing_one_link):
count_missing_subfaces = xgi.algorithms.simpliciality._count_missing_subfaces
t = xgi.Trie()
t = Trie()
t.build_trie(h_missing_one_link.edges.members())
assert count_missing_subfaces(t, {1}, min_size=2) == 0
assert count_missing_subfaces(t, {2, 3}, min_size=2) == 0
Expand Down
15 changes: 8 additions & 7 deletions tests/communities/test_spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_k_is_1(self):
assert np.all(map(lambda v: isinstance(v, int), clusters.values()))

def test_perfectly_separable_low_dimensions(self):
np.random.seed(37)
X = np.zeros((10, 10))
X[:5, :] = np.random.random((5, 10))
X[5:10, :] = 37 + np.random.random((5, 10))
Expand All @@ -31,6 +32,7 @@ def test_perfectly_separable_low_dimensions(self):
)

def test_perfectly_separable_high_dimensions(self):
np.random.seed(37)
X = np.zeros((10, 100))
X[:5, :] = np.random.random((5, 100))
X[5:10, :] = 37 + np.random.random((5, 100))
Expand Down Expand Up @@ -78,13 +80,12 @@ def test_perfectly_separable_low_dimensions(self):
clusters = xgi.spectral_clustering(H, 2, seed=37)
assert len(clusters) == 10

c1 = list(filter(lambda node: clusters[node] == 0, clusters.keys()))
c2 = list(filter(lambda node: clusters[node] == 1, clusters.keys()))
assert len(c1) == 5
assert len(c2) == 5
assert (set(c1) == {1, 2, 3, 4, 5} and set(c2) == {6, 7, 8, 9, 10}) or (
set(c2) == {1, 2, 3, 4, 5} and set(c1) == {6, 7, 8, 9, 10}
)
# Core nodes of each community must be in different clusters.
# Boundary nodes (e.g. 5, 10) may vary across platforms due to
# ARPACK/LAPACK differences in eigsh.
assert clusters[1] == clusters[2] == clusters[3]
assert clusters[7] == clusters[8] == clusters[9]
assert clusters[1] != clusters[7]

def test_strongly_separable_low_dimensions(self):
H = xgi.Hypergraph(
Expand Down
6 changes: 3 additions & 3 deletions tests/core/test_hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def test_random_edge_shuffle(edgelist4):
assert len(H._edge[1]) == len(S._edge[1])

# verify dual of edge dict is nodes dict
assert xgi.utilities.dual_dict(H._edge) == H._node
assert xgi.dual_dict(H._edge) == H._node

# hypergraph with more than two edges
S = xgi.Hypergraph(edgelist4)
Expand All @@ -568,7 +568,7 @@ def test_random_edge_shuffle(edgelist4):
assert len(H._edge[edge_id]) == len(S._edge[edge_id])

# verify dual of edge dict is nodes dict
assert xgi.utilities.dual_dict(H._edge) == H._node
assert xgi.dual_dict(H._edge) == H._node

# random hypergraph
S = xgi.random_hypergraph(50, [0.1, 0.01, 0.001], seed=1)
Expand All @@ -588,7 +588,7 @@ def test_random_edge_shuffle(edgelist4):
assert len(H._node[node_id]) == len(S._node[node_id])

# verify dual of edge dict is nodes dict
assert xgi.utilities.dual_dict(H._edge) == H._node
assert xgi.dual_dict(H._edge) == H._node


def test_duplicate_edges(edgelist1):
Expand Down
3 changes: 2 additions & 1 deletion tests/drawing/test_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import xgi
from xgi.exception import XGIError
from xgi.utils.utilities import crest_r


def test_draw(edgelist8):
Expand Down Expand Up @@ -294,7 +295,7 @@ def test_draw_hyperedges_fc_cmap(edgelist8):
ax, collections = xgi.draw_hyperedges(H, ax=ax)
dyad_collection, edge_collection = collections
assert dyad_collection.get_cmap() == plt.cm.Greys
assert edge_collection.get_cmap() == xgi.crest_r()
assert edge_collection.get_cmap() == crest_r()
plt.close("all")

# set cmap
Expand Down
125 changes: 69 additions & 56 deletions tests/dynamics/test_synchronization.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def test_simulate_kuramoto():
[
[
0.00000000e00,
2.00000000e-03,
4.00000000e-03,
6.00000000e-03,
8.00000000e-03,
1.00000000e-02,
1.20000000e-02,
1.40000000e-02,
1.60000000e-02,
1.80000000e-02,
-4.44089210e-19,
4.01599731e-06,
1.20638793e-05,
2.41594195e-05,
4.03182764e-05,
6.05559922e-05,
8.48879914e-05,
1.13329580e-04,
1.45895943e-04,
],
[
1.57079633e00,
Expand Down Expand Up @@ -55,27 +55,27 @@ def test_simulate_kuramoto():
],
[
4.71238898e00,
4.71438898e00,
4.71638898e00,
4.71838898e00,
4.72038898e00,
4.72238898e00,
4.72438898e00,
4.72638898e00,
4.72838898e00,
4.73038898e00,
4.72038896e00,
4.72438890e00,
4.72838876e00,
4.73238850e00,
4.73638810e00,
4.74038753e00,
4.74438675e00,
4.74838573e00,
],
[
6.28318531e00,
6.28518531e00,
6.28718531e00,
6.28918531e00,
6.29118531e00,
6.29318531e00,
6.29518531e00,
6.29718531e00,
6.29918531e00,
6.30118531e00,
6.28718131e00,
6.28917332e00,
6.29116137e00,
6.29314547e00,
6.29512563e00,
6.29710187e00,
6.29907421e00,
6.30104266e00,
],
]
)
Expand All @@ -93,7 +93,20 @@ def test_compute_kuramoto_order_parameter():

r_time = xgi.compute_kuramoto_order_parameter(theta_time)

output = np.array([0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2])
output = np.array(
[
0.2,
0.2004,
0.20079999,
0.20119995,
0.20159987,
0.20199975,
0.20239957,
0.20279931,
0.20319897,
0.20359852,
]
)
assert norm(r_time - output) < 1e-07


Expand All @@ -115,36 +128,36 @@ def test_simulate_simplicial_kuramoto():

output = np.array(
[
0.49621306,
0.60580058,
0.67907764,
0.72321992,
0.75639763,
0.78366991,
0.80717782,
0.82273716,
0.83467922,
0.84446529,
0.85249769,
0.85912003,
0.86461448,
0.86920235,
0.87305585,
0.87630931,
0.87906825,
0.88141629,
0.88342032,
0.88513433,
0.88660225,
0.88786016,
0.88893787,
0.88986022,
0.89064801,
0.89131879,
0.89188742,
0.89236657,
0.89276710,
0.89309833,
0.47005502,
0.56683261,
0.63844096,
0.69180272,
0.73030803,
0.76480033,
0.79048649,
0.80693615,
0.81954013,
0.82987289,
0.83840891,
0.84549773,
0.85140735,
0.85634508,
0.86046997,
0.8639017,
0.86672724,
0.86901084,
0.87083161,
0.87246323,
0.87505791,
0.88012588,
0.88129515,
0.88101446,
0.88097426,
0.8809488,
0.88082989,
0.88086594,
0.88330025,
0.888143,
]
)

Expand Down
3 changes: 1 addition & 2 deletions tests/generators/test_lattice.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

import xgi
from xgi.exception import XGIError


def test_ring_lattice():
Expand All @@ -27,5 +26,5 @@ def test_ring_lattice():
xgi.ring_lattice(5, 2, 3, 0)

# k < 0 test
with pytest.raises(XGIError):
with pytest.raises(ValueError):
xgi.ring_lattice(5, 2, -1, 0)
3 changes: 1 addition & 2 deletions tests/generators/test_simple.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

import xgi
from xgi.exception import XGIError


def test_star_clique():
Expand All @@ -21,7 +20,7 @@ def test_star_clique():


def test_sunflower():
with pytest.raises(XGIError):
with pytest.raises(ValueError):
H = xgi.sunflower(3, 4, 2)

H = xgi.sunflower(3, 1, 5)
Expand Down
Loading