40 lines
1.1 KiB
Python
Executable File
40 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env 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 = baker.get_phis_3D(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 testQlinear3D(self):
|
|
phi, result = baker.qlinear_3D(self.X, grid.grid(self.r, self.q))
|
|
result = result
|
|
right_answer = 1.0
|
|
self.assertAlmostEqual(result, right_answer)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions)
|
|
unittest.TextTestRunner(verbosity=2).run(suite)
|