Commit 4fa7e25d authored by Charlles Abreu's avatar Charlles Abreu
Browse files

Safer periodic attribute reading in ForceField

parent 2507ee7f
...@@ -87,7 +87,11 @@ def _parseFunctions(element): ...@@ -87,7 +87,11 @@ def _parseFunctions(element):
elif key.endswith('min') or key.endswith('max'): elif key.endswith('min') or key.endswith('max'):
params[key] = float(function.attrib[key]) params[key] = float(function.attrib[key])
if functionType.startswith('Continuous'): if functionType.startswith('Continuous'):
params['periodic'] = eval(function.attrib.get('periodic', 'False').title()) periodicStr = function.attrib.get('periodic', 'false').lower()
if periodicStr in ['true', 'false', 'yes', 'no', '1', '0']:
params['periodic'] = periodicStr in ['true', 'yes', '1']
else:
raise ValueError('ForceField: non-boolean value for periodic attribute in tabulated function definition')
functions.append((function.attrib['name'], functionType, values, params)) functions.append((function.attrib['name'], functionType, values, params))
return functions return functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment