introduced Datatype.copy

as Datatype got mutable, it has to be copied when inherited.
Params.copy must call the introduced method Datatype.copy.

in addition:
- fixed bugs in ScaledInteger.__repr__ and datatypes.DATATYPES['struct']
- do not export unit from Parameters

Change-Id: Id552c33843b1b2bedffc68d1bd909705dcfb5605
Reviewed-on: https://forge.frm2.tum.de/review/20324
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2019-04-04 10:36:00 +02:00
parent 0eb68e54be
commit 2ebf62fa70
4 changed files with 56 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ class Accessible(CountedObj):
['%s=%r' % (k, v) for k, v in sorted(self.__dict__.items())]))
def copy(self):
# return a copy of ourselfs
'''return a copy of ourselfs'''
props = self.__dict__.copy()
return type(self)(**props)
@@ -146,11 +146,15 @@ class Parameter(Accessible):
if ctr is not None:
self.ctr = ctr
def copy(self):
'''return a copy of ourselfs'''
result = Accessible.copy(self)
result.datatype = result.datatype.copy()
return result
def for_export(self):
# used for serialisation only
res = self.exported_properties()
if self.unit:
res['unit'] = self.unit
return res
def export_value(self):