From 590ce0b0b93fc9d508ec5ae84c715a06b51ac431 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Tue, 29 Oct 2024 11:19:50 +0100 Subject: [PATCH] Fix bug in ODAPI --- api/od.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/od.py b/api/od.py index 4fda019..1047834 100644 --- a/api/od.py +++ b/api/od.py @@ -68,7 +68,11 @@ class ODAPI: return od.find_incoming_typed_by(self.bottom, tgt=obj, type_node=self.bottom.read_outgoing_elements(self.mm, assoc_name)[0]) def get_all_instances(self, type_name: str, include_subtypes=True): - obj_names = self.type_to_objs[type_name] + if include_subtypes: + all_types = self.cd.transitive_sub_types[type_name] + else: + all_types = set(type_name) + obj_names = [obj_name for type_name in all_types for obj_name in self.type_to_objs[type_name]] return [(obj_name, self.bottom.read_outgoing_elements(self.m, obj_name)[0]) for obj_name in obj_names] def get_type(self, obj: UUID): @@ -92,7 +96,7 @@ class ODAPI: def is_instance(obj: UUID, type_name: str, include_subtypes=True): typ = self.cd.get_type(type_name) - types = set(typ) if not include_subtypes else self.cd.transitive_subtypes[type_name] + types = set(typ) if not include_subtypes else self.cd.transitive_sub_types[type_name] for type_of_obj in self.bottom.read_outgoing_elements(obj, "Morphism"): if type_of_obj in types: return True