diff --git a/python/lammps/core.py b/python/lammps/core.py index 5e51a7bba0..fcd5c76ad5 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -99,7 +99,7 @@ class lammps(object): # load a shared object. try: - if ptr: self.lib = CDLL("",RTLD_GLOBAL) + if ptr is not None: self.lib = CDLL("",RTLD_GLOBAL) except OSError: self.lib = None @@ -329,7 +329,7 @@ class lammps(object): # ptr is the desired instance of LAMMPS # just convert it to ctypes ptr and store in self.lmp - if not ptr: + if ptr is None: # with mpi4py v2+, we can pass MPI communicators to LAMMPS # need to adjust for type of MPI communicator object @@ -338,7 +338,7 @@ class lammps(object): from mpi4py import MPI self.MPI = MPI - if comm: + if comm is not None: if not self.has_mpi_support: raise Exception('LAMMPS not compiled with real MPI library') if not self.has_mpi4py: @@ -354,7 +354,7 @@ class lammps(object): narg = 0 cargs = None - if cmdargs: + if cmdargs is not None: cmdargs.insert(0,"lammps") narg = len(cmdargs) for i in range(narg): @@ -376,7 +376,7 @@ class lammps(object): if self.has_mpi4py and self.has_mpi_support: self.comm = self.MPI.COMM_WORLD self.opened = 1 - if cmdargs: + if cmdargs is not None: cmdargs.insert(0,"lammps") narg = len(cmdargs) for i in range(narg): diff --git a/python/lammps/pylammps.py b/python/lammps/pylammps.py index a6e3578aef..abd4d6da98 100644 --- a/python/lammps/pylammps.py +++ b/python/lammps/pylammps.py @@ -854,30 +854,30 @@ class IPyLammps(PyLammps): """ cmd_args = [group, "image", filename, color, diameter] - if size: + if size is not None: width = size[0] height = size[1] cmd_args += ["size", width, height] - if view: + if view is not None: theta = view[0] phi = view[1] cmd_args += ["view", theta, phi] - if center: + if center is not None: flag = center[0] Cx = center[1] Cy = center[2] Cz = center[3] cmd_args += ["center", flag, Cx, Cy, Cz] - if up: + if up is not None: Ux = up[0] Uy = up[1] Uz = up[2] cmd_args += ["up", Ux, Uy, Uz] - if zoom: + if zoom is not None: cmd_args += ["zoom", zoom] cmd_args.append("modify backcolor " + background_color)