Skip to content

Commit 2f93315

Browse files
authored
Merge pull request #120 from Tigul/main
Test for duplicated symbols after remove_connection
2 parents d42f91f + dac217b commit 2f93315

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/semantic_digital_twin/world.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,6 @@ def add_connection(
701701
:param connection: The connection to add.
702702
"""
703703
connection.add_to_world(self)
704-
for dof in connection.dofs:
705-
if dof._world is None:
706-
self.add_degree_of_freedom(dof)
707704
self.add_kinematic_structure_entity(connection.parent, handle_duplicates)
708705
self.add_kinematic_structure_entity(connection.child, handle_duplicates)
709706

test/test_worlds/test_world.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
RevoluteConnection,
1212
Connection6DoF,
1313
FixedConnection,
14+
OmniDrive,
1415
)
1516
from semantic_digital_twin.exceptions import (
1617
AddingAnExistingSemanticAnnotationError,
@@ -828,3 +829,22 @@ def test_missing_world_modification_context(world_setup):
828829
world, l1, l2, bf, r1, r2 = world_setup
829830
with pytest.raises(MissingWorldModificationContextError):
830831
world.add_semantic_annotation(Handle(l1))
832+
833+
834+
def test_symbol_removal():
835+
world1 = World()
836+
body1 = Body(name=PrefixedName("body1"))
837+
with world1.modify_world():
838+
world1.add_body(body1)
839+
840+
world2 = World()
841+
body2 = Body(name=PrefixedName("body2"))
842+
with world2.modify_world():
843+
world2.add_body(body2)
844+
845+
world1.merge_world(world2)
846+
847+
with world1.modify_world():
848+
world1.remove_connection(body2.parent_connection)
849+
c_root_bf = OmniDrive.create_with_dofs(parent=body1, child=body2, world=world1)
850+
world1.add_connection(c_root_bf)

0 commit comments

Comments
 (0)