forked from pyt-team/TopoEmbedX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_neighborhood.py
49 lines (37 loc) · 1.59 KB
/
test_neighborhood.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Testing the neighborhood module."""
import pytest
import toponetx as tnx
import topoembedx as tex
class TestNeighborhood:
"""Test the neighborhood module of TopoEmbedX."""
def test_neighborhood_from_complex_raise_error(self):
"""Testing if right assertion is raised for incorrect type."""
with pytest.raises(TypeError) as e:
tex.neighborhood.neighborhood_from_complex(1)
assert (
str(e.value)
== """Input Complex can only be a Simplicial, Cell or Combinatorial Complex."""
)
def test_neighborhood_from_complex_matrix_dimension_cell_complex(self):
"""Testing the matrix dimensions for the adjacency and coadjacency matrices."""
# Testing for the case of Cell Complex
cc1 = tnx.classes.CellComplex(
[[0, 1, 2, 3], [1, 2, 3, 4], [1, 3, 4, 5, 6, 7, 8]]
)
cc2 = tnx.classes.CellComplex([[0, 1, 2], [1, 2, 3]])
ind, A = tex.neighborhood.neighborhood_from_complex(cc1)
assert A.todense().shape == tuple([9, 9])
assert len(ind) == 9
ind, A = tex.neighborhood.neighborhood_from_complex(cc2)
assert A.todense().shape == tuple([4, 4])
assert len(ind) == 4
ind, A = tex.neighborhood.neighborhood_from_complex(
cc1, neighborhood_type="!adj"
)
assert A.todense().shape == tuple([9, 9])
assert len(ind) == 9
ind, A = tex.neighborhood.neighborhood_from_complex(
cc2, neighborhood_type="!adj"
)
assert A.todense().shape == tuple([4, 4])
assert len(ind) == 4