From 460de7672407a7435082f36076dde86852afd8c4 Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Mon, 25 Nov 2024 14:03:46 +0100 Subject: [PATCH] fix for #112 --- owlapy/owl_ontology.py | 7 +++++-- owlapy/owl_ontology_manager.py | 9 ++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/owlapy/owl_ontology.py b/owlapy/owl_ontology.py index 930360d0..5f400401 100644 --- a/owlapy/owl_ontology.py +++ b/owlapy/owl_ontology.py @@ -784,7 +784,7 @@ class Ontology(AbstractOWLOntology): _world: owlready2.World is_modified: bool - def __init__(self, manager: _OM, ontology_iri: IRI, load: bool): + def __init__(self, manager: _OM, ontology_iri: IRI | str, load: bool): """Represents an Ontology in Ontolearn. Args: @@ -796,7 +796,10 @@ def __init__(self, manager: _OM, ontology_iri: IRI, load: bool): self._iri = ontology_iri self._world = manager._world self.is_modified = False - onto = self._world.get_ontology(ontology_iri.as_str()) + if isinstance(ontology_iri,str): + onto = self._world.get_ontology(ontology_iri) + else: + onto = self._world.get_ontology(ontology_iri.as_str()) if load: onto = onto.load() self._onto = onto diff --git a/owlapy/owl_ontology_manager.py b/owlapy/owl_ontology_manager.py index f0d03795..4297969b 100644 --- a/owlapy/owl_ontology_manager.py +++ b/owlapy/owl_ontology_manager.py @@ -89,13 +89,8 @@ def create_ontology(self, iri: Union[str, IRI] = None) -> Ontology: assert isinstance(iri, IRI), "iri either must be string or an instance of IRI Class" return Ontology(self, iri, load=False) - def load_ontology(self, path: Union[IRI, str] = None) -> Ontology: - if isinstance(path, str): - path_iri = IRI.create(path) - else: - assert isinstance(path, IRI), "iri either must be string or an instance of IRI Class" - path_iri=path - return Ontology(self, path_iri, load=True) + def load_ontology(self, path: str = None) -> Ontology: + return Ontology(self, path, load=True) def apply_change(self, change: AbstractOWLOntologyChange): if isinstance(change, AddImport):