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

If possible, set figure size as in script

parent 68b1dd79
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ The check passes successfully if the example runs without exceptions thrown and
generates non-zero-size intensity image.
"""
import matplotlib, os, sys
import matplotlib, os, re, sys
matplotlib.use('Agg')
from matplotlib import pyplot as plt
......@@ -40,12 +40,13 @@ def run_example(filename, output_dir):
if not os.path.exists(filename):
raise Exception("Example script '" + filename + "' not found")
print("Input script: " + filename, flush=True)
with open(filename, 'rb') as file:
with open(filename, 'r') as file:
script = file.read()
if "AllFormFactorsAvailable" in filename:
figsize = (1024, 768)
else:
m = re.search(r'plt\.figure\(.+?figsize=\((.+?),(.+?)\)', script)
if m: # set figure size as in script
figsize = (float(m.group(1)), float(m.group(2)))
else: # script does not specify figure size
figsize = (640, 480)
fig = get_figure(figsize)
......
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