Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUPPORT EMMO-beta4.0 #441

Merged
merged 11 commits into from
Aug 16, 2022
3 changes: 2 additions & 1 deletion .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
sudo apt-get update
sudo apt-get install -y graphviz
sudo apt-get install -y texlive-xetex
sudo apt-get install -y texlive-latex-extra
Expand All @@ -170,7 +171,7 @@ jobs:
cd examples/emmodoc
python ../../tools/ontodoc -f simple-html emmo-inferred emmo-simple.html
python ../../tools/ontodoc -t emmo.md -p no-self-contained emmo-inferred emmo.html
python ../../tools/ontodoc -t emmo.md emmo-inferred emmo.pdf
# python ../../tools/ontodoc -t emmo.md emmo-inferred emmo.pdf
cd -


Expand Down
1 change: 1 addition & 0 deletions emmopy/emmopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def get_emmo(inferred: Optional[bool] = True) -> "Ontology":

Returns:
The loaded emmo ontology.

"""
name = "emmo-inferred" if inferred in [True, None] else "emmo"
return get_ontology(name).load()
4 changes: 2 additions & 2 deletions examples/emmodoc/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ branch of mereotopology.
%BRANCHDOC Perspective

%BRANCHDOC Holistic
%BRANCHDOC Semiotic
%BRANCHDOC Semiotics
%BRANCHDOC Sign
%BRANCHDOC Interpreter
%BRANCHDOC Object
Expand Down Expand Up @@ -73,7 +73,7 @@ branch of mereotopology.

%BRANCHDOC Physicalistic
%BRANCHDOC ElementaryParticle
%BRANCHDOC Subatomic
#%BRANCHDOC Subatomic
%BRANCHDOC Matter
%BRANCHDOC Fluid
%BRANCHDOC Mixture
Expand Down
8 changes: 4 additions & 4 deletions examples/emmodoc/relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ The characteristics of the different properties are described by the following *
%BRANCHFIG EMMORelation caption="Top-level of the EMMO relation hierarchy."
%ENTITY EMMORelation

%%BRANCHDOC mereotopological
%BRANCHHEAD mereotopological
%BRANCH mereotopological
#%%BRANCHDOC mereotopological
#%BRANCHHEAD mereotopological
#%BRANCH mereotopological

%BRANCHDOC connected
#%BRANCHDOC connected

%BRANCHDOC hasPart

Expand Down
6 changes: 4 additions & 2 deletions ontopy/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,11 @@ def get_edge_attrs(self, predicate, attrs):
)
break
else:
raise ValueError(
f"Relation {relation} not found in entity.mro()."
warnings.warn(
f"Style not defined for relation {name}. "
"Resorting to default style."
)
rattrs = self.style.get("default_relation", {})
# object property
if isinstance(
entity,
Expand Down
16 changes: 9 additions & 7 deletions ontopy/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,28 @@ def get_ontology(self, base_iri="emmo-inferred"):
The `base_iri` argument may be one of:
- valid URL (possible excluding final .owl or .ttl)
- file name (possible excluding final .owl or .ttl)
- "emmo": load latest stable version of asserted EMMO
- "emmo-inferred": load latest stable version of inferred EMMO
- "emmo": load latest version of asserted EMMO
- "emmo-inferred": load latest version of inferred EMMO
(default)
- "emmo-development": load latest inferred development version
of EMMO
of EMMO. Until first stable release emmo-inferred and
emmo-development will be the same.
"""
base_iri = base_iri.as_uri() if isinstance(base_iri, Path) else base_iri

if base_iri == "emmo":
base_iri = (
"https://raw.githubusercontent.com/emmo-repo/"
"EMMO/master/emmo.ttl"
"http://emmo-repo.github.io/versions/1.0.0-beta4/emmo.ttl"
)
elif base_iri == "emmo-inferred":
base_iri = (
"https://emmo-repo.github.io/latest-stable/emmo-inferred.ttl"
"https://emmo-repo.github.io/versions/1.0.0-beta4/"
"emmo-inferred.ttl"
)
elif base_iri == "emmo-development":
base_iri = (
"https://emmo-repo.github.io/development/emmo-inferred.ttl"
"https://emmo-repo.github.io/versions/1.0.0-beta4/"
"emmo-inferred.ttl"
)

if base_iri in self.ontologies:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_graph2(emmo: "Ontology", tmpdir: "Path") -> None:
graph = OntoGraph(
emmo,
emmo.hasPart,
leafs=("mereotopological", "semiotical", "connected"),
leafs=("mereological", "semiotical", "causal"),
)
graph.save(tmpdir / "hasPart.svg")

Expand Down Expand Up @@ -113,7 +113,7 @@ def test_graph2(emmo: "Ontology", tmpdir: "Path") -> None:
emmo.Icon,
emmo.Interpretant,
emmo.Index,
emmo.SubjectiveProperty,
emmo.Subjective,
emmo.NominalProperty,
emmo.ConventionalQuantitativeProperty,
emmo.ModelledQuantitativeProperty,
Expand All @@ -139,7 +139,7 @@ def test_graph2(emmo: "Ontology", tmpdir: "Path") -> None:
emmo.Quantity,
emmo.String,
emmo.PrefixedUnit,
emmo.SymbolicComposition,
emmo.SymbolicConstruct,
emmo.Matter,
],
parents=2,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 12 additions & 2 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import pytest

if TYPE_CHECKING:
from pathlib import Path

from ontopy.ontology import Ontology


def test_basic(emmo: "Ontology") -> None:
from ontopy import get_ontology
from ontopy.utils import LabelDefinitionError

emmo.sync_reasoner()

onto = get_ontology("onto.owl")
onto.imported_ontologies.append(emmo)
onto.base_iri = "http://emmo.info/examples/test#"
Expand Down Expand Up @@ -50,3 +50,13 @@ class H2O(emmo.Molecule):
assert water.name.startswith("onto_")
# A UUID is 32 chars long + 4 `-` chars = 36 chars
assert len(water.name) == len(name_prefix) + 36


def test_sync_reasoner(repo_dir: "Path") -> None:
"""Test `ontopy:Ontology.sync_reasoner()`."""
from ontopy import get_ontology

ontodir = repo_dir / "tests" / "testonto"

onto: "Ontology" = get_ontology((ontodir / "testonto.ttl").as_uri())
onto.sync_reasoner()
4 changes: 2 additions & 2 deletions tests/test_manchester.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def test_manchester():
(emmo.Atom & emmo.Molecule) | emmo.Proton,
)
check(
"inverse(hasPart) value Universe",
Inverse(emmo.hasPart).value(emmo.Universe),
"inverse(hasPart) value universe",
Inverse(emmo.hasPart).value(emmo.universe),
)
# literal data restriction
check('hasSymbolData value "hello"', emmo.hasSymbolData.value("hello"))
Expand Down
1 change: 1 addition & 0 deletions tests/tools/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def tool(request: "Dict[str, Any]") -> "ModuleType":
original_tool_path: Path = (
Path(__file__).resolve().parent.parent.parent / "tools" / request.param
)
sys.path.append(str(original_tool_path.parent.parent))

assert (
original_tool_path.exists()
Expand Down