Skip to content

Commit

Permalink
Merge pull request #119 from dice-group/complement_tests
Browse files Browse the repository at this point in the history
Complement tests
  • Loading branch information
Demirrr authored Dec 2, 2024
2 parents 6cfd36a + 097a0c6 commit 5bb557a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_OWLObjectComplementOf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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 5bb557a

Please sign in to comment.