From 010da9f998a7b833e8a0405eed76b6d313656225 Mon Sep 17 00:00:00 2001 From: Dave Grote Date: Thu, 2 Aug 2018 14:49:00 -0700 Subject: Bug fixes in the python interface Fixed handling species with same name as predefined species. Removed dependency on six --- Python/pywarpx/WarpX.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Python/pywarpx/WarpX.py') 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() -- cgit v1.2.3