-
Notifications
You must be signed in to change notification settings - Fork 0
/
filtration_test.py
57 lines (46 loc) · 1.36 KB
/
filtration_test.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
# Unit tests for the filtration module.
# Test 1
# Points:
# A(-1, 0), B(1, 0), C(0, 1)
# Illustration:
# .
# . .
#
# Test 2
# Points:
# A(0, -2), B(0, -1), C (0, 1), D(0, 2)
# Illustration:
# .
# .
#
# .
# .
from abstract_simplicial_complex import Point, Simplex, ASC
from filtration import Filtration
from metrics import induced_metric
import numpy as np
def display_filtration(points):
f = Filtration(points, len(points) - 1)
f.print_metadata()
f.generate_filtration()
f.print_filtration()
def test_1():
print("\nTest 1\n")
points = set([
Point(name='A', coordinates=np.array([-1, 0]), dist_metric=induced_metric),
Point(name='B', coordinates=np.array([+1, 0]), dist_metric=induced_metric),
Point(name='C', coordinates=np.array([ 0, +1]), dist_metric=induced_metric)
])
display_filtration(points)
def test_2():
print("\nTest 2\n")
points = set([
Point(name='A', coordinates=np.array([ 0, -2]), dist_metric=induced_metric),
Point(name='B', coordinates=np.array([ 0, -1]), dist_metric=induced_metric),
Point(name='C', coordinates=np.array([ 0, +1]), dist_metric=induced_metric),
Point(name='D', coordinates=np.array([ 0, +2]), dist_metric=induced_metric)
])
display_filtration(points)
if __name__ == '__main__':
test_1()
test_2()