Explicitly check for None

This commit is contained in:
Richard Berger
2021-10-26 15:00:12 -04:00
parent fe9dfc6095
commit 008013ddfb
2 changed files with 10 additions and 10 deletions

View File

@ -99,7 +99,7 @@ class lammps(object):
# load a shared object. # load a shared object.
try: try:
if ptr: self.lib = CDLL("",RTLD_GLOBAL) if ptr is not None: self.lib = CDLL("",RTLD_GLOBAL)
except OSError: except OSError:
self.lib = None self.lib = None
@ -329,7 +329,7 @@ class lammps(object):
# ptr is the desired instance of LAMMPS # ptr is the desired instance of LAMMPS
# just convert it to ctypes ptr and store in self.lmp # 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 # with mpi4py v2+, we can pass MPI communicators to LAMMPS
# need to adjust for type of MPI communicator object # need to adjust for type of MPI communicator object
@ -338,7 +338,7 @@ class lammps(object):
from mpi4py import MPI from mpi4py import MPI
self.MPI = MPI self.MPI = MPI
if comm: if comm is not None:
if not self.has_mpi_support: if not self.has_mpi_support:
raise Exception('LAMMPS not compiled with real MPI library') raise Exception('LAMMPS not compiled with real MPI library')
if not self.has_mpi4py: if not self.has_mpi4py:
@ -354,7 +354,7 @@ class lammps(object):
narg = 0 narg = 0
cargs = None cargs = None
if cmdargs: if cmdargs is not None:
cmdargs.insert(0,"lammps") cmdargs.insert(0,"lammps")
narg = len(cmdargs) narg = len(cmdargs)
for i in range(narg): for i in range(narg):
@ -376,7 +376,7 @@ class lammps(object):
if self.has_mpi4py and self.has_mpi_support: if self.has_mpi4py and self.has_mpi_support:
self.comm = self.MPI.COMM_WORLD self.comm = self.MPI.COMM_WORLD
self.opened = 1 self.opened = 1
if cmdargs: if cmdargs is not None:
cmdargs.insert(0,"lammps") cmdargs.insert(0,"lammps")
narg = len(cmdargs) narg = len(cmdargs)
for i in range(narg): for i in range(narg):

View File

@ -854,30 +854,30 @@ class IPyLammps(PyLammps):
""" """
cmd_args = [group, "image", filename, color, diameter] cmd_args = [group, "image", filename, color, diameter]
if size: if size is not None:
width = size[0] width = size[0]
height = size[1] height = size[1]
cmd_args += ["size", width, height] cmd_args += ["size", width, height]
if view: if view is not None:
theta = view[0] theta = view[0]
phi = view[1] phi = view[1]
cmd_args += ["view", theta, phi] cmd_args += ["view", theta, phi]
if center: if center is not None:
flag = center[0] flag = center[0]
Cx = center[1] Cx = center[1]
Cy = center[2] Cy = center[2]
Cz = center[3] Cz = center[3]
cmd_args += ["center", flag, Cx, Cy, Cz] cmd_args += ["center", flag, Cx, Cy, Cz]
if up: if up is not None:
Ux = up[0] Ux = up[0]
Uy = up[1] Uy = up[1]
Uz = up[2] Uz = up[2]
cmd_args += ["up", Ux, Uy, Uz] cmd_args += ["up", Ux, Uy, Uz]
if zoom: if zoom is not None:
cmd_args += ["zoom", zoom] cmd_args += ["zoom", zoom]
cmd_args.append("modify backcolor " + background_color) cmd_args.append("modify backcolor " + background_color)