Skip to content

Commit

Permalink
added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Mar 9, 2024
1 parent 62d3a07 commit 6ea9df9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/core/test_diviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,15 @@ def test_isolates():
assert set(DH.nodes.isolates()) == {0, 1, 2, 3}
DH.add_edge([{0}, {1, 2}])
assert set(DH.nodes.isolates()) == {3}


def test_diview_custom_filterby(diedgelist2):
H = xgi.DiHypergraph(diedgelist2)

f = lambda val, arg: val % arg == 0
assert set(H.edges.filterby("tail_size", 2, mode=f)) == {0, 1}


def test_diview_custom_filterby_attr(dihyperwithattrs):
f = lambda val, arg: arg in val
assert set(dihyperwithattrs.nodes.filterby_attr("color", "l", mode=f)) == {2, 3, 5}
12 changes: 12 additions & 0 deletions tests/core/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,15 @@ def test_ids_are_immutable(edgelist5):
H = xgi.Hypergraph(edgelist5)
H.edges.ids.add(42)
assert H.edges.ids == {0, 1, 2, 3}


def test_view_custom_filterby(edgelist8):
H = xgi.Hypergraph(edgelist8)

f = lambda val, arg: val <= arg**2
assert set(H.nodes.filterby("degree", 2, mode=f)) == {2, 3, 4, 5, 6}


def test_view_custom_filterby_attr(hyperwithattrs):
f = lambda val, arg: arg in val
assert set(hyperwithattrs.nodes.filterby_attr("color", "l", mode=f)) == {2, 3, 5}

0 comments on commit 6ea9df9

Please sign in to comment.