aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/Diagnostics.py
diff options
context:
space:
mode:
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)