Skip to content

Commit

Permalink
Merge pull request #127 from dice-group/bug_fixing
Browse files Browse the repository at this point in the history
Bug fixing & Version increase to 1.4.0
  • Loading branch information
alkidbaci authored Feb 4, 2025
2 parents 7972d4f + 2ab36a2 commit 6601ac6
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- main
- documentation # just for testing
pull_request:
branches:
- main

jobs:
docs:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
[![Downloads](https://static.pepy.tech/badge/owlapy)](https://pepy.tech/project/owlapy)
[![Downloads](https://img.shields.io/pypi/dm/owlapy)](https://pypi.org/project/owlapy/)
[![Coverage](https://img.shields.io/badge/coverage-78%25-green)](https://dice-group.github.io/owlapy/usage/further_resources.html#coverage-report)
[![Pypi](https://img.shields.io/badge/pypi-1.3.3-blue)](https://pypi.org/project/owlapy/1.3.3/)
[![Docs](https://img.shields.io/badge/documentation-1.3.3-yellow)](https://dice-group.github.io/owlapy/usage/main.html)
[![Pypi](https://img.shields.io/badge/pypi-1.4.0-blue)](https://pypi.org/project/owlapy/1.4.0/)
[![Docs](https://img.shields.io/badge/documentation-1.4.0-yellow)](https://dice-group.github.io/owlapy/usage/main.html)

![OWLAPY](docs/_static/images/owlapy_logo.png)

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

project = 'OWLAPY'
author = 'Ontolearn Team'
release = '1.3.3'
release = '1.4.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/main.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# About owlapy

**Version:** owlapy 1.3.3
**Version:** owlapy 1.4.0

**GitHub repository:** [https://github.com/dice-group/owlapy](https://github.com/dice-group/owlapy)

Expand Down
2 changes: 1 addition & 1 deletion owlapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .converter import owl_expression_to_sparql, owl_expression_to_sparql_with_confusion_matrix
from .owl_ontology_manager import OntologyManager

__version__ = '1.3.3'
__version__ = '1.4.0'

__all__ = [
'owl_expression_to_dl', 'owl_expression_to_manchester',
Expand Down
12 changes: 9 additions & 3 deletions owlapy/owl_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ def get_bottom_entity(cls) -> OWLClass:
return OWLNothing

def _hierarchy_down_generator(self, reasoner: AbstractOWLReasoner) -> Iterable[Tuple[OWLClass, Iterable[OWLClass]]]:
clss = set(reasoner.get_root_ontology().classes_in_signature())
clss.add(OWLNothing)
yield from ((_, reasoner.sub_classes(_, direct=True))
for _ in reasoner.get_root_ontology().classes_in_signature())
for _ in clss)

def sub_classes(self, entity: OWLClass, direct: bool = True) -> Iterable[OWLClass]:
yield from self.children(entity, direct)
Expand Down Expand Up @@ -298,10 +300,12 @@ def get_bottom_entity(cls) -> OWLObjectProperty:

def _hierarchy_down_generator(self, reasoner: AbstractOWLReasoner) \
-> Iterable[Tuple[OWLObjectProperty, Iterable[OWLObjectProperty]]]:
o_props = set(reasoner.get_root_ontology().object_properties_in_signature())
o_props.add(OWLBottomObjectProperty)
return ((_, map(lambda _: cast(OWLObjectProperty, _),
filter(lambda _: isinstance(_, OWLObjectProperty),
reasoner.sub_object_properties(_, direct=True))))
for _ in reasoner.get_root_ontology().object_properties_in_signature())
for _ in o_props)

def sub_object_properties(self, entity: OWLObjectProperty, direct: bool = True) -> Iterable[OWLObjectProperty]:
yield from self.children(entity, direct)
Expand Down Expand Up @@ -346,8 +350,10 @@ def get_bottom_entity(cls) -> OWLDataProperty:

def _hierarchy_down_generator(self, reasoner: AbstractOWLReasoner) \
-> Iterable[Tuple[OWLDataProperty, Iterable[OWLDataProperty]]]:
d_props = set(reasoner.get_root_ontology().data_properties_in_signature())
d_props.add(OWLBottomDataProperty)
return ((_, reasoner.sub_data_properties(_, direct=True))
for _ in reasoner.get_root_ontology().data_properties_in_signature())
for _ in d_props)

def sub_data_properties(self, entity: OWLDataProperty, direct: bool = True):
yield from self.children(entity, direct)
Expand Down
25 changes: 16 additions & 9 deletions owlapy/owl_reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,31 @@ def reset(self):

def data_property_domains(self, pe: OWLDataProperty, direct: bool = False) -> Iterable[OWLClassExpression]:
domains = {d.get_domain() for d in self.get_root_ontology().data_property_domain_axioms(pe)}
super_domains = set(chain.from_iterable([self.super_classes(d) for d in domains]))
yield from domains - super_domains
sub_domains = set(chain.from_iterable([self.sub_classes(d) for d in domains]))
yield from domains - sub_domains
if not direct:
yield from super_domains
yield from sub_domains

def object_property_domains(self, pe: OWLObjectProperty, direct: bool = False) -> Iterable[OWLClassExpression]:
domains = {d.get_domain() for d in self.get_root_ontology().object_property_domain_axioms(pe)}
super_domains = set(chain.from_iterable([self.super_classes(d) for d in domains]))
yield from domains - super_domains
sub_domains = set(chain.from_iterable([self.sub_classes(d) for d in domains]))
yield from domains - sub_domains
if not direct:
yield from super_domains
yield from sub_domains

def object_property_ranges(self, pe: OWLObjectProperty, direct: bool = False) -> Iterable[OWLClassExpression]:
ranges = {r.get_range() for r in self.get_root_ontology().object_property_range_axioms(pe)}
super_ranges = set(chain.from_iterable([self.super_classes(d) for d in ranges]))
yield from ranges - super_ranges
sub_ranges = set(chain.from_iterable([self.sub_classes(d) for d in ranges]))
yield from ranges - sub_ranges
if not direct:
yield from super_ranges
yield from sub_ranges

def data_property_ranges(self, pe: OWLDataProperty, direct: bool = True) -> Iterable[OWLClassExpression]:
if direct:
yield from [r.get_range() for r in self.get_root_ontology().data_property_range_axioms(pe)]
else:
# hierarchy of data types is not considered.
return NotImplemented()

def equivalent_classes(self, ce: OWLClassExpression, only_named: bool = True) -> Iterable[OWLClassExpression]:
seen_set = {ce}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
setup(
name="owlapy",
description="OWLAPY is a Python Framework for creating and manipulating OWL Ontologies.",
version="1.3.3",
version="1.4.0",
packages=find_packages(),
include_package_data=True,
package_data={'owlapy': ['jar_dependencies/*.jar'],},
Expand Down
10 changes: 5 additions & 5 deletions tests/test_owlapy_ontology_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,17 +492,17 @@ def test_add_remove_axiom(self):
self.assertNotIn(OWLObjectUnionOf([person, person_sibling]),
list(reasoner.object_property_domains(has_sibling, direct=True)))

self.assertNotIn(sister, list(reasoner.object_property_ranges(has_sibling)))
self.assertNotIn(sister, list(reasoner.object_property_ranges(has_sibling, direct=True)))
onto.add_axiom(OWLObjectPropertyRangeAxiom(has_sibling, sister))
self.assertIn(sister, list(reasoner.object_property_ranges(has_sibling)))
onto.remove_axiom(OWLObjectPropertyRangeAxiom(has_sibling, sister))
self.assertNotIn(sister, list(reasoner.object_property_ranges(has_sibling)))
self.assertNotIn(sister, list(reasoner.object_property_ranges(has_sibling, direct=True)))

self.assertNotIn(person, list(reasoner.data_property_domains(age)))
self.assertNotIn(person, list(reasoner.data_property_domains(age, True)))
onto.add_axiom(OWLDataPropertyDomainAxiom(age, person))
self.assertIn(person, list(reasoner.data_property_domains(age)))
self.assertIn(person, list(reasoner.data_property_domains(age, True)))
onto.remove_axiom(OWLDataPropertyDomainAxiom(age, person))
self.assertNotIn(person, list(reasoner.data_property_domains(age)))
self.assertNotIn(person, list(reasoner.data_property_domains(age, True)))

self.assertFalse(list(reasoner.data_property_ranges(age)))
onto.add_axiom(OWLDataPropertyRangeAxiom(age, OWLDataUnionOf([IntegerOWLDatatype, DateOWLDatatype])))
Expand Down

0 comments on commit 6601ac6

Please sign in to comment.