mirror of
https://github.com/triqs/dft_tools
synced 2024-11-07 06:33:48 +01:00
Fixed a bug in 'inpconf.py', added a corresponding test
This commit is contained in:
parent
b05d176f39
commit
90c93c4693
@ -342,6 +342,7 @@ class ConfigParameters:
|
|||||||
|
|
||||||
# Otherwise create a single group taking group information from [Shell] section
|
# Otherwise create a single group taking group information from [Shell] section
|
||||||
self.groups.append({})
|
self.groups.append({})
|
||||||
|
self.groups[0]['index'] = '1'
|
||||||
# Check that the single '[Shell]' section contains enough information
|
# Check that the single '[Shell]' section contains enough information
|
||||||
# (required group parameters except 'shells')
|
# (required group parameters except 'shells')
|
||||||
# and move it to the `groups` dictionary
|
# and move it to the `groups` dictionary
|
||||||
@ -362,12 +363,12 @@ class ConfigParameters:
|
|||||||
for par in self.gr_optional.keys():
|
for par in self.gr_optional.keys():
|
||||||
try:
|
try:
|
||||||
key = self.gr_optional[par][0]
|
key = self.gr_optional[par][0]
|
||||||
value = self.shells[ind].pop(key)
|
value = self.shells[0].pop(key)
|
||||||
self.groups[0][key] = value
|
self.groups[0][key] = value
|
||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
# Add the index of the single shell into the group
|
# Add the index of the single shell into the group
|
||||||
self.groups.update({'shells': 0})
|
self.groups[0].update({'shells': [1]})
|
||||||
|
|
||||||
#
|
#
|
||||||
# Consistency checks
|
# Consistency checks
|
||||||
|
7
python/converters/vasp/test/inpconf/example_nogroup.cfg
Normal file
7
python/converters/vasp/test/inpconf/example_nogroup.cfg
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[Shell 1]
|
||||||
|
LSHELL = 2
|
||||||
|
IONS = 5..8
|
||||||
|
EMIN = -7.6
|
||||||
|
EMAX = 3.0
|
||||||
|
|
||||||
|
|
@ -28,6 +28,7 @@ class TestParseInput(arraytest.ArrayTestCase):
|
|||||||
**raise** Exception
|
**raise** Exception
|
||||||
- **if** all sections are parsed error-free check that the output
|
- **if** all sections are parsed error-free check that the output
|
||||||
is correct
|
is correct
|
||||||
|
- correct example with a single shell and no explicit groups
|
||||||
"""
|
"""
|
||||||
# Scenario 1
|
# Scenario 1
|
||||||
def test_no_group(self):
|
def test_no_group(self):
|
||||||
@ -81,5 +82,27 @@ Groups:
|
|||||||
|
|
||||||
self.assertEqual(res, expected)
|
self.assertEqual(res, expected)
|
||||||
|
|
||||||
|
# Scenario 6
|
||||||
|
def test_example_no_groups(self):
|
||||||
|
conf_pars = ConfigParameters('example_nogroup.cfg')
|
||||||
|
conf_pars.parse_input()
|
||||||
|
# with open('parse_input.output.test', 'wt') as f:
|
||||||
|
# f.write("Shells:\n")
|
||||||
|
# f.write(conf_pars.shells.__repr__() + '\n\n')
|
||||||
|
# f.write("Groups:\n")
|
||||||
|
# f.write(conf_pars.groups.__repr__() + '\n')
|
||||||
|
res = "Shells:\n"
|
||||||
|
res += conf_pars.shells.__repr__() + '\n\n'
|
||||||
|
res += "Groups:\n"
|
||||||
|
res += conf_pars.groups.__repr__()
|
||||||
|
print res
|
||||||
|
|
||||||
|
expected = r"""Shells:
|
||||||
|
[{'ion_list': array([4, 5, 6, 7]), 'user_index': 1, 'lshell': 2}]
|
||||||
|
|
||||||
|
Groups:
|
||||||
|
[{'index': '1', 'emin': -7.6, 'shells': [0], 'emax': 3.0}]"""
|
||||||
|
|
||||||
|
self.assertEqual(res, expected)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user