-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
executable file
·107 lines (74 loc) · 2.24 KB
/
tests.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
import datetime
from glnzlist import *
print version
# Tests
def test_lattice_by_rows(length, start, stop, print_matrices=False):
count = 0
totalcount = 0
row_indices = range(length)
row_boundaries = range(0, length * length + 1, length)
# print row_boundaries
print "Testing matrices with internal row pruning (pos and elem), caching:"
time_start = time.clock()
for distsquared in range(start, stop):
for mat in generate_lattice_matrices_in_shell(length, length, distsquared):
totalcount += 1
# for row in mat:
# print row_gcd(row)
det = determinant(mat)
if (det == 1 or det == -1):
count += 1
if print_matrices:
print pretty_matrix(transpose(mat))
print
time_end = time.clock()
print "Time: {} s".format(time_end - time_start)
print "{} generated\n{} with det +/-1\n".format(totalcount, count)
def test_suite():
print "Testing at {}".format(datetime.datetime.now())
print
test_suite_matrices()
# test_suite_row_caching()
print "Tests finished.\n*****"
print
def test_suite_matrices():
arguments = {
'length': 4,
'start': 1,
'stop': 12,
'print_matrices': False
}
tests = [
test_lattice_by_rows,
]
print "Testing matrix generation: dim {length}, start {start}, stop {stop}".format(**arguments)
print
for fn in tests:
fn(**arguments)
def test_suite_row_caching():
count = 0
for i in range(0,17):
for row in generate_good_rows_in_shell(4, i):
# print row
count += 1
print count
for i in range(0,17):
for row in generate_good_rows_in_shell(4, i):
# print row
count += 1
print count
def test_suite_square_root():
print square_root_lookup(0)
print square_root_lookup(1)
print square_root_lookup(2)
print square_root_lookup(14)
print len(square_root_list)
print square_root_lookup(144)
print square_root_lookup(146)
print len(square_root_list)
if __name__ == '__main__':
sys.exit(test_suite())