From 89e38b86f97c17dba021828fb6bedf2c368ae91b Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Tue, 21 Nov 2023 20:13:51 +0100 Subject: [PATCH 1/3] Update test_unit_dimension() to EMMO 1.0.0-beta5 --- emmopy/emmocheck.py | 5 ++--- ontopy/patch.py | 21 ++++++++++++--------- tools/ontoconvert | 1 + 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/emmopy/emmocheck.py b/emmopy/emmocheck.py index f81dcab20..e982c0c09 100644 --- a/emmopy/emmocheck.py +++ b/emmopy/emmocheck.py @@ -206,6 +206,7 @@ def test_unit_dimension(self): "emmo.DerivedUnit", "emmo.BaseUnit", "emmo.UnitSymbol", + "emmo.SIAccepted", "emmo.SICoherentDerivedUnit", "emmo.SINonCoherentDerivedUnit", "emmo.SISpecialUnit", @@ -219,9 +220,7 @@ def test_unit_dimension(self): if not hasattr(self.onto, "MeasurementUnit"): return exceptions.update(self.get_config("test_unit_dimension.exceptions", ())) - regex = re.compile( - r"^(emmo|metrology).hasPhysicalDimension.some\(.*\)$" - ) + regex = re.compile(r"^(emmo|metrology).hasDimensionString.value\(.*\)$") classes = set(self.onto.classes(self.check_imported)) for cls in self.onto.MeasurementUnit.descendants(): if not self.check_imported and cls not in classes: diff --git a/ontopy/patch.py b/ontopy/patch.py index 23e28afb2..61c68e50c 100644 --- a/ontopy/patch.py +++ b/ontopy/patch.py @@ -187,15 +187,18 @@ def get_indirect_is_a(self, skip_classes=True): """ subclass_relations = set() for entity in reversed(self.mro()): - if hasattr(entity, "is_a"): - if skip_classes: - subclass_relations.update( - _ - for _ in entity.is_a - if not isinstance(_, owlready2.ThingClass) - ) - else: - subclass_relations.update(entity.is_a) + for attr in "is_a", "equivalent_to": + if hasattr(entity, attr): + lst = getattr(entity, attr) + if skip_classes: + subclass_relations.update( + r + for r in lst + if not isinstance(r, owlready2.ThingClass) + ) + else: + subclass_relations.update(lst) + subclass_relations.update(self.is_a) return subclass_relations diff --git a/tools/ontoconvert b/tools/ontoconvert index b184b5b23..8c23570b4 100755 --- a/tools/ontoconvert +++ b/tools/ontoconvert @@ -203,6 +203,7 @@ def main(argv: list = None): include_imported=include_imported, debug=verbose, ) + onto.save( args.output, format=output_format, From 7e1ed44311461e81b8806306e5ebcb6874b8aaaa Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Tue, 21 Nov 2023 20:18:07 +0100 Subject: [PATCH 2/3] Added test for test_get_indirect_is_a() based on EMMO 1.0.0-beta5 --- ontopy/ontology.py | 6 ++-- ontopy/patch.py | 4 +-- tests/ontopy_tests/test_graph.py | 4 +-- tests/ontopy_tests/test_patch.py | 54 +++++++++++++++++++------------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/ontopy/ontology.py b/ontopy/ontology.py index 2fa5fff27..4dd4feff4 100644 --- a/ontopy/ontology.py +++ b/ontopy/ontology.py @@ -108,16 +108,16 @@ def get_ontology( if base_iri == "emmo": base_iri = ( - "http://emmo-repo.github.io/versions/1.0.0-beta4/emmo.ttl" + "http://emmo-repo.github.io/versions/1.0.0-beta5/emmo.ttl" ) elif base_iri == "emmo-inferred": base_iri = ( - "https://emmo-repo.github.io/versions/1.0.0-beta4/" + "https://emmo-repo.github.io/versions/1.0.0-beta5/" "emmo-inferred.ttl" ) elif base_iri == "emmo-development": base_iri = ( - "https://emmo-repo.github.io/versions/1.0.0-beta4/" + "https://emmo-repo.github.io/versions/1.0.0-beta5/" "emmo-inferred.ttl" ) diff --git a/ontopy/patch.py b/ontopy/patch.py index 61c68e50c..07f653e87 100644 --- a/ontopy/patch.py +++ b/ontopy/patch.py @@ -99,11 +99,11 @@ def _setitem(self, name, value): >>> from owlready2 import locstr >>> emmo = get_emmo() >>> emmo.Atom['altLabel'] - [locstr('ChemicalElement', 'en')] + ['ChemicalElement'] >>> emmo.Atom['altLabel'] = 'Element' >>> emmo.Atom['altLabel'] = locstr('Atomo', 'it') >>> emmo.Atom['altLabel'] - [locstr('ChemicalElement', 'en'), 'Element', locstr('Atomo', 'it')] + ['ChemicalElement', 'Element', 'Atomo'] """ item = _getitem(self, name) diff --git a/tests/ontopy_tests/test_graph.py b/tests/ontopy_tests/test_graph.py index afd9747a9..4a94fae98 100644 --- a/tests/ontopy_tests/test_graph.py +++ b/tests/ontopy_tests/test_graph.py @@ -223,8 +223,8 @@ def test_emmo_graphs(emmo: "Ontology", tmpdir: "Path") -> None: emmo.Index, emmo.Subjective, emmo.NominalProperty, - emmo.ConventionalQuantitativeProperty, - emmo.ModelledQuantitativeProperty, + emmo.ConventionalProperty, + emmo.ModelledProperty, emmo.Theorization, emmo.Experiment, emmo.Theory, diff --git a/tests/ontopy_tests/test_patch.py b/tests/ontopy_tests/test_patch.py index 8ce2b253b..67926db1c 100644 --- a/tests/ontopy_tests/test_patch.py +++ b/tests/ontopy_tests/test_patch.py @@ -1,6 +1,7 @@ """Tests Owlready2 patches implemented in ontopy/patch.py """ +import re import pytest @@ -29,36 +30,40 @@ def test_get_by_label_onto(emmo: "Ontology") -> None: setassert( emmo.Atom.get_annotations(all=True).keys(), { - "qualifiedCardinality", - "minQualifiedCardinality", - "prefLabel", + "IEVReference", + "ISO14040Reference", + "ISO80000Reference", + "ISO9000Reference", + "OWLDLRestrictedAxiom", + "VIMTerm", "abstract", - "hiddenLabel", - "etymology", "altLabel", - "example", - "elucidation", - "OWLDLRestrictedAxiom", - "wikipediaReference", - "conceptualisation", - "logo", "comment", + "conceptualisation", + "contact", + "contributor", + "creator", "dbpediaReference", "definition", - "VIMTerm", - "creator", + "elucidation", + "etymology", + "example", + "figure", "iupacReference", - "contact", + "license", + "logo", + "minQualifiedCardinality", "omReference", - "ISO9000Reference", - "ISO80000Reference", + "prefLabel", + "publisher", + "qualifiedCardinality", "qudtReference", - "contributor", - "license", - "ISO14040Reference", - "figure", "title", - "publisher", + "ucumCode", + "uneceCommonCode", + "unitSymbol", + "wikidataReference", + "wikipediaReference", }, ) @@ -87,6 +92,13 @@ def test_get_by_label_onto(emmo: "Ontology") -> None: ) # Check that wikipediaReference can be acceses as attribute +def test_get_indirect_is_a(emmo: "Ontology") -> None: + assert any( + re.match("^emmo.*.hasDimensionString.value(.*)$", str(e)) + for e in emmo.MicroPascal.get_indirect_is_a() + ) + + # TODO: Fix disjoint_with(). # It seems not to take into account disjoint unions. # assert set(emmo.Collection.disjoint_with()) == {emmo.Item} From a874474f54ba80be95b7f4a16a72afffbab4c8ea Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Tue, 16 Jan 2024 10:45:14 +0100 Subject: [PATCH 3/3] Changec back to EMMO beta4 as default --- ontopy/ontology.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ontopy/ontology.py b/ontopy/ontology.py index 4dd4feff4..9e3702584 100644 --- a/ontopy/ontology.py +++ b/ontopy/ontology.py @@ -108,11 +108,11 @@ def get_ontology( if base_iri == "emmo": base_iri = ( - "http://emmo-repo.github.io/versions/1.0.0-beta5/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/versions/1.0.0-beta5/" + "https://emmo-repo.github.io/versions/1.0.0-beta4/" "emmo-inferred.ttl" ) elif base_iri == "emmo-development":