From 33c846cd5e10db650547f3d597788426a5d228c8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 17 Jan 2020 09:48:07 -0500 Subject: [PATCH] guard converting thermo output from other output to the screen and do not crash fixes #1844 --- python/lammps.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/python/lammps.py b/python/lammps.py index e8fc240c75..2e597f9e18 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -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):