diff options
author | 2020-01-14 09:37:56 -0800 | |
---|---|---|
committer | 2020-01-14 09:37:56 -0800 | |
commit | 3bf2684c160ea821b94c8791ea01d53ec34f98b1 (patch) | |
tree | aa55f09cd99b4c35b8db073f00a925cf4958ffe7 /Python/pywarpx/Bucket.py | |
parent | ed93568fe37da1acaafc6c770607b152e58c2e9b (diff) | |
parent | 0c593f22cd3c5571ff89ddc32a6b7b205815ead2 (diff) | |
download | WarpX-3bf2684c160ea821b94c8791ea01d53ec34f98b1.tar.gz WarpX-3bf2684c160ea821b94c8791ea01d53ec34f98b1.tar.zst WarpX-3bf2684c160ea821b94c8791ea01d53ec34f98b1.zip |
Merge pull request #593 from dpgrote/fix_picmi_diagnostics
Updated handling of diagnostics in picmi interface
Diffstat (limited to 'Python/pywarpx/Bucket.py')
-rw-r--r-- | Python/pywarpx/Bucket.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Python/pywarpx/Bucket.py b/Python/pywarpx/Bucket.py index 66494a700..6a32c755b 100644 --- a/Python/pywarpx/Bucket.py +++ b/Python/pywarpx/Bucket.py @@ -1,3 +1,5 @@ +import numpy as np + class Bucket(object): """ The purpose of this class is to be a named bucket for holding attributes. @@ -34,9 +36,13 @@ class Bucket(object): # --- The strip is then needed when value is a string. if isinstance(value, str): rhs = value - elif hasattr(value, '__iter__'): - # --- For lists, tuples, and arrays make a space delimited string of the values - rhs = ' '.join(map(repr, value)) + elif np.iterable(value): + if len(value) == 0: + # --- Skip if empty + continue + # --- For lists, tuples, and arrays make a space delimited string of the values. + # --- The lambda is needed in case this is a list of strings. + rhs = ' '.join(map(lambda s : repr(s).strip("'\""), value)) else: rhs = value attrstring = '{0}.{1} = {2}'.format(self.instancename, attr, repr(rhs).strip("'\"")) |