aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/Diagnostics.py
diff options
context:
space:
mode:
authorGravatar David Grote <grote1@llnl.gov> 2020-05-14 16:00:36 -0700
committerGravatar GitHub <noreply@github.com> 2020-05-14 16:00:36 -0700
commitda0a1f4917ec3cd7e481ce225780980a021180e8 (patch)
treeaf197021330a43edc6945347882c500866f83285 /Python/pywarpx/Diagnostics.py
parent4a65dd2ae17b69383d505ab3ff6b6c17747e59b7 (diff)
downloadWarpX-da0a1f4917ec3cd7e481ce225780980a021180e8.tar.gz
WarpX-da0a1f4917ec3cd7e481ce225780980a021180e8.tar.zst
WarpX-da0a1f4917ec3cd7e481ce225780980a021180e8.zip
Implemented new particle diagnostics in picmi (#984)
* Implemented new particle diagnostics in picmi * Cleaned up picmi adding new particle diagnostics * In PICMI examples, use name option for diagnostics * For travis, update ubuntu version to bionic
Diffstat (limited to 'Python/pywarpx/Diagnostics.py')
-rw-r--r--Python/pywarpx/Diagnostics.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/Python/pywarpx/Diagnostics.py b/Python/pywarpx/Diagnostics.py
index 25d9ae958..4846a88c8 100644
--- a/Python/pywarpx/Diagnostics.py
+++ b/Python/pywarpx/Diagnostics.py
@@ -6,6 +6,20 @@
from .Bucket import Bucket
-diagnostics = Bucket('diagnostics', diags_names=[])
-diagnostics_list = []
+diagnostics = Bucket('diagnostics', _diagnostics_dict={})
+
+class Diagnostic(Bucket):
+ """
+ This is the same as a Bucket, but checks that any attributes are always given the same value.
+ """
+ def add_new_attr_with_check(self, name, value):
+ if name.startswith('_'):
+ self._localsetattr(name, value)
+ else:
+ if name in self.argvattrs:
+ assert value == self.argvattrs[name], Exception(f'Diagnostic attributes not consistent for {self.instancename}')
+ self.argvattrs[name] = value
+
+ def __setattr__(self, name, value):
+ self.add_new_attr_with_check(name, value)