Skip to content

Commit

Permalink
Updates tests to output stats on fail
Browse files Browse the repository at this point in the history
  • Loading branch information
holm10 committed Dec 8, 2023
1 parent 3249a02 commit e20258e
Show file tree
Hide file tree
Showing 191 changed files with 960 additions and 384 deletions.
Binary file modified pytests/pytests/fulltests/nonog_d_c-fb_16x8/solution.h5
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def matches(save, refs, epsilon):
from uedge import bbb
recoverstate(save, refs)
fnrm = bbb.get_fnrm(bbb.dtreal)
return isclose(fnrm, refs['fnrm'][()], atol=0.0, rtol=epsilon)
reffnrm = refs['fnrm'][()]
return isclose(fnrm, reffnrm, atol=0.0, rtol=epsilon), fnrm, reffnrm


def print_itroub(refs):
Expand Down Expand Up @@ -100,19 +101,23 @@ def print_itroub(refs):
with File('solution.h5', 'r') as f:
refs = f['pytests']
defref = refs['default']
if matches(f, defref, epsilon):
match, fnrm, reffnrm = matches(f, defref, epsilon)
if match:
# Turn output back on
try:
com.iprint = 1
except:
bbb.iprint = 1
assert True
else:
print('Returned fnrm:'.ljust(30), fnrm)
print('Reference fnrm:'.ljust(30), reffnrm)
print_itroub(refs)
print('Failed equation(s):')
for setupkey in ['ni', 'up', 'te', 'ti', 'ng', 'tg', 'phi']:
if setupkey in refs:
if matches(f, refs[setupkey], epsilon):
match, fnrm, reffnrm = matches(f, refs[setupkey], epsilon)
if match:
continue
elif isinstance(refs[setupkey][f'is{setupkey}on'][()], ndarray):
species = refs['casesetup/nisp'][()]*(setupkey == 'ni') +\
Expand Down Expand Up @@ -141,7 +146,8 @@ def print_itroub(refs):
failed.append(var)
failindex = []
for s in range(species):
if not matches(f, refs[f'{setupkey}-{s}'], epsilon):
match, fnrm, reffnrm = matches(f, refs[f'{setupkey}-{s}'], epsilon)
if not match:
failindex.append(s)
print(' - {} for indices: {}'.format(setupkey, str(failindex)[1:-1]))
else:
Expand Down
Binary file modified pytests/pytests/fulltests/orthogonal_unittest/solution.h5
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def matches(save, refs, epsilon):
from uedge import bbb
recoverstate(save, refs)
fnrm = bbb.get_fnrm(bbb.dtreal)
return isclose(fnrm, refs['fnrm'][()], atol=0.0, rtol=epsilon)
reffnrm = refs['fnrm'][()]
return isclose(fnrm, reffnrm, atol=0.0, rtol=epsilon), fnrm, reffnrm


def print_itroub(refs):
Expand Down Expand Up @@ -100,19 +101,23 @@ def print_itroub(refs):
with File('solution.h5', 'r') as f:
refs = f['pytests']
defref = refs['default']
if matches(f, defref, epsilon):
match, fnrm, reffnrm = matches(f, defref, epsilon)
if match:
# Turn output back on
try:
com.iprint = 1
except:
bbb.iprint = 1
assert True
else:
print('Returned fnrm:'.ljust(30), fnrm)
print('Reference fnrm:'.ljust(30), reffnrm)
print_itroub(refs)
print('Failed equation(s):')
for setupkey in ['ni', 'up', 'te', 'ti', 'ng', 'tg', 'phi']:
if setupkey in refs:
if matches(f, refs[setupkey], epsilon):
match, fnrm, reffnrm = matches(f, refs[setupkey], epsilon)
if match:
continue
elif isinstance(refs[setupkey][f'is{setupkey}on'][()], ndarray):
species = refs['casesetup/nisp'][()]*(setupkey == 'ni') +\
Expand Down Expand Up @@ -141,7 +146,8 @@ def print_itroub(refs):
failed.append(var)
failindex = []
for s in range(species):
if not matches(f, refs[f'{setupkey}-{s}'], epsilon):
match, fnrm, reffnrm = matches(f, refs[f'{setupkey}-{s}'], epsilon)
if not match:
failindex.append(s)
print(' - {} for indices: {}'.format(setupkey, str(failindex)[1:-1]))
else:
Expand Down
Binary file modified pytests/pytests/unittests/D+C/nonog_carbon/default/solution.h5
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def matches(save, refs, epsilon):
from uedge import bbb
recoverstate(save, refs)
fnrm = bbb.get_fnrm(bbb.dtreal)
return isclose(fnrm, refs['fnrm'][()], atol=0.0, rtol=epsilon)
reffnrm = refs['fnrm'][()]
return isclose(fnrm, reffnrm, atol=0.0, rtol=epsilon), fnrm, reffnrm


def print_itroub(refs):
Expand Down Expand Up @@ -100,19 +101,23 @@ def print_itroub(refs):
with File('solution.h5', 'r') as f:
refs = f['pytests']
defref = refs['default']
if matches(f, defref, epsilon):
match, fnrm, reffnrm = matches(f, defref, epsilon)
if match:
# Turn output back on
try:
com.iprint = 1
except:
bbb.iprint = 1
assert True
else:
print('Returned fnrm:'.ljust(30), fnrm)
print('Reference fnrm:'.ljust(30), reffnrm)
print_itroub(refs)
print('Failed equation(s):')
for setupkey in ['ni', 'up', 'te', 'ti', 'ng', 'tg', 'phi']:
if setupkey in refs:
if matches(f, refs[setupkey], epsilon):
match, fnrm, reffnrm = matches(f, refs[setupkey], epsilon)
if match:
continue
elif isinstance(refs[setupkey][f'is{setupkey}on'][()], ndarray):
species = refs['casesetup/nisp'][()]*(setupkey == 'ni') +\
Expand Down Expand Up @@ -141,7 +146,8 @@ def print_itroub(refs):
failed.append(var)
failindex = []
for s in range(species):
if not matches(f, refs[f'{setupkey}-{s}'], epsilon):
match, fnrm, reffnrm = matches(f, refs[f'{setupkey}-{s}'], epsilon)
if not match:
failindex.append(s)
print(' - {} for indices: {}'.format(setupkey, str(failindex)[1:-1]))
else:
Expand Down
Binary file modified pytests/pytests/unittests/D_only/nonog/0p5albedoc/solution.h5
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def matches(save, refs, epsilon):
from uedge import bbb
recoverstate(save, refs)
fnrm = bbb.get_fnrm(bbb.dtreal)
return isclose(fnrm, refs['fnrm'][()], atol=0.0, rtol=epsilon)
reffnrm = refs['fnrm'][()]
return isclose(fnrm, reffnrm, atol=0.0, rtol=epsilon), fnrm, reffnrm


def print_itroub(refs):
Expand Down Expand Up @@ -100,19 +101,23 @@ def print_itroub(refs):
with File('solution.h5', 'r') as f:
refs = f['pytests']
defref = refs['default']
if matches(f, defref, epsilon):
match, fnrm, reffnrm = matches(f, defref, epsilon)
if match:
# Turn output back on
try:
com.iprint = 1
except:
bbb.iprint = 1
assert True
else:
print('Returned fnrm:'.ljust(30), fnrm)
print('Reference fnrm:'.ljust(30), reffnrm)
print_itroub(refs)
print('Failed equation(s):')
for setupkey in ['ni', 'up', 'te', 'ti', 'ng', 'tg', 'phi']:
if setupkey in refs:
if matches(f, refs[setupkey], epsilon):
match, fnrm, reffnrm = matches(f, refs[setupkey], epsilon)
if match:
continue
elif isinstance(refs[setupkey][f'is{setupkey}on'][()], ndarray):
species = refs['casesetup/nisp'][()]*(setupkey == 'ni') +\
Expand Down Expand Up @@ -141,7 +146,8 @@ def print_itroub(refs):
failed.append(var)
failindex = []
for s in range(species):
if not matches(f, refs[f'{setupkey}-{s}'], epsilon):
match, fnrm, reffnrm = matches(f, refs[f'{setupkey}-{s}'], epsilon)
if not match:
failindex.append(s)
print(' - {} for indices: {}'.format(setupkey, str(failindex)[1:-1]))
else:
Expand Down
Binary file modified pytests/pytests/unittests/D_only/nonog/albdsi/solution.h5
Binary file not shown.
14 changes: 10 additions & 4 deletions pytests/pytests/unittests/D_only/nonog/albdsi/test_nonog_albdsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def matches(save, refs, epsilon):
from uedge import bbb
recoverstate(save, refs)
fnrm = bbb.get_fnrm(bbb.dtreal)
return isclose(fnrm, refs['fnrm'][()], atol=0.0, rtol=epsilon)
reffnrm = refs['fnrm'][()]
return isclose(fnrm, reffnrm, atol=0.0, rtol=epsilon), fnrm, reffnrm


def print_itroub(refs):
Expand Down Expand Up @@ -100,19 +101,23 @@ def print_itroub(refs):
with File('solution.h5', 'r') as f:
refs = f['pytests']
defref = refs['default']
if matches(f, defref, epsilon):
match, fnrm, reffnrm = matches(f, defref, epsilon)
if match:
# Turn output back on
try:
com.iprint = 1
except:
bbb.iprint = 1
assert True
else:
print('Returned fnrm:'.ljust(30), fnrm)
print('Reference fnrm:'.ljust(30), reffnrm)
print_itroub(refs)
print('Failed equation(s):')
for setupkey in ['ni', 'up', 'te', 'ti', 'ng', 'tg', 'phi']:
if setupkey in refs:
if matches(f, refs[setupkey], epsilon):
match, fnrm, reffnrm = matches(f, refs[setupkey], epsilon)
if match:
continue
elif isinstance(refs[setupkey][f'is{setupkey}on'][()], ndarray):
species = refs['casesetup/nisp'][()]*(setupkey == 'ni') +\
Expand Down Expand Up @@ -141,7 +146,8 @@ def print_itroub(refs):
failed.append(var)
failindex = []
for s in range(species):
if not matches(f, refs[f'{setupkey}-{s}'], epsilon):
match, fnrm, reffnrm = matches(f, refs[f'{setupkey}-{s}'], epsilon)
if not match:
failindex.append(s)
print(' - {} for indices: {}'.format(setupkey, str(failindex)[1:-1]))
else:
Expand Down
Binary file modified pytests/pytests/unittests/D_only/nonog/albdso/solution.h5
Binary file not shown.
14 changes: 10 additions & 4 deletions pytests/pytests/unittests/D_only/nonog/albdso/test_nonog_albdso.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def matches(save, refs, epsilon):
from uedge import bbb
recoverstate(save, refs)
fnrm = bbb.get_fnrm(bbb.dtreal)
return isclose(fnrm, refs['fnrm'][()], atol=0.0, rtol=epsilon)
reffnrm = refs['fnrm'][()]
return isclose(fnrm, reffnrm, atol=0.0, rtol=epsilon), fnrm, reffnrm


def print_itroub(refs):
Expand Down Expand Up @@ -100,19 +101,23 @@ def print_itroub(refs):
with File('solution.h5', 'r') as f:
refs = f['pytests']
defref = refs['default']
if matches(f, defref, epsilon):
match, fnrm, reffnrm = matches(f, defref, epsilon)
if match:
# Turn output back on
try:
com.iprint = 1
except:
bbb.iprint = 1
assert True
else:
print('Returned fnrm:'.ljust(30), fnrm)
print('Reference fnrm:'.ljust(30), reffnrm)
print_itroub(refs)
print('Failed equation(s):')
for setupkey in ['ni', 'up', 'te', 'ti', 'ng', 'tg', 'phi']:
if setupkey in refs:
if matches(f, refs[setupkey], epsilon):
match, fnrm, reffnrm = matches(f, refs[setupkey], epsilon)
if match:
continue
elif isinstance(refs[setupkey][f'is{setupkey}on'][()], ndarray):
species = refs['casesetup/nisp'][()]*(setupkey == 'ni') +\
Expand Down Expand Up @@ -141,7 +146,8 @@ def print_itroub(refs):
failed.append(var)
failindex = []
for s in range(species):
if not matches(f, refs[f'{setupkey}-{s}'], epsilon):
match, fnrm, reffnrm = matches(f, refs[f'{setupkey}-{s}'], epsilon)
if not match:
failindex.append(s)
print(' - {} for indices: {}'.format(setupkey, str(failindex)[1:-1]))
else:
Expand Down
Binary file modified pytests/pytests/unittests/D_only/nonog/bcee/solution.h5
Binary file not shown.
14 changes: 10 additions & 4 deletions pytests/pytests/unittests/D_only/nonog/bcee/test_nonog_bcee.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def matches(save, refs, epsilon):
from uedge import bbb
recoverstate(save, refs)
fnrm = bbb.get_fnrm(bbb.dtreal)
return isclose(fnrm, refs['fnrm'][()], atol=0.0, rtol=epsilon)
reffnrm = refs['fnrm'][()]
return isclose(fnrm, reffnrm, atol=0.0, rtol=epsilon), fnrm, reffnrm


def print_itroub(refs):
Expand Down Expand Up @@ -100,19 +101,23 @@ def print_itroub(refs):
with File('solution.h5', 'r') as f:
refs = f['pytests']
defref = refs['default']
if matches(f, defref, epsilon):
match, fnrm, reffnrm = matches(f, defref, epsilon)
if match:
# Turn output back on
try:
com.iprint = 1
except:
bbb.iprint = 1
assert True
else:
print('Returned fnrm:'.ljust(30), fnrm)
print('Reference fnrm:'.ljust(30), reffnrm)
print_itroub(refs)
print('Failed equation(s):')
for setupkey in ['ni', 'up', 'te', 'ti', 'ng', 'tg', 'phi']:
if setupkey in refs:
if matches(f, refs[setupkey], epsilon):
match, fnrm, reffnrm = matches(f, refs[setupkey], epsilon)
if match:
continue
elif isinstance(refs[setupkey][f'is{setupkey}on'][()], ndarray):
species = refs['casesetup/nisp'][()]*(setupkey == 'ni') +\
Expand Down Expand Up @@ -141,7 +146,8 @@ def print_itroub(refs):
failed.append(var)
failindex = []
for s in range(species):
if not matches(f, refs[f'{setupkey}-{s}'], epsilon):
match, fnrm, reffnrm = matches(f, refs[f'{setupkey}-{s}'], epsilon)
if not match:
failindex.append(s)
print(' - {} for indices: {}'.format(setupkey, str(failindex)[1:-1]))
else:
Expand Down
Binary file modified pytests/pytests/unittests/D_only/nonog/bcei/solution.h5
Binary file not shown.
14 changes: 10 additions & 4 deletions pytests/pytests/unittests/D_only/nonog/bcei/test_nonog_bcei.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def matches(save, refs, epsilon):
from uedge import bbb
recoverstate(save, refs)
fnrm = bbb.get_fnrm(bbb.dtreal)
return isclose(fnrm, refs['fnrm'][()], atol=0.0, rtol=epsilon)
reffnrm = refs['fnrm'][()]
return isclose(fnrm, reffnrm, atol=0.0, rtol=epsilon), fnrm, reffnrm


def print_itroub(refs):
Expand Down Expand Up @@ -100,19 +101,23 @@ def print_itroub(refs):
with File('solution.h5', 'r') as f:
refs = f['pytests']
defref = refs['default']
if matches(f, defref, epsilon):
match, fnrm, reffnrm = matches(f, defref, epsilon)
if match:
# Turn output back on
try:
com.iprint = 1
except:
bbb.iprint = 1
assert True
else:
print('Returned fnrm:'.ljust(30), fnrm)
print('Reference fnrm:'.ljust(30), reffnrm)
print_itroub(refs)
print('Failed equation(s):')
for setupkey in ['ni', 'up', 'te', 'ti', 'ng', 'tg', 'phi']:
if setupkey in refs:
if matches(f, refs[setupkey], epsilon):
match, fnrm, reffnrm = matches(f, refs[setupkey], epsilon)
if match:
continue
elif isinstance(refs[setupkey][f'is{setupkey}on'][()], ndarray):
species = refs['casesetup/nisp'][()]*(setupkey == 'ni') +\
Expand Down Expand Up @@ -141,7 +146,8 @@ def print_itroub(refs):
failed.append(var)
failindex = []
for s in range(species):
if not matches(f, refs[f'{setupkey}-{s}'], epsilon):
match, fnrm, reffnrm = matches(f, refs[f'{setupkey}-{s}'], epsilon)
if not match:
failindex.append(s)
print(' - {} for indices: {}'.format(setupkey, str(failindex)[1:-1]))
else:
Expand Down
Binary file modified pytests/pytests/unittests/D_only/nonog/cmntgwi/solution.h5
Binary file not shown.
Loading

0 comments on commit e20258e

Please sign in to comment.