aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/WarpX.py
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/WarpX.py
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/WarpX.py')
-rw-r--r--Python/pywarpx/WarpX.py11
1 files changed, 9 insertions, 2 deletions
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()