Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make model.Entity.specific_asset_id a Set of model.SpecificAssetIds #149

Merged
merged 25 commits into from
Nov 14, 2023
Merged
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
77e0f86
Fix Entity.specificAssetIds in schemas
zrgt Oct 27, 2023
e1fffec
- Set `Entity.specific_asset_id` as `Iterable[SpecificAssetId]`, beca…
zrgt Oct 27, 2023
92e8618
Refactor `check_entity_equal()`&`check_asset_information_equal()`
zrgt Oct 27, 2023
0ed5d4f
Update test files
zrgt Oct 27, 2023
bc66b2a
Update tutorial_serialization_deserialization.py
zrgt Oct 27, 2023
91bfe92
Use getter/setter decorators for global_asset_id
zrgt Oct 29, 2023
0386628
Fix errors from MyPy
zrgt Oct 29, 2023
2f8a731
Fix pycodestyle errors
zrgt Oct 29, 2023
f537658
Fix typehint of specific_asset_id
zrgt Nov 3, 2023
046ee15
Fix wrong example value
zrgt Nov 3, 2023
7a2e341
model.base: fix `ConstrainedList.clear()` atomicity
jkhsjdhjs Nov 4, 2023
ff31f45
model.submodel: remove `_string_constraints` decorator from `Entity`
jkhsjdhjs Nov 4, 2023
7ac9aa6
model.submodel: move `Entity.global_asset_id` string constraint check…
jkhsjdhjs Nov 4, 2023
4b8a7ae
model.submodel: remove duplicate code in `Entity`
jkhsjdhjs Nov 4, 2023
3dcf9ff
model.ass: add `_validate_asset_ids()` function to `AssetInformation`
jkhsjdhjs Nov 4, 2023
b853160
model.{aas, submodel}: add set hook to `{AssetInformation, Entity}.sp…
jkhsjdhjs Nov 4, 2023
39a8c48
model.submodel: assign values correctly in `Entity.__init__`
jkhsjdhjs Nov 4, 2023
6b3de29
model.{aas, submodel}: add getter/setter for `{AssetInformation, Enti…
jkhsjdhjs Nov 4, 2023
47b2e47
model.submodel: verify constraints when `SpecificAssetIds` are added …
jkhsjdhjs Nov 4, 2023
5e0f160
model.{aas, submodel}: improve `{AssetInformation, Entity}.global_ass…
jkhsjdhjs Nov 4, 2023
6fb375d
test.model: add `AssetInformation` tests and improve `Entity` tests
jkhsjdhjs Nov 4, 2023
f11c7f5
Merge branch 'fix/constrained_list_clear_atomicity' into entityfix
jkhsjdhjs Nov 4, 2023
f8a2bf6
Merge pull request #1 from rwth-iat/entityfix
zrgt Nov 7, 2023
9ed5704
Refactor `Entity` and `AssetInformation`
zrgt Nov 7, 2023
0222237
Refactor `Entity` and `AssetInformation`
zrgt Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions basyx/aas/model/base.py
Original file line number Diff line number Diff line change
@@ -1311,6 +1311,10 @@ def extend(self, values: Iterable[_T]) -> None:
self._item_add_hook(v, self._list + v_list[:idx])
self._list = self._list + v_list

def clear(self) -> None:
# clear() repeatedly deletes the last item by default, making it not atomic
del self[:]

@overload
def __getitem__(self, index: int) -> _T: ...

10 changes: 9 additions & 1 deletion test/model/test_base.py
Original file line number Diff line number Diff line change
@@ -1213,7 +1213,15 @@ def hook(itm: int, _list: List[int]) -> None:
self.assertEqual(c_list, [1, 2, 3])
with self.assertRaises(ValueError):
c_list.clear()
self.assertEqual(c_list, [1, 2, 3])
# the default clear() implementation seems to repeatedly delete the last item until the list is empty
# in this case, the last item is 3, which cannot be deleted because it is > 2, thus leaving it unclear whether
# clear() really is atomic. to work around this, the list is reversed, making 1 the last item, and attempting
# to clear again.
c_list.reverse()
with self.assertRaises(ValueError):
c_list.clear()
self.assertEqual(c_list, [3, 2, 1])
c_list.reverse()
del c_list[0:2]
self.assertEqual(c_list, [3])