From 899c5401ab429222eb6d2dd5a3b751cb74e30ce4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 18 Jul 2016 23:14:29 -0400 Subject: [PATCH] accept PyLammps() and lammps() objects for ptr argument and initialize as needed --- python/lammps.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/lammps.py b/python/lammps.py index 836625188d..7db1735d19 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -392,7 +392,13 @@ class PyLammps(object): def __init__(self,name="",cmdargs=None,ptr=None,comm=None): if ptr: - self.lmp = ptr + if isinstance(ptr,PyLammps): + self.lmp = ptr.lmp + elif isinstance(ptr,lammps): + self.lmp = ptr + else: + self.lmp = None + raise TypeError('Unsupported type passed as "ptr"') else: self.lmp = lammps(name=name,cmdargs=cmdargs,ptr=None,comm=comm) print("LAMMPS output is captured by PyLammps wrapper")