3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-21 20:03:41 +01:00

Fixed tests affected by recent changes

This commit is contained in:
Oleg Peil 2018-05-04 16:21:08 +02:00 committed by Manuel
parent 64605e3267
commit 14f8b1d9e1
6 changed files with 34 additions and 22 deletions

View File

@ -78,9 +78,9 @@ class TestParseInput(arraytest.ArrayTestCase):
res = res.replace(" ","") # Remove spaces for comparison res = res.replace(" ","") # Remove spaces for comparison
expected = r"""Shells: expected = r"""Shells:
[{'ion_list':array([4,5,6,7]),'user_index':1,'lshell':2},{'tmatrix':array([[0.,1.,0.], [{'ions':{'nion':4,'ion_list':[[4],[5],[6],[7]]},'user_index':1,'lshell':2},{'tmatrix':array([[0.,1.,0.],
[1.,0.,0.], [1.,0.,0.],
[0.,0.,1.]]),'ion_list':array([0,1,2,3]),'user_index':2,'lshell':1},{'ion_list':array([0,1,2,3]),'user_index':3,'lshell':3}] [0.,0.,1.]]),'ions':{'nion':4,'ion_list':[[0],[1],[2],[3]]},'user_index':2,'lshell':1},{'ions':{'nion':4,'ion_list':[[0],[1],[2],[3]]},'user_index':3,'lshell':3}]
Groups: Groups:
[{'normalize':True,'index':1,'ewindow':(-7.6,3.0),'normion':True,'shells':[0,1]},{'normalize':True,'index':2,'ewindow':(-1.6,2.0),'normion':True,'shells':[2]}]""" [{'normalize':True,'index':1,'ewindow':(-7.6,3.0),'normion':True,'shells':[0,1]},{'normalize':True,'index':2,'ewindow':(-1.6,2.0),'normion':True,'shells':[2]}]"""
@ -103,7 +103,7 @@ Groups:
res = res.replace(" ","") # Remove spaces for comparison res = res.replace(" ","") # Remove spaces for comparison
expected = r"""Shells: expected = r"""Shells:
[{'ion_list':array([4,5,6,7]),'user_index':1,'lshell':2}] [{'ions':{'nion':4,'ion_list':[[4],[5],[6],[7]]},'user_index':1,'lshell':2}]
Groups: Groups:
[{'normalize':True,'index':'1','ewindow':(-7.6,3.0),'shells':[0],'normion':True}]""" [{'normalize':True,'index':'1','ewindow':(-7.6,3.0),'shells':[0],'normion':True}]"""
@ -111,3 +111,7 @@ Groups:
self.assertEqual(res, expected) self.assertEqual(res, expected)
if __name__ == '__main__':
import unittest
unittest.main(verbosity=2, buffer=False)

View File

@ -57,19 +57,19 @@ class TestParseShells(arraytest.ArrayTestCase):
conf_pars = ConfigParameters(_rpath + 'parse_shells_4.cfg') conf_pars = ConfigParameters(_rpath + 'parse_shells_4.cfg')
conf_pars.parse_shells() conf_pars.parse_shells()
res = conf_pars.shells res = conf_pars.shells
expected = [{'user_index': 1, 'lshell': 2, 'ion_list': np.array([4, 5, 6, 7])}, expected = [{'user_index': 1, 'lshell': 2, 'ions': {'nion': 4, 'ion_list': [[4],[5],[6],[7]]}},
{'user_index': 2, 'lshell': 1, 'ion_list': np.array([0, 1, 2, 3]), {'user_index': 2, 'lshell': 1, 'ions': {'nion': 4, 'ion_list': [[0],[1],[2],[3]]},
'tmatrix': np.array([[ 0., 1., 0.], [ 1., 0., 0.], [ 0., 0., 1.]])}] 'tmatrix': np.array([[ 0., 1., 0.], [ 1., 0., 0.], [ 0., 0., 1.]])}]
# ...lousy way to test equality of two dictionaries containing numpy arrays # ...lousy way to test equality of two dictionaries containing numpy arrays
self.assertEqual(len(res), len(expected)) self.assertEqual(len(res), len(expected))
arr = res[0].pop('ion_list') arr = res[0].pop('ions')
arr_exp = expected[0].pop('ion_list') arr_exp = expected[0].pop('ions')
self.assertEqual(arr, arr_exp) self.assertDictEqual(arr, arr_exp)
arr = res[1].pop('ion_list') arr = res[1].pop('ions')
arr_exp = expected[1].pop('ion_list') arr_exp = expected[1].pop('ions')
self.assertEqual(arr, arr_exp) self.assertDictEqual(arr, arr_exp)
arr = res[1].pop('tmatrix') arr = res[1].pop('tmatrix')
arr_exp = expected[1].pop('tmatrix') arr_exp = expected[1].pop('tmatrix')
@ -78,3 +78,7 @@ class TestParseShells(arraytest.ArrayTestCase):
self.assertListEqual(res, expected) self.assertListEqual(res, expected)
if __name__ == '__main__':
import unittest
unittest.main(verbosity=2, buffer=False)

View File

@ -60,11 +60,12 @@ class TestParseStringIonList(arraytest.ArrayTestCase):
Scenarios: Scenarios:
- **if** par_str == '5 6 7 8' **return** array([4, 5, 6, 7]) - **if** par_str == '5 6 7 8' **return** 'ions' with ion_list = [[4], [5], [6], [7]]
- **if** par_str == 'Ni' **raise** NotImplementedError - **if** par_str == 'Ni' **raise** NotImplementedError
- **if** par_str == '0 1' **raise** AssertionError - **if** par_str == '0 1' **raise** AssertionError
- **if** par_str == '5..8' **return** array([4, 5, 6, 7]) - **if** par_str == '5..8' **return** 'ions' with ion_list = [[4], [5], [6], [7]]
- **if** par_str == '8..5' **raise** AssertionError - **if** par_str == '8..5' **raise** AssertionError
- **if** par_str == '[5, 8] [6 7]' **return** 'ions' with ion_list = [[4, 7], [5, 6]]
""" """
def setUp(self): def setUp(self):
""" """
@ -74,9 +75,9 @@ class TestParseStringIonList(arraytest.ArrayTestCase):
# Scenario 1 # Scenario 1
def test_simple_list(self): def test_simple_list(self):
expected = np.array([4, 5, 6, 7]) expected = {'nion': 4, 'ion_list': [[4], [5], [6], [7]]}
res = self.cpars.parse_string_ion_list('5 6 7 8') res = self.cpars.parse_string_ion_list('5 6 7 8')
self.assertEqual(res, expected) self.assertDictEqual(res, expected)
# Scenario 2 # Scenario 2
def test_atomic_symbol(self): def test_atomic_symbol(self):
@ -91,9 +92,9 @@ class TestParseStringIonList(arraytest.ArrayTestCase):
# Scenario 4 # Scenario 4
def test_list_range(self): def test_list_range(self):
expected = np.array([4, 5, 6, 7]) expected = {'nion': 4, 'ion_list': [[4], [5], [6], [7]]}
res = self.cpars.parse_string_ion_list('5..8') res = self.cpars.parse_string_ion_list('5..8')
self.assertEqual(res, expected) self.assertDictEqual(res, expected)
# Scenario 5 # Scenario 5
def test_range_wrong_order(self): def test_range_wrong_order(self):
@ -294,3 +295,7 @@ class TestParseStringDosmesh(arraytest.ArrayTestCase):
self.cpars.parse_string_dosmesh('8.0') self.cpars.parse_string_dosmesh('8.0')
if __name__ == '__main__':
import unittest
unittest.main(verbosity=2, buffer=False)

View File

@ -1,8 +1,7 @@
[Shell 1] [Shell 1]
LSHELL = 2 LSHELL = 2
IONS = 1 IONS = 2
EMIN = -15.0 EWINDOW = -15.0 5.0
EMAX = 5.0

View File

@ -1 +1 @@
PYTHONPATH=../../python:../../c:$PYTHONPATH python $1 PYTHONPATH=../../python:../../c:$PYTHONPATH ../../../build_pytriqs $1

View File

@ -1,4 +1,4 @@
pars: {'ion_list': array([1]), 'user_index': 1, 'lshell': 2} pars: {'ions': {'nion': 1, 'ion_list': [[1]]}, 'user_index': 1, 'lshell': 2}
10 25 10 25
1 0.000000 -0.000000 1 0.000000 -0.000000
2 0.000000 0.000000 2 0.000000 0.000000