1
1
import os
2
2
import numpy as np
3
3
import unittest
4
- from dpdata . cp2k . output import cell_to_low_triangle
4
+ from context import dpdata
5
5
6
- class CellToLowTriangle (unittest .TestCase ):
6
+ class TestCellToLowTriangle (unittest .TestCase ):
7
7
def test_func1 (self ):
8
- cell_1 = cell_to_low_triangle (6 ,6 ,6 ,np .pi * 1 / 2 , np .pi * 1 / 2 , np .pi * 1 / 2 )
8
+ cell_1 = dpdata . cp2k . output . cell_to_low_triangle (6 ,6 ,6 ,np .pi * 1 / 2 , np .pi * 1 / 2 , np .pi * 1 / 2 )
9
9
cell_2 = np .asarray ([[6 ,0 ,0 ],[0 ,6 ,0 ],[0 ,0 ,6 ]])
10
10
for ii in range (3 ):
11
11
for jj in range (3 ):
12
12
self .assertAlmostEqual (cell_1 [ii ,jj ], cell_2 [ii ,jj ], places = 6 )
13
13
14
14
def test_func2 (self ):
15
- cell_1 = cell_to_low_triangle (6 ,6 ,6 ,np .pi * 1 / 3 , np .pi * 1 / 3 , np .pi * 1 / 3 )
15
+ cell_1 = dpdata . cp2k . output . cell_to_low_triangle (6 ,6 ,6 ,np .pi * 1 / 3 , np .pi * 1 / 3 , np .pi * 1 / 3 )
16
16
cell_2 = np .asarray ([
17
17
[6 ,0 ,0 ],
18
18
[3 ,3 * np .sqrt (3 ),0 ],
@@ -23,12 +23,12 @@ def test_func2(self):
23
23
24
24
def test_func3 (self ):
25
25
with self .assertRaises (Exception ) as c :
26
- cell_to_low_triangle (0.1 ,6 ,6 ,np .pi * 1 / 2 ,np .pi * 1 / 2 ,np .pi * 1 / 2 )
26
+ dpdata . cp2k . output . cell_to_low_triangle (0.1 ,6 ,6 ,np .pi * 1 / 2 ,np .pi * 1 / 2 ,np .pi * 1 / 2 )
27
27
self .assertTrue ("A==0.1" in str (c .exception ))
28
28
29
29
def test_func4 (self ):
30
30
with self .assertRaises (Exception ) as c :
31
- cell_to_low_triangle (6 ,6 ,6 ,np .pi * 3 / 180 ,np .pi * 1 / 2 ,np .pi * 1 / 2 )
31
+ dpdata . cp2k . output . cell_to_low_triangle (6 ,6 ,6 ,np .pi * 3 / 180 ,np .pi * 1 / 2 ,np .pi * 1 / 2 )
32
32
self .assertTrue ("alpha" in str (c .exception ))
33
33
34
34
if __name__ == '__main__' :
0 commit comments