-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
createFileLog.py
39 lines (30 loc) · 950 Bytes
/
createFileLog.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
#!/usr/bin/python3
# usage python3 createFileLog.py <system.mky>
# writes a log file on stdout for system <system.mky>
import sys
from pathlib import Path
here=Path(sys.argv[0]).parent.parent
if here=="": here='.' #relative path
sys.path.append(str(here))
from pyminsky import minsky
import re
minsky.load(sys.argv[1])
nSteps=10
print("nsteps,",nSteps)
minsky.running(True)
#provide seed to ensure repeatability
minsky.srand(10)
minsky.reset()
for step in range(nSteps):
minsky.step()
print(minsky.t(),end='')
for name in minsky.variableValues._keys():
if re.search("^constant:",name) != None: continue
value=minsky.variableValues[name]
if value.temp(): continue
if value.size()>1:
for i in range(value.size()):
print(f',"{value.name()}|{i}"',value.value(i),sep=',',end='')
else:
print(f',"{value.name()}"',value.value(),sep=',',end="")
print()