diff options
author | 2020-01-09 15:37:27 -0800 | |
---|---|---|
committer | 2020-01-09 15:37:27 -0800 | |
commit | fdba3b3ed6614eaac6a1a7c57e2cdc26f77eb8ea (patch) | |
tree | 79999eaee318df6071c42d7efe23eb279ff2996d | |
parent | d20a7b866fc2c65519da587b305ff20b3d235ca4 (diff) | |
download | WarpX-fdba3b3ed6614eaac6a1a7c57e2cdc26f77eb8ea.tar.gz WarpX-fdba3b3ed6614eaac6a1a7c57e2cdc26f77eb8ea.tar.zst WarpX-fdba3b3ed6614eaac6a1a7c57e2cdc26f77eb8ea.zip |
For picmi, handle zero length list of values for output
-rw-r--r-- | Python/pywarpx/Bucket.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/pywarpx/Bucket.py b/Python/pywarpx/Bucket.py index 016d6a57e..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,7 +36,10 @@ class Bucket(object): # --- The strip is then needed when value is a string. if isinstance(value, str): rhs = value - elif hasattr(value, '__iter__'): + 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)) |