Skip to content
Snippets Groups Projects
Commit 0ad369fd authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

early handling of tolerance and reference instead of runargs

parent 7202cf28
No related branches found
No related tags found
1 merge request!1699Provide infrastructure and convert examples for configuring Python example scripts using embedded Ruby (#554)
......@@ -79,7 +79,7 @@ function(test_equality example reference tolerance)
cmake_path(SET reffile NORMALIZE ${REFERENCE_DIR_EXAMPLES_MINI}/${reference})
add_test(NAME ${TARGET_NAME}
${launch_env} ${launch_py} ${MINI_SCRIPT} show=n datfile=${outfile}
run_tolerance=${tolerance} run_reference=${reffile}
tolerance=${tolerance} reference=${reffile}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_custom_target(${TARGET_NAME}
${launch_env} ${launch_py} ${PUBL_SCRIPT}
......
......@@ -52,11 +52,12 @@ rc('text', usetex=usetex_default)
plotargs = {}
simargs = {}
runargs = {}
datfile = None
figfile = None
saveformat = None
do_show = True
tolerance = None
reference = None
# ************************************************************************** #
# internal functions
......@@ -125,13 +126,11 @@ def get_axes_labels(result, units):
def check_or_save(result, fname, subname=""):
outfile = fname + subname + ".int.gz"
tolerance = runargs.get('tolerance')
reference = runargs.get('reference')
ba.writeDatafield(result, outfile)
if not tolerance or not reference:
return
reffile = reference + subname + ".int.gz"
ok = ba.filesAgree(outfile, reffile, float(tolerance))
ok = ba.filesAgree(outfile, reffile, tolerance)
if not ok:
raise Exception(f"=> no agreement between result and reference: {datfile} {reffile}")
......@@ -420,12 +419,10 @@ Support for bp.simargs will be removed in future releases.
Replace \"bp.simargs['{key[4:]}']\" by a hard-coded value
or by variable under your own control.
""")
elif key[0:4] == 'run_':
runargs[key[4:]] = tmp[key]
else:
plotargs[key] = tmp[key]
global datfile, figfile, do_show
global datfile, figfile, do_show, tolerance, reference
a = plotargs.pop('datfile', None)
if a:
datfile = a
......@@ -444,19 +441,29 @@ or by variable under your own control.
a = plotargs.pop('show', None)
if a:
if a == 'y':
print("DEBUG Y")
do_show = True
elif a == 'n':
print("DEBUG N")
do_show = False
else:
raise Exception("Parameter 'show' must be 'y' or 'n'")
a = plotargs.pop('tolerance', None)
if a:
tolerance = float(a)
a = plotargs.pop('reference', None)
if a:
reference = a
if (tolerance is not None and reference is None) or \
(tolerance is None and reference is not None):
raise Exception(
"If one of tolerance and reference is given, then the other must also be given")
def show_or_export():
if figfile:
plt.savefig(figfile, format=save_format, bbox_inches='tight')
print(f"DEBUG S={do_show}")
if do_show:
plt.show()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment