guard converting thermo output from other output to the screen and do not crash

fixes #1844
This commit is contained in:
Axel Kohlmeyer 2020-01-17 09:48:07 -05:00
parent a53202bad2
commit 33c846cd5e
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 12 additions and 3 deletions

View File

@ -1029,10 +1029,19 @@ def get_thermo_data(output):
r = {'thermo' : thermo_data }
runs.append(namedtuple('Run', list(r.keys()))(*list(r.values())))
elif in_run and len(columns) > 0:
values = [float(x) for x in line.split()]
items = line.split()
# Convert thermo output and store it.
# It must have the same number of columns and
# all of them must be convertable to floats.
# Otherwise we ignore the line
if len(items) == len(columns):
try:
values = [float(x) for x in items]
for i, col in enumerate(columns):
current_run[col].append(values[i])
except ValueError:
pass
for i, col in enumerate(columns):
current_run[col].append(values[i])
return runs
class PyLammps(object):