forked from sarah-mcguire/nervePool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pooling.py
91 lines (74 loc) · 2.49 KB
/
test_pooling.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import numpy as np
from complex import SComplex, pool_complex
from originalcomplex import SComplex as OriginalSComplex
from originalcomplex import pool_complex as original_pool_complex
vertex_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
edge_list = [
"ab",
"ac",
"bc",
"cd",
"cj",
"de",
"df",
"dg",
"ef",
"gh",
"gi",
"gj",
"gk",
"gl",
"hi",
"jk",
"jl",
"kl",
]
triangle_list = ["abc", "gjk", "gjl", "gkl", "jkl"]
tetrahedron_list = ["gjkl"]
# Cluster Assignments
S0 = np.array(
[
[1, 0, 0, 0],
[1, 0, 0, 0],
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 1, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 1, 0],
[0, 0, 1, 0],
[1, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 0, 1],
]
)
# Gather these lists into a single list
simplices = list([vertex_list, edge_list, triangle_list, tetrahedron_list])
OSC1 = OriginalSComplex(simplices)
SC1 = SComplex(simplices=simplices)
np.testing.assert_equal(SC1.boundaries.B1, OSC1.B1, verbose=True)
np.testing.assert_equal(SC1.boundaries.B2, OSC1.B2, verbose=True)
np.testing.assert_equal(SC1.boundaries.B3, OSC1.B3, verbose=True)
OSC1_pooled = original_pool_complex(OSC1, S0)
SC1_pooled = pool_complex(SC1, S0)
np.testing.assert_equal(SC1_pooled.boundaries.B1, OSC1_pooled.B1, verbose=True)
np.testing.assert_equal(SC1_pooled.boundaries.B2, OSC1_pooled.B2, verbose=True)
np.testing.assert_equal(SC1_pooled.boundaries.B3, OSC1_pooled.B3, verbose=True)
if SC1_pooled.boundaries.B1 is not None:
np.testing.assert_allclose(SC1_pooled.boundaries.B1, OSC1_pooled.B1, verbose=True)
if SC1_pooled.boundaries.B2 is not None:
np.testing.assert_allclose(SC1_pooled.boundaries.B2, OSC1_pooled.B2, verbose=True)
if SC1_pooled.boundaries.B3 is not None:
np.testing.assert_allclose(SC1_pooled.boundaries.B3, OSC1_pooled.B3, verbose=True)
if SC1_pooled.simplices.nodes is not None:
print("Testing Nodes")
all(x == y for x, y in zip(SC1_pooled.simplices.nodes, OSC1_pooled.nodes))
if SC1_pooled.simplices.edges is not None:
print("Testing Edges")
all(x == y for x, y in zip(SC1_pooled.simplices.edges, OSC1_pooled.edges))
if SC1_pooled.simplices.cycles is not None:
print("Testing Cycles")
all(x == y for x, y in zip(SC1_pooled.simplices.cycles, OSC1_pooled.cycles))
if SC1_pooled.simplices.tetra is not None:
print("Testing Tetra")
all(x == y for x, y in zip(SC1_pooled.tetra, OSC1_pooled.tetra))