allow to convert numpy arrays to ArrayOf
accept all sequences instead of just tuple / list + change Module.announceUpdate to convert value before comparing with previous one (comparing will not work with numpy arrays) Change-Id: I5eceef4297607107e2dde688af2833d3651a8775 Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/28525 Tested-by: Markus Zolliker <markus.zolliker@psi.ch> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
ab2fe6200a
commit
33a7c56fa2
@ -760,7 +760,7 @@ class ArrayOf(DataType):
|
||||
|
||||
def __call__(self, value):
|
||||
"""validate an external representation to an internal one"""
|
||||
if isinstance(value, (tuple, list)):
|
||||
try:
|
||||
# check number of elements
|
||||
if self.minlen is not None and len(value) < self.minlen:
|
||||
raise BadValueError(
|
||||
@ -771,8 +771,9 @@ class ArrayOf(DataType):
|
||||
'Array too big, holds at most %d elements!' % self.minlen)
|
||||
# apply subtype valiation to all elements and return as list
|
||||
return tuple(self.members(elem) for elem in value)
|
||||
raise BadValueError(
|
||||
'Can not convert %s to ArrayOf DataType!' % repr(value))
|
||||
except TypeError:
|
||||
raise BadValueError('%s can not be converted to ArrayOf DataType!'
|
||||
% type(value).__name__) from None
|
||||
|
||||
def export_value(self, value):
|
||||
"""returns a python object fit for serialisation"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user