-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbase.py
53 lines (39 loc) · 1.37 KB
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import logging
from ds import set_parameter
log = logging.getLogger(__name__)
class MaterialProperty(object):
def __init__(self, value):
self.value = value
def __lt__(self, other):
return self.value < other
def __le__(self, other):
return self.value <= other
def __eq__(self, other):
return self.value == other
def __ne__(self, other):
return self.value != other
def __gt__(self, other):
return self.value > other
def __ge__(self, other):
return self.value >= other
class Material(object):
name = 'isolator'
def __init__(self, **kwargs):
self.__parameters = []
for name, value in kwargs.items():
setattr(self, name, MaterialProperty(value))
def __repr__(self):
return self.name
def set_parameters_for(self, device_name, region_name):
props = [
p for p in dir(self)
if not p.startswith('_') and isinstance(getattr(self, p), MaterialProperty)
]
for pname in props:
set_parameter(
device=device_name,
region=region_name,
name=pname, value=getattr(self, pname).value
)
log.debug('set_parameter(device={}, region={}, name={}, value={})'.format(
device_name, region_name, pname, getattr(self, pname).value))