Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6ac413a
pytest migration: generate commands exactly matching those of smlp_re…
fbrausse Mar 18, 2026
ed6edde
pytest lib: compare output files like smlp_regr.py does (w/o interact…
fbrausse Mar 19, 2026
d70dd8c
regr: fixes in pytest lib + one in smlp_regr.py
fbrausse Mar 19, 2026
37d7a25
pytest regr: mark 104 and 107 as expected to fail
fbrausse Mar 20, 2026
8bfad84
regr lib.py: python-3.11 compat format strings
fbrausse Mar 20, 2026
5933506
pytest: enable strict mode
fbrausse Mar 20, 2026
428ae8a
regr lib.py: fix warning reporting
fbrausse Mar 20, 2026
f2012fb
regr lib.py: fix for missing Path()
fbrausse Mar 23, 2026
6f8872c
regr lib.py: remove work-around for -model_name
fbrausse Mar 23, 2026
ff09ecb
pyproject.toml: move to pytest-9
fbrausse May 6, 2026
c3323ad
regr lib: do not use relative path for executable anymore
fbrausse May 6, 2026
9dc6255
regr lib: remove unnecessary case distrinction: execute_test
fbrausse May 6, 2026
329163f
regr csv-cmp: support running as stand-alone script
fbrausse May 8, 2026
46701bc
regr lib: slight restructuring of file cmp code
fbrausse May 8, 2026
6446bc5
regr lib: use absolute path from argument in stand-alone mode
fbrausse May 8, 2026
66d4aa7
regr master: set "output_directory" from "./" to "."
fbrausse May 8, 2026
625d294
regr: re-generate test_cmdline (adding new tests + fixing external so…
fbrausse Jun 1, 2026
02e77c4
regr: fix computation of diff in csv_compare
fbrausse Jun 1, 2026
563f318
regr: lib uses "smlp" instead of local script + ignores another log line
fbrausse Jun 1, 2026
60afbdd
regr lib: add alternative spellings for special options
fbrausse Jun 1, 2026
4c4f52e
regr: mark test 229 as expected to fail as well
fbrausse Jun 1, 2026
001fddd
add conversion script from smlp_regr.csv to test_cmdline.py
fbrausse Jun 18, 2026
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
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ smlp = "smlp.run_smlp:main2"
where = ["."]
exclude = ["*"]

[tool.pytest]
strict = true
markers = [
"toy: Toy example tests (deselect with '-m \"not toy\"')",
"real: Tests on real world data (deselect with '-m \"not real\"')",
"test: ?? TODO: description (deselect with '-m \"not test\"')",
]

# ---------------------------------------------------------------------------
# Build-time environment variables (all optional)
# ---------------------------------------------------------------------------
Expand Down
88 changes: 88 additions & 0 deletions regr_smlp/code/convert-csv-pytest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env python3

import csv
import sys
import shlex

from smlp_regr import (conf_identifier, get_conf_name)

HEADER = '''\
#!/usr/bin/env python3

import pytest
import subprocess

from lib import *
'''

FOOTER = '''\
'''

def process(row : list[str]):
assert len(row) >= 5, repr(row)
nr = int(row[0])
data = row[1]
new_data = row[2]
switches = row[3]
comment = row[4:]

args = shlex.split(switches)

ignored_tests = []
is_toy = ((row[1].startswith('smlp_toy') or
row[1].startswith('mlbt_toy') or
row[2].startswith('smlp_toy') or
row[2].startswith('mlbt_toy') or
(conf_identifier(row[3]) and get_conf_name(row[3]).startswith('smlp_toy')) or
(not conf_identifier(row[3]) and row[1] == '' and row[2] == '')) and
(row[0] not in ignored_tests))

is_real = ((not (row[1].startswith('smlp_toy') or
row[1].startswith('mlbt_toy') or
row[2].startswith('smlp_toy') or
row[2].startswith('mlbt_toy') or
(conf_identifier(row[3]) and get_conf_name(row[3]).startswith('smlp_toy')))) and
(row[0] not in ignored_tests))

i_picks = ['36', '51', '60', '80', '95', '104', '120']
is_test = str(nr) in i_picks

failing = {
104: 'wrong spec due to singleton value',
107: 'contradictory eta contraints',
229: 'missing radius spec for p1/p2',
}

# keep in sync with /pyproject.toml: tool.pytest.ini_options.markers
if is_toy:
print('@pytest.mark.toy')
if is_real:
print('@pytest.mark.real')
if is_test:
print('@pytest.mark.test')

if nr in failing:
print(f'@pytest.mark.xfail(True, reason={failing[nr]!r},\n'
' raises=subprocess.CalledProcessError, strict=True)')

print(f"class Test{nr}(CmdTestCase):\n\t'''")
for line in comment:
print(f'\t{line.strip()}')
print("\t'''")

print(f'''
nr = {nr}
data = {data!r}
new_data = {new_data!r}
args = {args!r}\n''')

def main():
print(HEADER)
itr = csv.reader(sys.stdin)
next(itr)
for row in itr:
process(row)
print(FOOTER)

if __name__ == '__main__':
main()
12 changes: 8 additions & 4 deletions regr_smlp/code/csv_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def check_values(csv1, csv2):
if np.isnan(val2):
return False
if isinstance(val1, np.float64) and isinstance(val2, np.float64):
diff = abs(abs(val1) - abs(val2))
diff = abs(val1 - val2)
max_val = max(abs(val1), abs(val2))
diff_ratio = diff / max_val
if diff_ratio >= THRESHOLD:
Expand All @@ -66,9 +66,13 @@ def compare_csv(csv1, csv2):


def main():
pass
#return comapre_csv(path.join(old_path, file), path.join(new_path, file))
if compare_csv(sys.argv[1], sys.argv[2]):
print('OK')
return 0
else:
print('Failed')
return 1


if __name__ == "__main__":
main()
sys.exit(main())
Loading