pyibis-ami 7.2.3__py3-none-any.whl → 7.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyibis_ami-7.2.3.dist-info → pyibis_ami-7.2.4.dist-info}/METADATA +133 -134
- pyibis_ami-7.2.4.dist-info/RECORD +27 -0
- {pyibis_ami-7.2.3.dist-info → pyibis_ami-7.2.4.dist-info}/WHEEL +1 -1
- {pyibis_ami-7.2.3.dist-info → pyibis_ami-7.2.4.dist-info}/licenses/LICENSE +8 -8
- pyibisami/IBIS_AMI_Checker.ipynb +1693 -1693
- pyibisami/IBIS_AMI_Tester.ipynb +1457 -1457
- pyibisami/__init__.py +22 -22
- pyibisami/__main__.py +7 -7
- pyibisami/ami/config.py +297 -297
- pyibisami/ami/generic.ami.em +20 -20
- pyibisami/ami/generic.ibs.em +176 -139
- pyibisami/ami/model.py +631 -631
- pyibisami/ami/parameter.py +325 -324
- pyibisami/ami/parser.py +680 -680
- pyibisami/ami/reserved_parameter_names.py +84 -84
- pyibisami/common.py +42 -42
- pyibisami/ibis/file.py +325 -325
- pyibisami/ibis/model.py +399 -399
- pyibisami/ibis/parser.py +525 -525
- pyibisami/tools/run_notebook.py +144 -144
- pyibisami/tools/run_tests.py +273 -273
- pyibisami/tools/test_results.xsl +42 -42
- pyibis_ami-7.2.3.dist-info/RECORD +0 -27
- {pyibis_ami-7.2.3.dist-info → pyibis_ami-7.2.4.dist-info}/entry_points.txt +0 -0
- {pyibis_ami-7.2.3.dist-info → pyibis_ami-7.2.4.dist-info}/top_level.txt +0 -0
pyibisami/tools/run_tests.py
CHANGED
@@ -1,273 +1,273 @@
|
|
1
|
-
#! /usr/bin/env python
|
2
|
-
|
3
|
-
"""Python tool for running several EmPy encoded tests on a IBIS-AMI model.
|
4
|
-
|
5
|
-
Original Author: David Banas
|
6
|
-
Original Date: July 20, 2012
|
7
|
-
|
8
|
-
Copyright (c) 2012 David Banas; All rights reserved World wide.
|
9
|
-
"""
|
10
|
-
|
11
|
-
import shutil
|
12
|
-
from os import chdir
|
13
|
-
from pathlib import Path
|
14
|
-
|
15
|
-
import click
|
16
|
-
import em
|
17
|
-
import numpy as np
|
18
|
-
|
19
|
-
from pyibisami.ami.model import AMIModel
|
20
|
-
from pyibisami.common import TestSweep
|
21
|
-
|
22
|
-
|
23
|
-
def plot_name(tst_name, n=0):
|
24
|
-
"""Plot name generator keeps multiple tests from overwriting each other's
|
25
|
-
plots."""
|
26
|
-
while True:
|
27
|
-
n += 1
|
28
|
-
yield f"{tst_name}_plot_{n}.png"
|
29
|
-
|
30
|
-
|
31
|
-
def hsv2rgb(hue=0, saturation=1.0, value=1.0):
|
32
|
-
"""Convert a HSV number to and RGB one."""
|
33
|
-
if value < 0:
|
34
|
-
value = 0.0
|
35
|
-
elif value > 1.0:
|
36
|
-
value = 1.0
|
37
|
-
if saturation == 0:
|
38
|
-
return (value, value, value)
|
39
|
-
if saturation < 0:
|
40
|
-
saturation = 0
|
41
|
-
elif saturation > 1.0:
|
42
|
-
saturation = 1.0
|
43
|
-
hue = hue % 360
|
44
|
-
H = float(hue)
|
45
|
-
S = float(saturation)
|
46
|
-
V = float(value)
|
47
|
-
H_i = np.floor(H / 60.0)
|
48
|
-
f = (H / 60.0) - H_i
|
49
|
-
p = V * (1.0 - S)
|
50
|
-
q = V * (1.0 - f * S)
|
51
|
-
t = V * (1.0 - (1.0 - f) * S)
|
52
|
-
if H_i == 0:
|
53
|
-
R = V
|
54
|
-
G = t
|
55
|
-
B = p
|
56
|
-
elif H_i == 1:
|
57
|
-
R = q
|
58
|
-
G = V
|
59
|
-
B = p
|
60
|
-
elif H_i == 2:
|
61
|
-
R = p
|
62
|
-
G = V
|
63
|
-
B = t
|
64
|
-
elif H_i == 3:
|
65
|
-
R = p
|
66
|
-
G = q
|
67
|
-
B = V
|
68
|
-
elif H_i == 4:
|
69
|
-
R = t
|
70
|
-
G = p
|
71
|
-
B = V
|
72
|
-
else:
|
73
|
-
R = V
|
74
|
-
G = p
|
75
|
-
B = q
|
76
|
-
return (R, G, B)
|
77
|
-
|
78
|
-
|
79
|
-
def color_picker(num_hues=3, first_hue=0):
|
80
|
-
"""Yields pairs of colors having the same hue, but different intensities.
|
81
|
-
|
82
|
-
The first color is fully bright and saturated, and the second is
|
83
|
-
half bright and half saturated. Originally, the intent was to have
|
84
|
-
the second color used for the `reference` waveform in plots.
|
85
|
-
"""
|
86
|
-
hue = first_hue
|
87
|
-
while True:
|
88
|
-
yield (hsv2rgb(hue, 1.0, 1.0), hsv2rgb(hue, 0.75, 0.75))
|
89
|
-
hue += 360 // num_hues
|
90
|
-
|
91
|
-
|
92
|
-
def expand_params(input_parameters: str) -> list[TestSweep]:
|
93
|
-
"""
|
94
|
-
Take the command line input and convert it into usable parameter sweeps.
|
95
|
-
|
96
|
-
We can pass in a file, directory, or raw string here.
|
97
|
-
Handle all three cases.
|
98
|
-
"""
|
99
|
-
if Path(input_parameters).exists():
|
100
|
-
if Path(input_parameters).is_file():
|
101
|
-
cfg_files = [Path(input_parameters)]
|
102
|
-
else:
|
103
|
-
cfg_files = list(Path(input_parameters).glob("*.run"))
|
104
|
-
param_sweeps = []
|
105
|
-
for cfg_filename in cfg_files:
|
106
|
-
cfg_name = cfg_filename.stem
|
107
|
-
param_list = []
|
108
|
-
with open(cfg_filename, "rt", encoding="utf-8") as cfg_file:
|
109
|
-
description = cfg_file.readline()
|
110
|
-
expr = ""
|
111
|
-
for line in cfg_file:
|
112
|
-
toks = line.split()
|
113
|
-
if not toks or toks[0].startswith("#"):
|
114
|
-
continue
|
115
|
-
expr += line
|
116
|
-
if toks[-1] == "\\": # Test for line continuation.
|
117
|
-
expr = expr.rstrip("\\\n")
|
118
|
-
else:
|
119
|
-
param_list.append(eval(compile(expr, cfg_filename, "eval"))) # pylint: disable=eval-used
|
120
|
-
expr = ""
|
121
|
-
param_sweeps.append((cfg_name, description, param_list))
|
122
|
-
else:
|
123
|
-
try:
|
124
|
-
param_sweeps = eval(input_parameters) # pylint: disable=eval-used
|
125
|
-
except Exception as err:
|
126
|
-
raise ValueError(f"input_parameters: {input_parameters}") from err
|
127
|
-
return param_sweeps
|
128
|
-
|
129
|
-
|
130
|
-
def run_tests(**kwargs): # pylint: disable=too-many-locals
|
131
|
-
"""Provide a thin wrapper around the click interface so that we can test
|
132
|
-
the operation."""
|
133
|
-
|
134
|
-
# Fetch options and cast into local independent variables.
|
135
|
-
test_dir = Path(kwargs["test_dir"]).resolve()
|
136
|
-
ref_dir = Path(kwargs["ref_dir"]).resolve()
|
137
|
-
if not ref_dir.exists():
|
138
|
-
ref_dir = None
|
139
|
-
model = Path(kwargs["model"]).resolve()
|
140
|
-
out_dir = Path(kwargs["out_dir"]).resolve()
|
141
|
-
out_dir.mkdir(exist_ok=True)
|
142
|
-
xml_filename = out_dir.joinpath(kwargs["xml_file"])
|
143
|
-
|
144
|
-
# Some browsers demand that the stylesheet be located in the same
|
145
|
-
# folder as the *.XML file. Besides, this allows the model tester
|
146
|
-
# to zip up her 'test_results' directory and send it off to
|
147
|
-
# someone, whom may not have the PyIBIS-AMI package installed.
|
148
|
-
#
|
149
|
-
# Note: To avoid this issue entirely, incorporate `xsltproc` into your build flow.
|
150
|
-
shutil.copy(str(Path(__file__).parent.joinpath("test_results.xsl")), str(out_dir))
|
151
|
-
|
152
|
-
print(f"Testing model: {model}")
|
153
|
-
print(f"Using tests in: {test_dir}")
|
154
|
-
params = expand_params(kwargs["params"])
|
155
|
-
|
156
|
-
# Run the tests.
|
157
|
-
print(f"Sending XHTML output to: {xml_filename}")
|
158
|
-
with open(xml_filename, "w", encoding="utf-8") as xml_file:
|
159
|
-
xml_file.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
|
160
|
-
xml_file.write('<?xml-stylesheet type="text/xsl" href="test_results.xsl"?>\n')
|
161
|
-
xml_file.write("<tests>\n")
|
162
|
-
if kwargs["tests"]:
|
163
|
-
tests = kwargs["tests"]
|
164
|
-
else:
|
165
|
-
tests = list(test_dir.glob("*.em"))
|
166
|
-
for test in tests:
|
167
|
-
test_ = test.stem
|
168
|
-
print(f"Running test: {test_} ...")
|
169
|
-
theModel = AMIModel(str(model))
|
170
|
-
plot_names = plot_name(test_)
|
171
|
-
for cfg_item in params:
|
172
|
-
cfg_name = cfg_item[0]
|
173
|
-
print(f"\tRunning test configuration: {cfg_name} ...")
|
174
|
-
description = cfg_item[1]
|
175
|
-
param_list = cfg_item[2]
|
176
|
-
colors = color_picker(num_hues=len(param_list))
|
177
|
-
with open(xml_filename, "a", encoding="utf-8") as xml_file:
|
178
|
-
interpreter = em.Interpreter(
|
179
|
-
output=xml_file,
|
180
|
-
globals={
|
181
|
-
"name": f"{test_} ({cfg_name})",
|
182
|
-
"model": theModel,
|
183
|
-
"data": param_list,
|
184
|
-
"plot_names": plot_names,
|
185
|
-
"description": description,
|
186
|
-
"plot_colors": colors,
|
187
|
-
"ref_dir": ref_dir,
|
188
|
-
},
|
189
|
-
)
|
190
|
-
try:
|
191
|
-
cwd = Path().cwd()
|
192
|
-
chdir(out_dir) # So that the images are saved in the output directory.
|
193
|
-
with open(Path(test_dir, test), encoding="utf-8") as test_file:
|
194
|
-
interpreter.file(test_file)
|
195
|
-
chdir(cwd)
|
196
|
-
except Exception as err: # pylint: disable=broad-exception-caught
|
197
|
-
print("\t\t", err)
|
198
|
-
finally:
|
199
|
-
interpreter.shutdown()
|
200
|
-
print("Test:", test_, "complete.")
|
201
|
-
with open(xml_filename, "a", encoding="utf-8") as xml_file:
|
202
|
-
xml_file.write("</tests>\n")
|
203
|
-
|
204
|
-
print(f"Please, open file, `{xml_filename}` in a Web browser, in order to view the test results.")
|
205
|
-
|
206
|
-
|
207
|
-
@click.command(context_settings={"ignore_unknown_options": True, "help_option_names": ["-h", "--help"]})
|
208
|
-
@click.option(
|
209
|
-
"--model", "-m", default="libami.so", type=click.Path(exists=True), help="Sets the AMI model DLL file name."
|
210
|
-
)
|
211
|
-
@click.option(
|
212
|
-
"--test_dir",
|
213
|
-
"-t",
|
214
|
-
default="tests",
|
215
|
-
type=click.Path(),
|
216
|
-
help="Sets the name of the directory from which tests are taken.",
|
217
|
-
)
|
218
|
-
@click.option(
|
219
|
-
"--params",
|
220
|
-
"-p",
|
221
|
-
default='[("cfg_dflt", "default", [("default", ({"root_name":"testAMI"},{})),]),]',
|
222
|
-
help='List of lists of model configurations. Format: <filename> or [(name, [(label, ({AMI params., in "key:val" format},{Model params., in "key:val" format})), ...]), ...]',
|
223
|
-
)
|
224
|
-
@click.option(
|
225
|
-
"--xml_file",
|
226
|
-
"-x",
|
227
|
-
default="test_results.xml",
|
228
|
-
help="Sets the name of the XML output file. You should load this file into your Web browser after the program completion.",
|
229
|
-
)
|
230
|
-
@click.option(
|
231
|
-
"--ref_dir",
|
232
|
-
"-r",
|
233
|
-
default="refs",
|
234
|
-
type=click.Path(),
|
235
|
-
help="Sets the name of the directory from which reference waveforms are taken.",
|
236
|
-
)
|
237
|
-
@click.option(
|
238
|
-
"--out_dir",
|
239
|
-
"-o",
|
240
|
-
default="test_results",
|
241
|
-
type=click.Path(),
|
242
|
-
help="Sets the name of the directory in which to place the results.",
|
243
|
-
)
|
244
|
-
@click.argument("tests", nargs=-1, type=click.UNPROCESSED)
|
245
|
-
@click.version_option()
|
246
|
-
def main(**kwargs):
|
247
|
-
"""Run a series of tests on a AMI model DLL file.
|
248
|
-
|
249
|
-
If no tests are specified on the command line, run all tests found
|
250
|
-
in `test_dir'. (See `-t' option.)
|
251
|
-
|
252
|
-
usage: %prog [options] [test1 [test2 ...]]
|
253
|
-
|
254
|
-
Tests are written in the EmPy templating language, and produce XML
|
255
|
-
output. (See the examples provided in the `examples' directory of the
|
256
|
-
`pyibisami' Python package.)
|
257
|
-
|
258
|
-
Test results should be viewed by loading the XML output file into
|
259
|
-
a Web browser. By default, the XML output file refers to the supplied
|
260
|
-
XSLT file, `test_results.xsl'. It is possible that you may need to
|
261
|
-
copy this file from the pyibisami package directory to your local
|
262
|
-
working directory, in order to avoid file loading errors in your
|
263
|
-
Web browser.
|
264
|
-
|
265
|
-
If your browser's security settings disallow the use of an XSLT style
|
266
|
-
sheet when processing XML then use the `xsltproc` utility to convert
|
267
|
-
the XML/XSLT to HTML before viewing in your browser.
|
268
|
-
"""
|
269
|
-
run_tests(**kwargs)
|
270
|
-
|
271
|
-
|
272
|
-
if __name__ == "__main__":
|
273
|
-
main() # pylint: disable=no-value-for-parameter
|
1
|
+
#! /usr/bin/env python
|
2
|
+
|
3
|
+
"""Python tool for running several EmPy encoded tests on a IBIS-AMI model.
|
4
|
+
|
5
|
+
Original Author: David Banas
|
6
|
+
Original Date: July 20, 2012
|
7
|
+
|
8
|
+
Copyright (c) 2012 David Banas; All rights reserved World wide.
|
9
|
+
"""
|
10
|
+
|
11
|
+
import shutil
|
12
|
+
from os import chdir
|
13
|
+
from pathlib import Path
|
14
|
+
|
15
|
+
import click
|
16
|
+
import em
|
17
|
+
import numpy as np
|
18
|
+
|
19
|
+
from pyibisami.ami.model import AMIModel
|
20
|
+
from pyibisami.common import TestSweep
|
21
|
+
|
22
|
+
|
23
|
+
def plot_name(tst_name, n=0):
|
24
|
+
"""Plot name generator keeps multiple tests from overwriting each other's
|
25
|
+
plots."""
|
26
|
+
while True:
|
27
|
+
n += 1
|
28
|
+
yield f"{tst_name}_plot_{n}.png"
|
29
|
+
|
30
|
+
|
31
|
+
def hsv2rgb(hue=0, saturation=1.0, value=1.0):
|
32
|
+
"""Convert a HSV number to and RGB one."""
|
33
|
+
if value < 0:
|
34
|
+
value = 0.0
|
35
|
+
elif value > 1.0:
|
36
|
+
value = 1.0
|
37
|
+
if saturation == 0:
|
38
|
+
return (value, value, value)
|
39
|
+
if saturation < 0:
|
40
|
+
saturation = 0
|
41
|
+
elif saturation > 1.0:
|
42
|
+
saturation = 1.0
|
43
|
+
hue = hue % 360
|
44
|
+
H = float(hue)
|
45
|
+
S = float(saturation)
|
46
|
+
V = float(value)
|
47
|
+
H_i = np.floor(H / 60.0)
|
48
|
+
f = (H / 60.0) - H_i
|
49
|
+
p = V * (1.0 - S)
|
50
|
+
q = V * (1.0 - f * S)
|
51
|
+
t = V * (1.0 - (1.0 - f) * S)
|
52
|
+
if H_i == 0:
|
53
|
+
R = V
|
54
|
+
G = t
|
55
|
+
B = p
|
56
|
+
elif H_i == 1:
|
57
|
+
R = q
|
58
|
+
G = V
|
59
|
+
B = p
|
60
|
+
elif H_i == 2:
|
61
|
+
R = p
|
62
|
+
G = V
|
63
|
+
B = t
|
64
|
+
elif H_i == 3:
|
65
|
+
R = p
|
66
|
+
G = q
|
67
|
+
B = V
|
68
|
+
elif H_i == 4:
|
69
|
+
R = t
|
70
|
+
G = p
|
71
|
+
B = V
|
72
|
+
else:
|
73
|
+
R = V
|
74
|
+
G = p
|
75
|
+
B = q
|
76
|
+
return (R, G, B)
|
77
|
+
|
78
|
+
|
79
|
+
def color_picker(num_hues=3, first_hue=0):
|
80
|
+
"""Yields pairs of colors having the same hue, but different intensities.
|
81
|
+
|
82
|
+
The first color is fully bright and saturated, and the second is
|
83
|
+
half bright and half saturated. Originally, the intent was to have
|
84
|
+
the second color used for the `reference` waveform in plots.
|
85
|
+
"""
|
86
|
+
hue = first_hue
|
87
|
+
while True:
|
88
|
+
yield (hsv2rgb(hue, 1.0, 1.0), hsv2rgb(hue, 0.75, 0.75))
|
89
|
+
hue += 360 // num_hues
|
90
|
+
|
91
|
+
|
92
|
+
def expand_params(input_parameters: str) -> list[TestSweep]:
|
93
|
+
"""
|
94
|
+
Take the command line input and convert it into usable parameter sweeps.
|
95
|
+
|
96
|
+
We can pass in a file, directory, or raw string here.
|
97
|
+
Handle all three cases.
|
98
|
+
"""
|
99
|
+
if Path(input_parameters).exists():
|
100
|
+
if Path(input_parameters).is_file():
|
101
|
+
cfg_files = [Path(input_parameters)]
|
102
|
+
else:
|
103
|
+
cfg_files = list(Path(input_parameters).glob("*.run"))
|
104
|
+
param_sweeps = []
|
105
|
+
for cfg_filename in cfg_files:
|
106
|
+
cfg_name = cfg_filename.stem
|
107
|
+
param_list = []
|
108
|
+
with open(cfg_filename, "rt", encoding="utf-8") as cfg_file:
|
109
|
+
description = cfg_file.readline()
|
110
|
+
expr = ""
|
111
|
+
for line in cfg_file:
|
112
|
+
toks = line.split()
|
113
|
+
if not toks or toks[0].startswith("#"):
|
114
|
+
continue
|
115
|
+
expr += line
|
116
|
+
if toks[-1] == "\\": # Test for line continuation.
|
117
|
+
expr = expr.rstrip("\\\n")
|
118
|
+
else:
|
119
|
+
param_list.append(eval(compile(expr, cfg_filename, "eval"))) # pylint: disable=eval-used
|
120
|
+
expr = ""
|
121
|
+
param_sweeps.append((cfg_name, description, param_list))
|
122
|
+
else:
|
123
|
+
try:
|
124
|
+
param_sweeps = eval(input_parameters) # pylint: disable=eval-used
|
125
|
+
except Exception as err:
|
126
|
+
raise ValueError(f"input_parameters: {input_parameters}") from err
|
127
|
+
return param_sweeps
|
128
|
+
|
129
|
+
|
130
|
+
def run_tests(**kwargs): # pylint: disable=too-many-locals
|
131
|
+
"""Provide a thin wrapper around the click interface so that we can test
|
132
|
+
the operation."""
|
133
|
+
|
134
|
+
# Fetch options and cast into local independent variables.
|
135
|
+
test_dir = Path(kwargs["test_dir"]).resolve()
|
136
|
+
ref_dir = Path(kwargs["ref_dir"]).resolve()
|
137
|
+
if not ref_dir.exists():
|
138
|
+
ref_dir = None
|
139
|
+
model = Path(kwargs["model"]).resolve()
|
140
|
+
out_dir = Path(kwargs["out_dir"]).resolve()
|
141
|
+
out_dir.mkdir(exist_ok=True)
|
142
|
+
xml_filename = out_dir.joinpath(kwargs["xml_file"])
|
143
|
+
|
144
|
+
# Some browsers demand that the stylesheet be located in the same
|
145
|
+
# folder as the *.XML file. Besides, this allows the model tester
|
146
|
+
# to zip up her 'test_results' directory and send it off to
|
147
|
+
# someone, whom may not have the PyIBIS-AMI package installed.
|
148
|
+
#
|
149
|
+
# Note: To avoid this issue entirely, incorporate `xsltproc` into your build flow.
|
150
|
+
shutil.copy(str(Path(__file__).parent.joinpath("test_results.xsl")), str(out_dir))
|
151
|
+
|
152
|
+
print(f"Testing model: {model}")
|
153
|
+
print(f"Using tests in: {test_dir}")
|
154
|
+
params = expand_params(kwargs["params"])
|
155
|
+
|
156
|
+
# Run the tests.
|
157
|
+
print(f"Sending XHTML output to: {xml_filename}")
|
158
|
+
with open(xml_filename, "w", encoding="utf-8") as xml_file:
|
159
|
+
xml_file.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
|
160
|
+
xml_file.write('<?xml-stylesheet type="text/xsl" href="test_results.xsl"?>\n')
|
161
|
+
xml_file.write("<tests>\n")
|
162
|
+
if kwargs["tests"]:
|
163
|
+
tests = kwargs["tests"]
|
164
|
+
else:
|
165
|
+
tests = list(test_dir.glob("*.em"))
|
166
|
+
for test in tests:
|
167
|
+
test_ = test.stem
|
168
|
+
print(f"Running test: {test_} ...")
|
169
|
+
theModel = AMIModel(str(model))
|
170
|
+
plot_names = plot_name(test_)
|
171
|
+
for cfg_item in params:
|
172
|
+
cfg_name = cfg_item[0]
|
173
|
+
print(f"\tRunning test configuration: {cfg_name} ...")
|
174
|
+
description = cfg_item[1]
|
175
|
+
param_list = cfg_item[2]
|
176
|
+
colors = color_picker(num_hues=len(param_list))
|
177
|
+
with open(xml_filename, "a", encoding="utf-8") as xml_file:
|
178
|
+
interpreter = em.Interpreter(
|
179
|
+
output=xml_file,
|
180
|
+
globals={
|
181
|
+
"name": f"{test_} ({cfg_name})",
|
182
|
+
"model": theModel,
|
183
|
+
"data": param_list,
|
184
|
+
"plot_names": plot_names,
|
185
|
+
"description": description,
|
186
|
+
"plot_colors": colors,
|
187
|
+
"ref_dir": ref_dir,
|
188
|
+
},
|
189
|
+
)
|
190
|
+
try:
|
191
|
+
cwd = Path().cwd()
|
192
|
+
chdir(out_dir) # So that the images are saved in the output directory.
|
193
|
+
with open(Path(test_dir, test), encoding="utf-8") as test_file:
|
194
|
+
interpreter.file(test_file)
|
195
|
+
chdir(cwd)
|
196
|
+
except Exception as err: # pylint: disable=broad-exception-caught
|
197
|
+
print("\t\t", err)
|
198
|
+
finally:
|
199
|
+
interpreter.shutdown()
|
200
|
+
print("Test:", test_, "complete.")
|
201
|
+
with open(xml_filename, "a", encoding="utf-8") as xml_file:
|
202
|
+
xml_file.write("</tests>\n")
|
203
|
+
|
204
|
+
print(f"Please, open file, `{xml_filename}` in a Web browser, in order to view the test results.")
|
205
|
+
|
206
|
+
|
207
|
+
@click.command(context_settings={"ignore_unknown_options": True, "help_option_names": ["-h", "--help"]})
|
208
|
+
@click.option(
|
209
|
+
"--model", "-m", default="libami.so", type=click.Path(exists=True), help="Sets the AMI model DLL file name."
|
210
|
+
)
|
211
|
+
@click.option(
|
212
|
+
"--test_dir",
|
213
|
+
"-t",
|
214
|
+
default="tests",
|
215
|
+
type=click.Path(),
|
216
|
+
help="Sets the name of the directory from which tests are taken.",
|
217
|
+
)
|
218
|
+
@click.option(
|
219
|
+
"--params",
|
220
|
+
"-p",
|
221
|
+
default='[("cfg_dflt", "default", [("default", ({"root_name":"testAMI"},{})),]),]',
|
222
|
+
help='List of lists of model configurations. Format: <filename> or [(name, [(label, ({AMI params., in "key:val" format},{Model params., in "key:val" format})), ...]), ...]',
|
223
|
+
)
|
224
|
+
@click.option(
|
225
|
+
"--xml_file",
|
226
|
+
"-x",
|
227
|
+
default="test_results.xml",
|
228
|
+
help="Sets the name of the XML output file. You should load this file into your Web browser after the program completion.",
|
229
|
+
)
|
230
|
+
@click.option(
|
231
|
+
"--ref_dir",
|
232
|
+
"-r",
|
233
|
+
default="refs",
|
234
|
+
type=click.Path(),
|
235
|
+
help="Sets the name of the directory from which reference waveforms are taken.",
|
236
|
+
)
|
237
|
+
@click.option(
|
238
|
+
"--out_dir",
|
239
|
+
"-o",
|
240
|
+
default="test_results",
|
241
|
+
type=click.Path(),
|
242
|
+
help="Sets the name of the directory in which to place the results.",
|
243
|
+
)
|
244
|
+
@click.argument("tests", nargs=-1, type=click.UNPROCESSED)
|
245
|
+
@click.version_option()
|
246
|
+
def main(**kwargs):
|
247
|
+
"""Run a series of tests on a AMI model DLL file.
|
248
|
+
|
249
|
+
If no tests are specified on the command line, run all tests found
|
250
|
+
in `test_dir'. (See `-t' option.)
|
251
|
+
|
252
|
+
usage: %prog [options] [test1 [test2 ...]]
|
253
|
+
|
254
|
+
Tests are written in the EmPy templating language, and produce XML
|
255
|
+
output. (See the examples provided in the `examples' directory of the
|
256
|
+
`pyibisami' Python package.)
|
257
|
+
|
258
|
+
Test results should be viewed by loading the XML output file into
|
259
|
+
a Web browser. By default, the XML output file refers to the supplied
|
260
|
+
XSLT file, `test_results.xsl'. It is possible that you may need to
|
261
|
+
copy this file from the pyibisami package directory to your local
|
262
|
+
working directory, in order to avoid file loading errors in your
|
263
|
+
Web browser.
|
264
|
+
|
265
|
+
If your browser's security settings disallow the use of an XSLT style
|
266
|
+
sheet when processing XML then use the `xsltproc` utility to convert
|
267
|
+
the XML/XSLT to HTML before viewing in your browser.
|
268
|
+
"""
|
269
|
+
run_tests(**kwargs)
|
270
|
+
|
271
|
+
|
272
|
+
if __name__ == "__main__":
|
273
|
+
main() # pylint: disable=no-value-for-parameter
|
pyibisami/tools/test_results.xsl
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2
|
-
|
3
|
-
<xsl:stylesheet version="1.0"
|
4
|
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
5
|
-
|
6
|
-
<xsl:template match="/">
|
7
|
-
<html>
|
8
|
-
<body>
|
9
|
-
<h2><a name="summary">Test Results - Summary</a></h2>
|
10
|
-
<table border="1">
|
11
|
-
<tr bgcolor="#9acd32">
|
12
|
-
<th>Test Name</th>
|
13
|
-
<th>Result</th>
|
14
|
-
<th>Description</th>
|
15
|
-
</tr>
|
16
|
-
<xsl:for-each select="tests/test">
|
17
|
-
<tr>
|
18
|
-
<td><a href="#{name}"><xsl:value-of select="name"/></a></td>
|
19
|
-
<td><xsl:value-of select="result"/></td>
|
20
|
-
<td><xsl:value-of select="description"/></td>
|
21
|
-
</tr>
|
22
|
-
</xsl:for-each>
|
23
|
-
</table>
|
24
|
-
<h2>Test Results - Details</h2>
|
25
|
-
<xsl:for-each select="tests/test">
|
26
|
-
<h3><a name="{name}"><xsl:value-of select="name"/> - <xsl:value-of select="description"/></a></h3>
|
27
|
-
<div style="overflow:auto;height:200px;background-color:lightgray;">
|
28
|
-
<xsl:for-each select="output/block[@type='text']">
|
29
|
-
<h4><xsl:value-of select="./@name"/></h4>
|
30
|
-
<pre><xsl:value-of select="."/></pre>
|
31
|
-
</xsl:for-each>
|
32
|
-
</div>
|
33
|
-
<xsl:for-each select="output/block[@type='image']">
|
34
|
-
<img src="{.}"/>
|
35
|
-
</xsl:for-each>
|
36
|
-
<p><a href="#summary">Back to top.</a></p>
|
37
|
-
</xsl:for-each>
|
38
|
-
</body>
|
39
|
-
</html>
|
40
|
-
</xsl:template>
|
41
|
-
|
42
|
-
</xsl:stylesheet>
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2
|
+
|
3
|
+
<xsl:stylesheet version="1.0"
|
4
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
5
|
+
|
6
|
+
<xsl:template match="/">
|
7
|
+
<html>
|
8
|
+
<body>
|
9
|
+
<h2><a name="summary">Test Results - Summary</a></h2>
|
10
|
+
<table border="1">
|
11
|
+
<tr bgcolor="#9acd32">
|
12
|
+
<th>Test Name</th>
|
13
|
+
<th>Result</th>
|
14
|
+
<th>Description</th>
|
15
|
+
</tr>
|
16
|
+
<xsl:for-each select="tests/test">
|
17
|
+
<tr>
|
18
|
+
<td><a href="#{name}"><xsl:value-of select="name"/></a></td>
|
19
|
+
<td><xsl:value-of select="result"/></td>
|
20
|
+
<td><xsl:value-of select="description"/></td>
|
21
|
+
</tr>
|
22
|
+
</xsl:for-each>
|
23
|
+
</table>
|
24
|
+
<h2>Test Results - Details</h2>
|
25
|
+
<xsl:for-each select="tests/test">
|
26
|
+
<h3><a name="{name}"><xsl:value-of select="name"/> - <xsl:value-of select="description"/></a></h3>
|
27
|
+
<div style="overflow:auto;height:200px;background-color:lightgray;">
|
28
|
+
<xsl:for-each select="output/block[@type='text']">
|
29
|
+
<h4><xsl:value-of select="./@name"/></h4>
|
30
|
+
<pre><xsl:value-of select="."/></pre>
|
31
|
+
</xsl:for-each>
|
32
|
+
</div>
|
33
|
+
<xsl:for-each select="output/block[@type='image']">
|
34
|
+
<img src="{.}"/>
|
35
|
+
</xsl:for-each>
|
36
|
+
<p><a href="#summary">Back to top.</a></p>
|
37
|
+
</xsl:for-each>
|
38
|
+
</body>
|
39
|
+
</html>
|
40
|
+
</xsl:template>
|
41
|
+
|
42
|
+
</xsl:stylesheet>
|
@@ -1,27 +0,0 @@
|
|
1
|
-
pyibis_ami-7.2.3.dist-info/licenses/LICENSE,sha256=I5JPpJOEHcYTZORGLbHda6gw4uuyEeBBdOlw9ZVgUTw,1301
|
2
|
-
pyibisami/IBIS_AMI_Checker.ipynb,sha256=vVIwLIo6GXG2ZC4vHG51nFaQmv9QZq2GEO1UOLX0bFI,1391858
|
3
|
-
pyibisami/IBIS_AMI_Tester.ipynb,sha256=PwLZ0suZD10V6XTJR2FRG-hBWj_nqgAwjudHg7A3yHM,785956
|
4
|
-
pyibisami/__init__.py,sha256=TZ5plqALCEzx23lqr31UYd_eM9tXjb3Uyn7W2X2ibXM,690
|
5
|
-
pyibisami/__main__.py,sha256=Jfo1w_o_mzusGPK0gdFYBfAlvnWyqzZYVn316ofe6ic,324
|
6
|
-
pyibisami/common.py,sha256=mxmYha24T3Qmf6lDhrCMqs2ckUk3LvRtBsfZeO7d5_U,1224
|
7
|
-
pyibisami/ami/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
pyibisami/ami/config.py,sha256=B1wvgxEzn4Kmld0b7175fKIy5vYyj5SvrN_EDKMcUpQ,11101
|
9
|
-
pyibisami/ami/generic.ami.em,sha256=s00qzshBk_gH0A4xT36ycQSHS0MgLEZLmrwEpQv9jIY,519
|
10
|
-
pyibisami/ami/generic.ibs.em,sha256=SjIZT3ISg_stfwBSrHi62KeqXihzOsIOZze5xzMFipE,5930
|
11
|
-
pyibisami/ami/model.py,sha256=iMCgd4_LCWeKcFqwof1dx_Yg6uQYLdtXprtg0XhUjek,25613
|
12
|
-
pyibisami/ami/parameter.py,sha256=HlSIwiLazdlZv4td6Q3HcvmsV-8aIASBCBh1k5jnrmc,11641
|
13
|
-
pyibisami/ami/parser.py,sha256=C34ISULYtOQYAsw18fDdFTDhKBNdoI4kOuvmOexqroU,26468
|
14
|
-
pyibisami/ami/reserved_parameter_names.py,sha256=XTqDtJyN8cinYlJ4kd7b46-2TmNp_r0Qxbm_vuJnLWY,1870
|
15
|
-
pyibisami/ibis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
pyibisami/ibis/file.py,sha256=7bUIeffytX3WxvOmwYGklCnqGF2tG4vPLhqfZprU-Og,12389
|
17
|
-
pyibisami/ibis/model.py,sha256=x6ad2E4JfoZ4B26NTxS2xRjPKO3LmLOKjpWvY9gXGNM,16748
|
18
|
-
pyibisami/ibis/parser.py,sha256=g3nuB--O2HrBh1gp22KZZtbU8W9tUYFApQxt5WJvaCY,14136
|
19
|
-
pyibisami/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
-
pyibisami/tools/run_notebook.py,sha256=B8WEQkfP8umniwHN8sSrLPPv5Hrh7betykXaw4D2fxI,5594
|
21
|
-
pyibisami/tools/run_tests.py,sha256=oY948sQ4Uos3nNQGdBNpAxv5x521_6K2tXGWWGoxdhk,9617
|
22
|
-
pyibisami/tools/test_results.xsl,sha256=CW3RdCml9jn2nBiZOxqVtXEqnWM-lODHzeDkESmWwBg,1704
|
23
|
-
pyibis_ami-7.2.3.dist-info/METADATA,sha256=2aoM4EGiLlM6JPruQYEN-K2G9grjeaj6X5FiTkZifgw,5407
|
24
|
-
pyibis_ami-7.2.3.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
25
|
-
pyibis_ami-7.2.3.dist-info/entry_points.txt,sha256=x2QobJi2Pu25LgUeWg60XZzOWH8j2R60oWGN-1Z7uVA,149
|
26
|
-
pyibis_ami-7.2.3.dist-info/top_level.txt,sha256=k2KfR4t4tJ47HrnzvSh77w9N2Xyz8_uUusJLbqXK0g4,10
|
27
|
-
pyibis_ami-7.2.3.dist-info/RECORD,,
|
File without changes
|