diff options
Diffstat (limited to 'Python/pywarpx')
-rw-r--r-- | Python/pywarpx/Bucket.py | 4 | ||||
-rw-r--r-- | Python/pywarpx/WarpX.py | 11 |
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() |