Skip to content

Commit

Permalink
test complement of
Browse files Browse the repository at this point in the history
  • Loading branch information
LckyLke committed Dec 1, 2024
1 parent 53462bd commit cc3d7d9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_OWLObjectComplementOf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from owlapy.class_expression import (
OWLClass,
OWLObjectComplementOf,
)
from owlapy.iri import IRI
from owlapy.owl_reasoner import SyncReasoner
from owlapy.owl_ontology_manager import SyncOntologyManager

def test_complement_of_owl_thing_is_owl_nothing():
owl_thing = OWLClass(IRI.create('http://www.w3.org/2002/07/owl#Thing'))
owl_nothing = OWLClass(IRI.create('http://www.w3.org/2002/07/owl#Nothing'))
complement_of_thing = OWLObjectComplementOf(owl_thing)
complement_of_nothing = OWLObjectComplementOf(owl_nothing)
mgr = SyncOntologyManager()
onto = mgr.load_ontology("KGs/Mutagenesis/mutagenesis.owl")
reasoner = SyncReasoner(onto, "HermiT")
equivalent_classes = reasoner.equivalent_classes(complement_of_thing)
assert owl_nothing in equivalent_classes
individuals_thing = reasoner.instances(owl_thing)
individuals_complement_of_nothing = reasoner.instances(complement_of_nothing)
assert individuals_thing == individuals_complement_of_nothing


def test_complement_of_owl_nothing_is_owl_thing():
owl_thing = OWLClass(IRI.create('http://www.w3.org/2002/07/owl#Thing'))
owl_nothing = OWLClass(IRI.create('http://www.w3.org/2002/07/owl#Nothing'))
complement_of_nothing = OWLObjectComplementOf(owl_nothing)
mgr = SyncOntologyManager()
onto = mgr.load_ontology("KGs/Mutagenesis/mutagenesis.owl")
reasoner = SyncReasoner(onto, "HermiT")
individuals_thing = reasoner.instances(owl_thing)
individuals_complement_of_nothing = reasoner.instances(complement_of_nothing)
assert individuals_thing == individuals_complement_of_nothing

def test_double_complement_is_identity():
class_iri = IRI.create('http://example.org/MyClass')
my_class = OWLClass(class_iri)
complement = OWLObjectComplementOf(my_class)
double_complement = OWLObjectComplementOf(complement)
assert my_class == double_complement

0 comments on commit cc3d7d9

Please sign in to comment.