-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
40 lines (31 loc) · 993 Bytes
/
config.py
File metadata and controls
40 lines (31 loc) · 993 Bytes
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
import copy
from collections.abc import Mapping
class ParaSet(Mapping):
"""
A parameter set used to store the setup for the layers and modules
"""
def __init__(self,**kwargs):
for key, value in kwargs.items():
self.__setattr__( key, value)
def clone(self, **kwargs):
ins = copy.deepcopy(self)
for key, value in kwargs.items():
ins.__setattr__( key, value)
return ins
def update(self, dicts):
for key, val in dicts.items():
self.__setattr__( key, val)
return self.__dict__
def __iter__(self):
for key in self.__dict__.keys():
yield key
def __len__(self):
return len(self.__dict__)
def __getitem__(self, item):
return self.__dict__[item]
def __call__(self, **kwargs):
for key, value in kwargs.items():
self.__setattr__( key, value)
#if __name__ == '__main__':
#
# c = cfg.clone()