smbinterp/test/baker3d.py
Stephen Mardson McQuay 9827035e72 made it so I can call all tests at once
--HG--
rename : test/2dcubic.py => test/cubic2d.py
rename : test/2dquadratic.py => test/quadratic2d.py
2011-02-15 11:27:45 -07:00

40 lines
1.0 KiB
Python

#!/usr/bin/env python
import unittest
from interp.baker import get_phis, qlinear
from interp.grid import grid
import numpy as np
import scipy.spatial
class Test(unittest.TestCase):
def setUp(self):
self.X = [0.0, 0.0, 0.0]
self.r = [
[0.0, 0.0, 1.0],
[0.94280904333606508, 0.0, -0.3333333283722672],
[-0.47140452166803232, 0.81649658244673617, -0.3333333283722672],
[-0.47140452166803298, -0.81649658244673584, -0.3333333283722672],
]
self.q = [0.0, 0.0, 0.0, 4]
def testGetPhis(self):
result = get_phis(self.X, self.r)
right_answer = [0.25, 0.25, 0.25, 0.25]
for a,b in zip(result, right_answer):
self.assertAlmostEqual(a,b)
def testQlinear(self):
phi, result = qlinear(self.X, grid(self.r, self.q))
result = result
right_answer = 1.0
self.assertAlmostEqual(result, right_answer)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(Test)
unittest.TextTestRunner(verbosity=2).run(suite)