aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/Constants.py
diff options
context:
space:
mode:
authorGravatar MaxThevenet <mthevenet@lbl.gov> 2019-03-29 15:15:54 +0100
committerGravatar GitHub <noreply@github.com> 2019-03-29 15:15:54 +0100
commit0605ce27e604549c3e93f2e9e342bd356000cf9e (patch)
tree6cdb42dfacedbefbc231c0e7d9674b825cf95696 /Python/pywarpx/Constants.py
parentb534b688dedd48b645bac47854260321e7960bf9 (diff)
parent761c82556e31de274d1e4c356bf81189abb1a1aa (diff)
downloadWarpX-0605ce27e604549c3e93f2e9e342bd356000cf9e.tar.gz
WarpX-0605ce27e604549c3e93f2e9e342bd356000cf9e.tar.zst
WarpX-0605ce27e604549c3e93f2e9e342bd356000cf9e.zip
Merge pull request #79 from ECP-WarpX/parser
use parser's setConstant function instead of using string replacement
Diffstat (limited to 'Python/pywarpx/Constants.py')
-rw-r--r--Python/pywarpx/Constants.py22
1 files changed, 3 insertions, 19 deletions
diff --git a/Python/pywarpx/Constants.py b/Python/pywarpx/Constants.py
index eafddd72e..20107ebc4 100644
--- a/Python/pywarpx/Constants.py
+++ b/Python/pywarpx/Constants.py
@@ -3,30 +3,14 @@ from .Bucket import Bucket
class Constants(Bucket):
"""
The purpose of this class is to be hold user defined constants
- The constants will be concatenated into names and values string.
"""
def __init__(self):
- Bucket.__init__(self, 'constants')
+ Bucket.__init__(self, 'my_constants')
def __setattr__(self, name, value):
# Make sure that any constants redefined have a consistent value
if name in self.argvattrs:
- assert self.argvattrs[name] == value, Exception('In consistent values given for user defined constants')
+ assert self.argvattrs[name] == value, Exception('An consistent values given for user defined constants')
Bucket.__setattr__(self, name, value)
- def attrlist(self):
- "Concatenate the attributes into a string"
- if self.argvattrs:
- names = ''
- values = ''
- for attr, value in self.argvattrs.items():
- names += ' ' + attr
- values += ' {}'.format(value)
- return ['constants.use_my_constants = 1',
- 'constants.constant_names = ' + names,
- 'constants.constant_values = ' + values]
- else:
- return []
-
-
-constants = Constants()
+my_constants = Constants()