issue destroying properties

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

issue destroying properties

felix
Hi,

I am having an issue (ValueError) when trying to destroy properties that are used within an "equivalent_to" axiom.
Here is a minimal example:

from owlready2 import get_ontology, destroy_entity, Thing, ObjectProperty
onto = get_ontology("http://example.org/onto-ex.owl")
with onto:
    class c_1(Thing):
        pass
    class c_2(Thing):
        pass
    class op_1(ObjectProperty):
        pass
    c_1.equivalent_to.append(op_1.some(c_2))
    destroy_entity(op_1)
onto.save(file="./onto-ex.owl")

Adapting the destroyer function in prop.py (l. 903 ff) as follows seems to work:

  def destroyer(bnode):
    if bnode == e.storid: return
    if undoer_bnodes: undoer_bnodes.append(bnode)
    class_construct = e.namespace.ontology._bnodes.pop(bnode, None)
    if class_construct:
      for subclass in class_construct.subclasses(True):
        if   isinstance(subclass, EntityClass) or isinstance(subclass, Thing):
#          subclass.is_a.remove(class_construct)
          if class_construct in subclass.is_a:
            subclass.is_a.remove(class_construct)
          elif class_construct in subclass.equivalent_to:
            subclass.equivalent_to.remove(class_construct)

Best,
Felix
Reply | Threaded
Open this post in threaded view
|

Re: issue destroying properties

Jiba
Administrator
Hi,

Thank you for noticing and fixing this problem!

I'll will include the fix in the next release today,

Jiba