Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #474 from highperformancecoder/pythonise-tcl-scripts
createFilelog and compareFileLog python utilities.
- Loading branch information
Showing
183 changed files
with
509 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/python3 | ||
import sys | ||
from pathlib import Path | ||
here=str(Path(sys.argv[0]).parent) | ||
if here: sys.path.append(here) | ||
else: sys.path.append('.') | ||
|
||
from pyminsky import minsky | ||
|
||
iconDir=here+'/gui-js/apps/minsky-web/src/assets/images/icons/' | ||
minsky.histogramResource.setResource(iconDir+'histogram.svg') | ||
# make the background transparent | ||
minsky.canvas.backgroundColour({'a':0}) | ||
ops=minsky.availableOperations() | ||
ops.append("switch") | ||
for op in ops: | ||
# ignore some operations | ||
if op in ["numOps","constant","copy","ravel","integrate"]: continue | ||
|
||
if op=="switch": minsky.canvas.addSwitch() | ||
else: minsky.canvas.addOperation(op) | ||
if op=="userFunction": | ||
minsky.canvas.itemFocus().description('f(x,y)') | ||
print(minsky.canvas.itemFocus().description()) | ||
minsky.renderCanvasToPNG(iconDir+op+'.png') | ||
minsky.clearAllMaps() |
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Binary file added
BIN
+388 Bytes
gui-js/apps/minsky-web/src/assets/images/icons/linearRegression.png
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Binary file removed
BIN
-408 Bytes
gui-js/apps/minsky-web/src/assets/images/icons/runningProduct.gif
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/python3 | ||
|
||
# usage python3 compareFileLog.py <system.mky> <logfile> | ||
|
||
# compares the running of a minsky model <system.mky>, with a previously | ||
# run data log file <logfile>, created by "createFileLog" | ||
|
||
import sys | ||
import csv | ||
import re | ||
|
||
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 | ||
|
||
def fclose(x,y): | ||
if abs(x)>1e-30: | ||
return abs(x-y)/(abs(x)+abs(y)) < 1e-2 | ||
return abs(x-y) <= 1e-30 | ||
|
||
minsky.load(sys.argv[1]) | ||
|
||
ret=0 | ||
|
||
minsky.running(True) | ||
#provide seed to ensure repeatability | ||
minsky.srand(10) | ||
minsky.reset() | ||
|
||
valueDict={} | ||
def testValue(key, value): | ||
# check that any local variable of the same name matches out value | ||
if not any([fclose(value, x) for x in valueDict[key]]): | ||
print(sys.argv[1], "t=",minsky.t(),name," logged ",value) | ||
ret=1 | ||
|
||
with open(sys.argv[2]) as log: | ||
reader=csv.reader(log) | ||
# first line should specify no of steps to run | ||
row=next(reader) | ||
nsteps=int(row[1]) | ||
|
||
for step in range(nsteps): | ||
row=next(reader) | ||
minsky.step() | ||
|
||
if not fclose(minsky.t(),float(row[0])): | ||
print("t=",minsky.t()," logged ",row[0]) | ||
ret=1 | ||
|
||
|
||
for i in range(1,len(row),2): | ||
# stash these in an array of values, to represent multiple same named local variables | ||
if row[i] in valueDict: | ||
valueDict[row[i]].append(float(row[i+1])) | ||
else: | ||
valueDict[row[i]]=[float(row[i+1])] | ||
|
||
|
||
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()): | ||
testValue(f"{value.name()}|{i}",value.value()) | ||
else: | ||
testValue(value.name(),value.value()) | ||
|
||
exit(ret) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/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() | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
nsteps 10 | ||
3 {:FirmInt} 0.858866 {:Firms} 85.8866 {:IntLoan} 4.70502 {:Loan} 2.44978 {:Loans} 94.1004 {:Safe} 8.21384 {:Vault} 4.89956 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
6.02049 {:FirmInt} 0.783437 {:Firms} 78.3437 {:IntLoan} 4.93813 {:Loan} 0.118746 {:Loans} 98.7625 {:Safe} 20.4188 {:Vault} 0.237492 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
9.0989 {:FirmInt} 0.655612 {:Firms} 65.5612 {:IntLoan} 4.94946 {:Loan} 0.00542632 {:Loans} 98.9891 {:Safe} 33.4279 {:Vault} 0.0108526 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
12.597 {:FirmInt} 0.502844 {:Firms} 50.2844 {:IntLoan} 4.94998 {:Loan} 0.000158069 {:Loans} 98.9997 {:Safe} 48.7153 {:Vault} 0.000316138 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
17.2533 {:FirmInt} 0.290882 {:Firms} 29.0882 {:IntLoan} 4.95 {:Loan} -2.36134e-06 {:Loans} 99 {:Safe} 69.9118 {:Vault} -4.72268e-06 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
24.2533 {:FirmInt} -0.0469424 {:Firms} -4.69424 {:IntLoan} 4.95 {:Loan} 1.53463e-06 {:Loans} 99 {:Safe} 103.694 {:Vault} 3.06927e-06 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
31.2533 {:FirmInt} -0.409262 {:Firms} -40.9262 {:IntLoan} 4.95 {:Loan} -9.97358e-07 {:Loans} 99 {:Safe} 139.926 {:Vault} -1.99472e-06 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
38.2533 {:FirmInt} -0.797852 {:Firms} -79.7852 {:IntLoan} 4.95 {:Loan} 6.48183e-07 {:Loans} 99 {:Safe} 178.785 {:Vault} 1.29637e-06 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
45.2533 {:FirmInt} -1.21462 {:Firms} -121.462 {:IntLoan} 4.95 {:Loan} -4.21254e-07 {:Loans} 99 {:Safe} 220.462 {:Vault} -8.42508e-07 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
52.2533 {:FirmInt} -1.6616 {:Firms} -166.16 {:IntLoan} 4.95 {:Loan} 2.73773e-07 {:Loans} 99 {:Safe} 265.16 {:Vault} 5.47546e-07 {:rD} 0.01 {:rL} 0.05 {:τ<sub>vault</sub>} 0.5 | ||
nsteps, 10 | ||
3.0,":FirmInt",0.8588660509119618,":Firms",85.88660509119617,":IntLoan",4.705022218461891,":Loan",2.44977781538109,":Loans",94.10044436923782,":Safe",8.213839278041643,":Vault",4.89955563076218,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
6.020493780300365,":FirmInt",0.7834374049051636,":Firms",78.34374049051635,":IntLoan",4.938125375996015,":Loan",0.11874624003985976,":Loans",98.76250751992029,":Safe",20.418767029403934,":Vault",0.23749248007971951,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
9.098903060211793,":FirmInt",0.6556122409453465,":Firms",65.56122409453465,":IntLoan",4.949457367861261,":Loan",0.005426321387397959,":Loans",98.98914735722522,":Safe",33.427923262690555,":Vault",0.010852642774795918,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
12.597033634549913,":FirmInt",0.5028440931774055,":Firms",50.284409317740554,":IntLoan",4.949984193080265,":Loan",0.00015806919735001588,":Loans",98.9996838616053,":Safe",48.71527454386475,":Vault",0.00031613839470003176,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
17.253250340525874,":FirmInt",0.2908818721402956,":Firms",29.08818721402956,":IntLoan",4.9500002361337945,":Loan",-2.361337937732855e-06,":Loans",99.00000472267588,":Safe",69.91181750864634,":Vault",-4.72267587546571e-06,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
24.253250340525874,":FirmInt",-0.046942394056448004,":Firms",-4.6942394056448,":IntLoan",4.949999846536688,":Loan",1.5346331306456168e-06,":Loans",98.99999693073374,":Safe",103.69423633637857,":Vault",3.0692662612912335e-06,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
31.253250340525874,":FirmInt",-0.40926154384946795,":Firms",-40.92615438494679,":IntLoan",4.950000099735782,":Loan",-9.97357814839633e-07,":Loans",99.00000199471563,":Safe",139.92615637966247,":Vault",-1.994715629679266e-06,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
38.253250340525874,":FirmInt",-0.7978518868990342,":Firms",-79.78518868990342,":IntLoan",4.949999935181733,":Loan",6.481826769914769e-07,":Loans",98.99999870363465,":Safe",178.78518739353808,":Vault",1.2963653539829538e-06,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
45.253250340525874,":FirmInt",-1.214618150039562,":Firms",-121.4618150039562,":IntLoan",4.950000042125382,":Loan",-4.212538133261557e-07,":Loans",99.00000084250763,":Safe",220.46181584646382,":Vault",-8.425076266523114e-07,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 | ||
52.253250340525874,":FirmInt",-1.66160341522156,":Firms",-166.160341522156,":IntLoan",4.949999972622723,":Loan",2.7377278279863865e-07,":Loans",98.99999945245445,":Safe",265.1603409746104,":Vault",5.475455655972773e-07,":rD",0.01,":rL",0.05,":\tau_\mathrm{vault}",0.5 |
Oops, something went wrong.