From a867e72fd367c1958f28af49e33ab0de80f92648 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 5 Sep 2024 17:38:22 +0500 Subject: [PATCH] rename get_elements_using_pset -> get_elements_by_pset for consistency To be consistent with other get_elements_by_xxx methods. --- src/bonsai/bonsai/bim/module/pset/data.py | 2 +- .../ifcopenshell/api/pset/assign_pset.py | 6 +++--- .../ifcopenshell/api/pset/unassign_pset.py | 4 ++-- .../ifcopenshell/api/pset/unshare_pset.py | 6 +++--- src/ifcopenshell-python/ifcopenshell/util/element.py | 2 +- src/ifcopenshell-python/test/api/pset/test_unshare_pset.py | 2 +- src/ifcopenshell-python/test/util/test_element.py | 2 +- src/ifcpatch/ifcpatch/recipes/UnsharePsets.py | 2 +- src/ifcpatch/test/test_UnsharePsets.py | 6 +++--- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/pset/data.py b/src/bonsai/bonsai/bim/module/pset/data.py index 58cecfa83a..c22ee88053 100644 --- a/src/bonsai/bonsai/bim/module/pset/data.py +++ b/src/bonsai/bonsai/bim/module/pset/data.py @@ -54,7 +54,7 @@ class Data: ) for name, data in sorted(psetqtos.items()): pset = ifc_file.by_id(data["id"]) - pset_uses = ifcopenshell.util.element.get_elements_using_pset(pset) + pset_uses = ifcopenshell.util.element.get_elements_by_pset(pset) results.append( { "id": data["id"], diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/assign_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/assign_pset.py index 028f49f05f..ed309944a1 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/assign_pset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/assign_pset.py @@ -44,19 +44,19 @@ def assign_pset( element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall") ifcopenshell.api.pset.assign_pset(model, [element], pset) # Pset is now assigned. - assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element} + assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element} element1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall") element2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall") ifcopenshell.api.pset.assign_pset(model, [element1, element2], pset) # Pset is now shared by multiple elements. - assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element, element1, element2} + assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element, element1, element2} # Same for element types. element_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType") ifcopenshell.api.pset.assign_pset(model, [element_type], type_pset) # Pset is now assigned to the type. - assert ifcopenshell.util.element.get_elements_using_pset(type_pset) == {element_type} + assert ifcopenshell.util.element.get_elements_by_pset(type_pset) == {element_type} """ is_ifc2x3 = file.schema == "IFC2X3" diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/unassign_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/unassign_pset.py index bcd78c79ae..24256f77fe 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/unassign_pset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/unassign_pset.py @@ -41,11 +41,11 @@ def unassign_pset( ifcopenshell.api.pset.assign_pset(self.file, [element1, element2], pset) # Pset is now shared by 2 elements. - assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element1, element2} + assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element1, element2} ifcopenshell.api.pset.unassign_pset(self.file, [element2], pset) # Pset was unassigned from element2. - assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element1} + assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element1} """ is_ifc2x3 = file.schema == "IFC2X3" diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/unshare_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/unshare_pset.py index c18458228f..a1c29046ea 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/unshare_pset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/unshare_pset.py @@ -45,17 +45,17 @@ def unshare_pset( ifcopenshell.api.pset.assign_pset(self.file, [element1, element2], pset) # Pset is now shared by 2 elements. - assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element1, element2} + assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element1, element2} new_psets = ifcopenshell.api.pset.unshare_pset(self.file, [element2], pset) # element2 was unassigned from the original pset. - assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element1} + assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element1} new_pset = new_psets[0] # New pset was created and was assigned to element2. assert new_pset != pset - assert ifcopenshell.util.element.get_elements_using_pset(new_pset) == {element2} + assert ifcopenshell.util.element.get_elements_by_pset(new_pset) == {element2} """ products_occurrences: set[ifcopenshell.entity_instance] = set() products_types: set[ifcopenshell.entity_instance] = set() diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index 9a35ed727d..c666a3eea5 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -441,7 +441,7 @@ def get_properties( return results -def get_elements_using_pset(pset: ifcopenshell.entity_instance) -> set[ifcopenshell.entity_instance]: +def get_elements_by_pset(pset: ifcopenshell.entity_instance) -> set[ifcopenshell.entity_instance]: """Retrieve the elements (or element types) that are using the provided property set.""" is_ifc2x3 = pset.file.schema == "IFC2X3" elements = set() diff --git a/src/ifcopenshell-python/test/api/pset/test_unshare_pset.py b/src/ifcopenshell-python/test/api/pset/test_unshare_pset.py index 1b752af1aa..3d3e75afe9 100644 --- a/src/ifcopenshell-python/test/api/pset/test_unshare_pset.py +++ b/src/ifcopenshell-python/test/api/pset/test_unshare_pset.py @@ -41,7 +41,7 @@ class TestUnsharePset(test.bootstrap.IFC4): used_elements = set() for pset in psets: - pset_elements = ifcopenshell.util.element.get_elements_using_pset(pset) + pset_elements = ifcopenshell.util.element.get_elements_by_pset(pset) assert len(pset_elements) == 1 used_elements.update(pset_elements) diff --git a/src/ifcopenshell-python/test/util/test_element.py b/src/ifcopenshell-python/test/util/test_element.py index 658b994c75..bfeb7ddb66 100644 --- a/src/ifcopenshell-python/test/util/test_element.py +++ b/src/ifcopenshell-python/test/util/test_element.py @@ -266,7 +266,7 @@ class TestGetElementsUsingPset(test.bootstrap.IFC4): element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType") pset = self.file.create_entity("IfcPropertySet") ifcopenshell.api.pset.assign_pset(self.file, [element, element_type], pset) - assert subject.get_elements_using_pset(pset) == {element, element_type} + assert subject.get_elements_by_pset(pset) == {element, element_type} class TestGetElementsUsingPsetIFC2X3(test.bootstrap.IFC2X3, TestGetElementsUsingPset): ... diff --git a/src/ifcpatch/ifcpatch/recipes/UnsharePsets.py b/src/ifcpatch/ifcpatch/recipes/UnsharePsets.py index 9ea882d2a1..3769008971 100644 --- a/src/ifcpatch/ifcpatch/recipes/UnsharePsets.py +++ b/src/ifcpatch/ifcpatch/recipes/UnsharePsets.py @@ -65,7 +65,7 @@ class Patcher: all_psets = self.file.by_type("IfcPropertySetDefinition") psets: dict[ifcopenshell.entity_instance, set[ifcopenshell.entity_instance]] = {} for pset in all_psets: - elements = ifcopenshell.util.element.get_elements_using_pset(pset) + elements = ifcopenshell.util.element.get_elements_by_pset(pset) # Skip non shared psets. if len(elements) < 2: continue diff --git a/src/ifcpatch/test/test_UnsharePsets.py b/src/ifcpatch/test/test_UnsharePsets.py index 29b4c71425..d2226223bc 100644 --- a/src/ifcpatch/test/test_UnsharePsets.py +++ b/src/ifcpatch/test/test_UnsharePsets.py @@ -38,7 +38,7 @@ class TestUnsharePsets(test.bootstrap.IFC4): used_elements = set() for pset in psets: - pset_elements = ifcopenshell.util.element.get_elements_using_pset(pset) + pset_elements = ifcopenshell.util.element.get_elements_by_pset(pset) assert len(pset_elements) == 1 used_elements.update(pset_elements) @@ -81,13 +81,13 @@ class TestUnsharePsets(test.bootstrap.IFC4): psets.remove(shared_pset) used_elements = set() for pset in psets: - pset_elements = ifcopenshell.util.element.get_elements_using_pset(pset) + pset_elements = ifcopenshell.util.element.get_elements_by_pset(pset) assert len(pset_elements) == 1 used_elements.update(pset_elements) assert used_elements == set(elements) # Leave shared pset untouched as it's not part of the provided query. - assert ifcopenshell.util.element.get_elements_using_pset(shared_pset) == set(shared_pset_elements) + assert ifcopenshell.util.element.get_elements_by_pset(shared_pset) == set(shared_pset_elements) class TestUnsharePsetsIFC2X3(test.bootstrap.IFC2X3, TestUnsharePsets):