From 424a04bffcbcb28c69f46f2a37c9cb9f9c1d0be2 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 17 Oct 2014 23:44:59 +0000 Subject: [PATCH] [Test] Limit number of lines printed after failed test comparison --- interfaces/cython/cantera/test/utilities.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/interfaces/cython/cantera/test/utilities.py b/interfaces/cython/cantera/test/utilities.py index 7cc3385bb..cb705ba5e 100644 --- a/interfaces/cython/cantera/test/utilities.py +++ b/interfaces/cython/cantera/test/utilities.py @@ -104,12 +104,19 @@ def compareProfiles(reference, sample, rtol=1e-5, atol=1e-12, xtol=1e-5): xerr = abserr / (abs(slope[j]) + atol) if abserr > atol and relerr > rtol and xerr > xtol: - bad.append(template.format(reference[0][j], i, a, b, abserr, relerr, xerr)) + bad.append((reference[0][j], i, a, b, abserr, relerr, xerr)) + + footer = [] + maxrows = 10 + if len(bad) > maxrows: + bad.sort(key=lambda row: -row[5]) + footer += ['Plus {0} more points exceeding error thresholds.'.format(len(bad)-maxrows)] + bad = bad[:maxrows] if bad: header = ['Failed series comparisons:', 'coordinate comp. reference val test value abs. err rel. err pos. err', '---------- --- -------------- -------------- --------- --------- ---------'] - return '\n'.join(header + bad) + return '\n'.join(header + [template.format(*row) for row in bad] + footer) else: return None