Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions library.html.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ Config: <pre>#config#</pre>
<script>
// A failed verification links its two .mat files (the differing variables of
// the result and of the reference) to the OMPlot page, which plots the tube
// comparison of each variable. The page needs absolute URLs. It cannot fetch
// files from file://, so there the link stays a download of the .mat file.
// comparison of each variable with the tolerances and tube of the verification.
// The page needs absolute URLs. It cannot fetch files from file://, so there
// the link stays a download of the .mat file.
if (location.protocol !== 'file:') {
const omplot = new URL(#omplot#, location.href).href;
for (const a of document.querySelectorAll('a[data-omplot]')) {
const abs = (f) => encodeURIComponent(new URL(f, location.href).href);
a.href = omplot + '?result=' + abs(a.dataset.omplot + '.mat') + '&reference=' + abs(a.dataset.omplot + '.ref.mat');
a.href = omplot + '?result=' + abs(a.dataset.omplot + '.mat') + '&reference=' + abs(a.dataset.omplot + '.ref.mat') + #omplotOptions#;
}
}
</script>
Expand Down
14 changes: 14 additions & 0 deletions shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ def simCodeTargetFromCommands(target, commands):
target = found[-1]
return target

def diffSimulationResultsOptions(conf):
"""The named arguments of the diffSimulationResults call that verifies a result."""
opts = [("relTol", conf["reference_reltol"]), ("relTolDiffMinMax", conf["reference_reltolDiffMinMax"])]
tube = conf.get("reference_tube")
# Without reference_tolerance, the csv-compare tubes get the default of diffSimulationResults, which is csv-compare's.
if tube not in ("rectangle", "ellipse"):
opts.append(("rangeDelta", conf["reference_rangeDelta"]))
elif "reference_tolerance" in conf:
opts.append(("rangeDelta", conf["reference_tolerance"]))
# Only passed when set: an omc without the tube argument fails the call.
if tube:
opts.append(("tube", tube))
return opts

def fixData(data,abortSimulationFlag,alarmFlag,overrideDefaults,defaultCustomCommands,extrasimflags,environmentTranslation,environmentSimulation):
data["configFromFile"] = dict(data)
for (key,default) in overrideDefaults:
Expand Down
3 changes: 2 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,8 @@ def publishLibrary(libname):
(u"#totalTime#", html.escape(str(datetime.timedelta(seconds=int(sum(s[3].get("exectime") or 0.0 for s in stats)))))),
(u"#config#", html.escape(json.dumps(conf["configFromFile"], indent=1, sort_keys=True))),
(u"#testsHTML#", testsHTML),
(u"#omplot#", json.dumps(args.omplot))
(u"#omplot#", json.dumps(args.omplot)),
(u"#omplotOptions#", json.dumps("".join("&%s=%s" % ("algorithm" if k == "tube" else k, v if k == "tube" else "%g" % v) for (k, v) in shared.diffSimulationResultsOptions(conf))))
)
open(os.path.join(stageRoot, "%s.html" % libname), "w").write(multiple_replace(htmltpl, *replacements))

Expand Down
11 changes: 2 additions & 9 deletions testmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,15 +1300,8 @@ def verifyAgainstReference(resFile, prefix, stat):
start=monotonic()
try:
# An empty diffPrefix: no per-variable CSV, the two filtered files below are the report.
# Only passed when set: an omc without the tube argument fails the call.
tube = conf.get("reference_tube")
# Without reference_tolerance, the csv-compare tubes get the default of diffSimulationResults, which is csv-compare's.
if tube in ("rectangle", "ellipse"):
rangeDelta = ',rangeDelta=%g' % conf["reference_tolerance"] if "reference_tolerance" in conf else ""
else:
rangeDelta = ',rangeDelta=%g' % conf["reference_rangeDelta"]
(referenceOK,diffVars) = sendExpressionTimeout(omc_new, 'diffSimulationResults("%s","%s","",relTol=%g,relTolDiffMinMax=%g%s%s)' %
(resFile, referenceFile, conf["reference_reltol"],conf["reference_reltolDiffMinMax"], rangeDelta, ',tube=OpenModelica.Scripting.TubeAlgorithm.%s' % tube if tube else ""), conf["ulimitOmc"])
diffArgs = "".join(",%s=%s" % (k, "OpenModelica.Scripting.TubeAlgorithm." + v if k == "tube" else "%g" % v) for (k, v) in shared.diffSimulationResultsOptions(conf))
(referenceOK,diffVars) = sendExpressionTimeout(omc_new, 'diffSimulationResults("%s","%s",""%s)' % (resFile, referenceFile, diffArgs), conf["ulimitOmc"])
except TimeoutError as e:
with open(errFile, 'a+') as fp:
fp.write("Timeout error for diffSimulationResults")
Expand Down
Loading