[770c98]: / Tests / Applications / run_SpinePressureTests.py

Download this file

65 lines (46 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Small script for updating the wilke test files with the new reference values
from pathlib import Path
import re
from anypytools import AnyPyProcess, macro_commands as mc
from pandas import Series
#%%
files = [
"test_SpinePressureLyingOnBack.any",
"test_SpinePressureSeatingRelaxed.any",
"test_SpinePressureSeatingStraitNoSupport.any",
"test_SpinePressureStanding.any",
"test_SpinePressureStandingFlexed.any",
"test_SpinePressureStandingLiftClose.any",
"test_SpinePressureStandingLiftFlexed.any",
"test_SpinePressureStandingLiftStretchedArms.any",
]
macros = []
for file in files:
macros.append(
[
mc.Load(file),
mc.OperationRun("Main.RunTest"),
mc.Dump("Main.Study.L5SacrumReac"),
]
)
#%%
app = AnyPyProcess(num_processes=4)
results = app.start_macro(macros)
#%%
REFVALUE_RE = re.compile(r"(AnyVar RefValue = )(?P<val>.+);")
results_table = {}
for file, result in zip(files, results):
file = Path(file)
val = round(result["Main.Study.L5SacrumReac"],1)
oldval = float(REFVALUE_RE.search(file.read_text()).group('val'))
status = 'OK' if 'ERROR' not in result else 'failed'
results_table[Path(file)] = val
print(f"{file.stem}: {val} ({status}: {oldval})")
# %%
for file, val in results_table.items():
text = file.read_text()
text = REFVALUE_RE.sub(fr"\g<1>{val};", text)
#print(text)
file.write_text(text)
# %%
Series(results_table.values()).to_clipboard(excel=True, index=False, header=False)