This repository was archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathfunctions.py
58 lines (45 loc) · 1.48 KB
/
functions.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
#!/usr/bin/env python
"""
Simple example of a test generator which just produces data on some
mathematical functions, keyed off of the current time.
"""
from __future__ import print_function
from lnt.testing import Machine, Run, TestSamples, Report
import math
import random
import sys
import time
def main():
from optparse import OptionParser
parser = OptionParser("usage: %prog [options] [output]")
opts, args = parser.parse_args()
if len(args) == 0:
output = '-'
elif len(args) == 1:
output = args[0]
else:
parser.error("invalid number of arguments")
if output == '-':
output = sys.stdout
else:
output = open(output, 'w')
offset = math.pi/5
delay = 120.
machine = Machine('Mr. Sin Wave', info={'delay': delay})
start = time.time()
run = Run(start, start, info={'t': start,
'tag': 'simple',
'run_order': 1})
tests = [TestSamples('simple.%s' % name,
[fn(start*2*math.pi / delay + j * offset)],
info={'offset': j})
for j in range(5)
for name, fn in (('sin', math.sin),
('cos', math.cos),
('random', lambda x: random.random()))]
report = Report(machine, run, tests)
print(report.render(), file=output)
if output is not sys.stderr:
output.close()
if __name__ == '__main__':
main()