restore pylammps.py
This commit is contained in:
@ -16,6 +16,10 @@
|
|||||||
# Written by Richard Berger <richard.berger@outlook.com>
|
# Written by Richard Berger <richard.berger@outlook.com>
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
# for python2/3 compatibility
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -758,7 +762,7 @@ class PyLammps(object):
|
|||||||
if self.comm_me > 0:
|
if self.comm_me > 0:
|
||||||
raise Exception("PyLammps.eval() may only be used on MPI rank 0")
|
raise Exception("PyLammps.eval() may only be used on MPI rank 0")
|
||||||
|
|
||||||
value = print('"$(%s)"' % expr).strip()
|
value = self.lmp_print('"$(%s)"' % expr).strip()
|
||||||
try:
|
try:
|
||||||
return float(value)
|
return float(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -843,6 +847,10 @@ class PyLammps(object):
|
|||||||
elements.append(element)
|
elements.append(element)
|
||||||
return elements
|
return elements
|
||||||
|
|
||||||
|
def lmp_print(self, s):
|
||||||
|
""" needed for Python2 compatibility, since print is a reserved keyword """
|
||||||
|
return self.__getattr__("print")(s)
|
||||||
|
|
||||||
def __dir__(self):
|
def __dir__(self):
|
||||||
return sorted(set(['angle_coeff', 'angle_style', 'atom_modify', 'atom_style', 'atom_style',
|
return sorted(set(['angle_coeff', 'angle_style', 'atom_modify', 'atom_style', 'atom_style',
|
||||||
'bond_coeff', 'bond_style', 'boundary', 'change_box', 'communicate', 'compute',
|
'bond_coeff', 'bond_style', 'boundary', 'change_box', 'communicate', 'compute',
|
||||||
|
|||||||
Reference in New Issue
Block a user