-
Notifications
You must be signed in to change notification settings - Fork 0
/
symmetry_test.py
37 lines (29 loc) · 1.28 KB
/
symmetry_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
import numpy as np
import random
from symmetry import *
def test_d2():
x = np.matrix([[1, 2, 3], [4, 5, 6]])
assert(np.array_equal(dihedral(x, 0), [[1, 2, 3], [4, 5, 6]]))
assert(np.array_equal(dihedral(x, 1), [[4, 5, 6], [1, 2, 3]]))
assert(np.array_equal(dihedral(x, 2), [[3, 2, 1], [6, 5, 4]]))
assert(np.array_equal(dihedral(x, 3), [[6, 5, 4], [3, 2, 1]]))
assert(np.array_equal(dihedral(x, 4), [[1, 2, 3], [4, 5, 6]]))
def test_d4():
x = np.matrix([[1, 2], [3, 4]])
assert(np.array_equal(dihedral(x, 0), [[1, 2], [3, 4]]))
assert(np.array_equal(dihedral(x, 1), [[2, 4], [1, 3]]))
assert(np.array_equal(dihedral(x, 2), [[4, 3], [2, 1]]))
assert(np.array_equal(dihedral(x, 3), [[3, 1], [4, 2]]))
assert(np.array_equal(dihedral(x, 4), [[3, 4], [1, 2]]))
assert(np.array_equal(dihedral(x, 5), [[4, 2], [3, 1]]))
assert(np.array_equal(dihedral(x, 6), [[2, 1], [4, 3]]))
assert(np.array_equal(dihedral(x, 7), [[1, 3], [2, 4]]))
def test_vectorised():
x = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
y = np.array([[[2, 4], [1, 3]], [[6, 8], [5, 7]]])
assert(np.array_equal(dihedral(x, 1), y))
assert(np.array_equal(dihedral(dihedral(x, 5), 5), x))
if __name__ == '__main__':
test_d2()
test_d4()
test_vectorised()