-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposh.py
47 lines (35 loc) · 956 Bytes
/
posh.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
import math
import time
# modelop.init
def init():
return
# modelop.metrics
def metrics():
yield {}
# modelop.score
def score(data):
begin = time.time() * 1000
print(begin)
print(data, flush=True)
start = 1
max = 10000000
if data is not None and (type(data) is dict):
if 'start' in data:
start = data['start']
if 'max' in data:
max = data['max']
print("start=" + str(start) + ", max=" + str(max), flush=True)
total = 0
for i in range(start, max):
total += math.sqrt(math.fabs(math.cos(i) * math.sin(i) / math.tan(i) * i**2 / i**3))
yieldDict = {
'start' : start,
'max' : max,
'score' : total / max,
'milliseconds' : (time.time() * 1000) - begin
}
print('about to yield', flush=True)
print(yieldDict, flush=True)
yield yieldDict
#print(score({'start' : 17, 'max' : 10}))
#print(score({'start' : 17}))