make datatypes immutable

in order to prevent modifying parameters without automatically
trigger updates, all datatypes must be immutable.

TupleOf and ArrayOf: change from list to tuple
StructOf: use ImmutableDict

most existing code should work properly, the only thing to consider are
equality comparisons with lists, which will result to False all the time

the changes in secop_psi/ppms.py (using tuples instead of lists for status values)
are not really necessary, but lead to less confusing code

Change-Id: I181f412b5cd55af296b2e5120af82449beb03f54
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/22972
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:
2020-04-15 16:56:40 +02:00
parent ae7727dda8
commit da7a027949
4 changed files with 74 additions and 66 deletions

View File

@ -381,10 +381,10 @@ def test_ArrayOf():
with pytest.raises(ValueError):
dt('av')
assert dt([1, 2, 3]) == [1, 2, 3]
assert dt([1, 2, 3]) == (1, 2, 3)
assert dt.export_value([1, 2, 3]) == [1, 2, 3]
assert dt.import_value([1, 2, 3]) == [1, 2, 3]
assert dt.import_value([1, 2, 3]) == (1, 2, 3)
assert dt.format_value([1,2,3]) == '[1, 2, 3] Z'
assert dt.format_value([1,2,3], '') == '[1, 2, 3]'
@ -419,10 +419,10 @@ def test_TupleOf():
with pytest.raises(ValueError):
dt([99, 'X'])
assert dt([1, True]) == [1, True]
assert dt([1, True]) == (1, True)
assert dt.export_value([1, True]) == [1, True]
assert dt.import_value([1, True]) == [1, True]
assert dt.import_value([1, True]) == (1, True)
assert dt.format_value([3,0]) == "(3, False)"