[Test] Remove remnants of the old Python test suite

This commit is contained in:
Ray Speth 2014-04-08 16:27:19 +00:00
parent 8e91a34b82
commit 53820ed4a3
3 changed files with 1 additions and 87 deletions

View file

@ -2,7 +2,7 @@ import os
import numpy as np
import itertools
import utilities
from . import utilities
import cantera as ct
from cantera import ck2cti

View file

@ -1,24 +0,0 @@
"""
Unit tests for the Cantera Python module.
This script gathers all the tests defined in all of the test<foo>.py
files, runs them, and prints a report.
"""
import sys
import os
import unittest
sys.path.insert(0, os.path.abspath('../../interfaces/python'))
import Cantera
Cantera.addDirectory(os.path.join(os.path.split(os.getcwd())[0], 'data'))
if __name__ == '__main__':
print '\n* INFO: using Cantera module found at this location:'
print '* ', repr(Cantera.__file__), '\n'
sys.stdout.flush()
loader = unittest.TestLoader()
runner = unittest.TextTestRunner(verbosity=2)
sys.exit(0)

View file

@ -1,62 +0,0 @@
import numpy as np
import unittest
class CanteraTest(unittest.TestCase):
def assertNear(self, a, b, rtol=1e-8, atol=1e-12, msg=None):
cmp = 2 * abs(a - b)/(abs(a) + abs(b) + atol)
if cmp > rtol:
message = ('AssertNear: %.14g - %.14g = %.14g\n' % (a, b, a-b) +
'Relative error of %10e exceeds rtol = %10e' % (cmp, rtol))
if msg:
message = msg + '\n' + message
self.fail(message)
def compareTimeSeries(reference, sample, rtol=1e-5, atol=1e-12):
"""
Compare two 2D arrays of time series data. Each data set should contain
the time in the first column and data series to be compared in successive
columns.
The times in each data set do not need to be the same: The data from the
second data set will be interpolated onto the times in the first data set
before being compared. This means that the time range of the "sample" data
set should be at least as long as the "reference" data set.
After interpolation, each data point must satisfy either the relative
error tolerance specified by `rtol` or the absolute error tolerance
specified by `atol`.
If the comparison succeeds, this function returns `None`. If the comparison
fails, a formatted report of the differing elements is returned.
"""
if isinstance(reference, str):
reference = np.genfromtxt(reference, delimiter=',').T
else:
reference = np.asarray(reference).T
sample = np.asarray(sample).T
assert reference.shape[0] == sample.shape[0]
nVars = reference.shape[0]
nTimes = reference.shape[1]
bad = []
template = '{0:9.4e} {1: 3d} {2:14.8e} {3:14.8e} {4:9.3e} {5:9.3e}'
for i in range(1, nVars):
comp = np.interp(reference[0], sample[0], sample[i])
for j in range(nTimes):
a = reference[i,j]
b = comp[j]
abserr = abs(a-b)
relerr = 2 * abs(a-b) / (abs(a) + abs(b) + atol)
if abserr > atol and relerr > rtol:
bad.append(template.format(reference[0][j], i, a, b, abserr, relerr))
if bad:
header = ['Failed time series comparisons:',
' time component reference test value abs. err. rel. err',
'---------- --- -------------- -------------- --------- ---------']
return '\n'.join(header + bad)
else:
return None