mirror of
https://github.com/triqs/dft_tools
synced 2024-12-22 04:13:47 +01:00
* Fixed tests for the modified version of 'parse_shells()'
* Removed redundant prints in 'parse_shells()'
This commit is contained in:
parent
76d0b4a6bb
commit
d2fe6d50e8
@ -249,33 +249,24 @@ class ConfigParameters:
|
|||||||
shell['user_index'] = ind
|
shell['user_index'] = ind
|
||||||
section = self.sh_sections[ind]
|
section = self.sh_sections[ind]
|
||||||
|
|
||||||
# Shell required parameters
|
|
||||||
if self.verbosity > 0:
|
if self.verbosity > 0:
|
||||||
print
|
print
|
||||||
print " Required shell parameters:"
|
print " Shell parameters:"
|
||||||
|
# Shell required parameters
|
||||||
parsed = self.parse_parameter_set(section, self.sh_required, exception=True)
|
parsed = self.parse_parameter_set(section, self.sh_required, exception=True)
|
||||||
shell.update(parsed)
|
shell.update(parsed)
|
||||||
|
|
||||||
# Shell optional parameters
|
# Shell optional parameters
|
||||||
if self.verbosity > 0:
|
|
||||||
print
|
|
||||||
print " Optional shell parameters:"
|
|
||||||
parsed = self.parse_parameter_set(section, self.sh_optional, exception=False)
|
parsed = self.parse_parameter_set(section, self.sh_optional, exception=False)
|
||||||
shell.update(parsed)
|
shell.update(parsed)
|
||||||
|
|
||||||
# Group required parameters
|
# Group required parameters
|
||||||
# Must be given if no group is explicitly specified
|
# Must be given if no group is explicitly specified
|
||||||
# If in conflict with the [Group] section, the latter has a priority
|
# If in conflict with the [Group] section, the latter has a priority
|
||||||
if self.verbosity > 0:
|
|
||||||
print
|
|
||||||
print " Required group parameters:"
|
|
||||||
parsed = self.parse_parameter_set(section, self.gr_required, exception=False)
|
parsed = self.parse_parameter_set(section, self.gr_required, exception=False)
|
||||||
shell.update(parsed)
|
shell.update(parsed)
|
||||||
|
|
||||||
# Group optional parameters
|
# Group optional parameters
|
||||||
if self.verbosity > 0:
|
|
||||||
print
|
|
||||||
print " Optional group parameters:"
|
|
||||||
parsed = self.parse_parameter_set(section, self.gr_optional, exception=False)
|
parsed = self.parse_parameter_set(section, self.gr_optional, exception=False)
|
||||||
shell.update(parsed)
|
shell.update(parsed)
|
||||||
|
|
||||||
@ -311,17 +302,14 @@ class ConfigParameters:
|
|||||||
raise ValueError("Failed to extract group index from a group name: %s"%(section))
|
raise ValueError("Failed to extract group index from a group name: %s"%(section))
|
||||||
group['index'] = gr_ind
|
group['index'] = gr_ind
|
||||||
|
|
||||||
# Group required parameters
|
|
||||||
if self.verbosity > 0:
|
if self.verbosity > 0:
|
||||||
print
|
print
|
||||||
print " Required group parameters:"
|
print " Group parameters:"
|
||||||
|
# Group required parameters
|
||||||
parsed = self.parse_parameter_set(section, self.gr_required, exception=True)
|
parsed = self.parse_parameter_set(section, self.gr_required, exception=True)
|
||||||
group.update(parsed)
|
group.update(parsed)
|
||||||
|
|
||||||
# Group optional parameters
|
# Group optional parameters
|
||||||
if self.verbosity > 0:
|
|
||||||
print
|
|
||||||
print " Optional group parameters:"
|
|
||||||
parsed = self.parse_parameter_set(section, self.gr_optional, exception=False)
|
parsed = self.parse_parameter_set(section, self.gr_optional, exception=False)
|
||||||
group.update(parsed)
|
group.update(parsed)
|
||||||
|
|
||||||
|
@ -225,25 +225,25 @@ class TestSpecialParsers(unittest.TestCase):
|
|||||||
conf_pars = ConfigParameters('test5.cfg')
|
conf_pars = ConfigParameters('test5.cfg')
|
||||||
conf_pars.parse_shells()
|
conf_pars.parse_shells()
|
||||||
res = conf_pars.shells
|
res = conf_pars.shells
|
||||||
expected = {1: {'lshell': 2, 'ion_list': np.array([4, 5, 6, 7])},
|
expected = [{'user_index': 1, 'lshell': 2, 'ion_list': np.array([4, 5, 6, 7])},
|
||||||
2: {'lshell': 1, 'ion_list': np.array([0, 1, 2, 3]),
|
{'user_index': 2, 'lshell': 1, 'ion_list': np.array([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.assertSetEqual(set(res.keys()), set(expected.keys()))
|
self.assertEqual(len(res), len(expected))
|
||||||
|
|
||||||
|
arr = res[0].pop('ion_list')
|
||||||
|
arr_exp = expected[0].pop('ion_list')
|
||||||
|
self.assertEqual(arr, arr_exp)
|
||||||
|
|
||||||
arr = res[1].pop('ion_list')
|
arr = res[1].pop('ion_list')
|
||||||
arr_exp = expected[1].pop('ion_list')
|
arr_exp = expected[1].pop('ion_list')
|
||||||
self.assertEqual(arr, arr_exp)
|
self.assertEqual(arr, arr_exp)
|
||||||
|
|
||||||
arr = res[2].pop('ion_list')
|
arr = res[1].pop('tmatrix')
|
||||||
arr_exp = expected[2].pop('ion_list')
|
arr_exp = expected[1].pop('tmatrix')
|
||||||
self.assertEqual(arr, arr_exp)
|
self.assertEqual(arr, arr_exp)
|
||||||
|
|
||||||
arr = res[2].pop('tmatrix')
|
self.assertListEqual(res, expected)
|
||||||
arr_exp = expected[2].pop('tmatrix')
|
|
||||||
self.assertEqual(arr, arr_exp)
|
|
||||||
|
|
||||||
self.assertDictEqual(res, expected)
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user