aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx
diff options
context:
space:
mode:
authorGravatar Dave Grote <grote1@llnl.gov> 2018-08-02 14:49:00 -0700
committerGravatar Dave Grote <grote1@llnl.gov> 2018-08-02 14:49:00 -0700
commit010da9f998a7b833e8a0405eed76b6d313656225 (patch)
tree8036a0e799261a5d27e1c67f9f252dcfbd817869 /Python/pywarpx
parentbbd7d61b7a9c8e65d988cfac2833a2265209255f (diff)
downloadWarpX-010da9f998a7b833e8a0405eed76b6d313656225.tar.gz
WarpX-010da9f998a7b833e8a0405eed76b6d313656225.tar.zst
WarpX-010da9f998a7b833e8a0405eed76b6d313656225.zip
Bug fixes in the python interface
Fixed handling species with same name as predefined species. Removed dependency on six
Diffstat (limited to 'Python/pywarpx')
-rw-r--r--Python/pywarpx/Bucket.py4
-rw-r--r--Python/pywarpx/WarpX.py11
2 files changed, 10 insertions, 5 deletions
diff --git a/Python/pywarpx/Bucket.py b/Python/pywarpx/Bucket.py
index cd5c81793..c73b3dac9 100644
--- a/Python/pywarpx/Bucket.py
+++ b/Python/pywarpx/Bucket.py
@@ -1,5 +1,3 @@
-from six import iteritems
-
class Bucket(object):
"""
The purpose of this class is to be a named bucket for holding attributes.
@@ -25,7 +23,7 @@ class Bucket(object):
def attrlist(self):
"Concatenate the attributes into a string"
result = []
- for attr, value in iteritems(self.argvattrs):
+ for attr, value in self.argvattrs.items():
if value is None:
continue
# --- repr is applied to value so that for floats, all of the digits are included.
diff --git a/Python/pywarpx/WarpX.py b/Python/pywarpx/WarpX.py
index d7a37a6fa..f1fb9918a 100644
--- a/Python/pywarpx/WarpX.py
+++ b/Python/pywarpx/WarpX.py
@@ -30,10 +30,17 @@ class WarpX(Bucket):
argv += laser.attrlist()
# --- Search through species_names and add any predefined particle objects in the list.
- # --- assuming that only the built in particle types are being used.
+ particles_list_names = [p.instancename for p in particles_list]
for pstring in particles.species_names.split(' '):
- if hasattr(Particles, pstring):
+ if pstring in particles_list_names:
+ # --- The species is already included in particles_list
+ continue
+ elif hasattr(Particles, pstring):
+ # --- Add the predefined species to particles_list
particles_list.append(getattr(Particles, pstring))
+ particles_list_names.append(pstring)
+ else:
+ raise Exception('Species %s listed in species_names not defined'%pstring)
for particle in particles_list:
argv += particle.attrlist()