smbinterp/test/baker3D.test.py

39 lines
1.1 KiB
Python
Raw Normal View History

#!/usr/bin/python
import unittest
import baker
import grid
import numpy as np
import scipy.spatial
class TestSequenceFunctions(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 testGetPhis3D(self):
result = [round(i, 5) for i in baker.get_phis_3D(self.X, self.r)]
right_answer = [round(i, 5) for i in [0.25, 0.25, 0.25, 0.25]]
self.assertEqual(result, right_answer)
def testQlinear3D(self):
phi, result = baker.qlinear_3D(self.X, grid.grid(self.r, self.q))
result = round(result, 5)
right_answer = round(1.0, 5)
self.assertEqual(result, right_answer)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions)
unittest.TextTestRunner(verbosity=2).run(suite)