Add PyLammps.atoms test and fix bug with -echo screen/both

This commit is contained in:
Richard Berger
2020-09-16 12:48:20 -04:00
parent 9cdd35e625
commit 2270d8f4ec
2 changed files with 20 additions and 2 deletions

View File

@ -1974,6 +1974,14 @@ class PyLammps(object):
"""
def __init__(self, name="", cmdargs=None, ptr=None, comm=None):
self.has_echo = False
if cmdargs:
if '-echo' in cmdargs:
idx = cmdargs.index('-echo')
# ensures that echo line is ignored during output capture
self.has_echo = idx+1 < len(cmdargs) and cmdargs[idx+1] in ('screen', 'both')
if ptr:
if isinstance(ptr,PyLammps):
self.lmp = ptr.lmp
@ -2323,7 +2331,8 @@ class PyLammps(object):
cmd_args = [name] + [str(x) for x in args]
with OutputCapture() as capture:
self.command(' '.join(cmd_args))
cmd = ' '.join(cmd_args)
self.command(cmd)
output = capture.output
if 'verbose' in kwargs and kwargs['verbose']:
@ -2331,6 +2340,9 @@ class PyLammps(object):
lines = output.splitlines()
if self.has_echo:
lines = lines[1:]
if len(lines) > 1:
return lines
elif len(lines) == 1: