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

Fixed failing tests in test_patch.py #618

Merged
merged 5 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 32 additions & 36 deletions tests/ontopy_tests/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,24 @@
# Test some ThingClass extensions implemented in patch.py
assert emmo.Atom.get_preferred_label() == "Atom"

assert emmo.Atom.get_parents() == {
emmo.CausalSystem,
emmo.CompositeParticle,
emmo.MolecularEntity,
}
assert emmo.Atom.get_parents() == {emmo.MolecularEntity}

assert set(emmo.Atom.get_annotations().keys()) == {
"prefLabel",
"altLabel",
"elucidation",
"comment",
}


# Test item access/assignment/deletion for classes
assert emmo.Atom["altLabel"] == ["ChemicalElement"]
assert set(emmo.Atom["altLabel"]) == {"ChemicalElement"}

with pytest.raises(KeyError):
emmo.Atom["hasPart"]

emmo.Atom["altLabel"] = "Element"
assert emmo.Atom["altLabel"] == ["ChemicalElement", "Element"]
assert set(emmo.Atom["altLabel"]) == {"ChemicalElement", "Element"}

del emmo.Atom["altLabel"]
assert emmo.Atom["altLabel"] == []
Expand All @@ -44,37 +41,36 @@
assert emmo.Atom["altLabel"] == ["ChemicalElement"]


assert emmo.Atom.is_defined == False
francescalb marked this conversation as resolved.
Show resolved Hide resolved
assert emmo.Holistic.is_defined == True

# TODO: Fix disjoint_with().
# It seems not to take into account disjoint unions.
# assert set(emmo.Collection.disjoint_with()) == {emmo.Item}

assert set(str(s) for s in emmo.CausalChain.get_indirect_is_a()) == set(
str(s)
for s in {
Inverse(emmo.hasPart).value(emmo.universe),
emmo.CausalObject,
emmo.Particle,
emmo.hasPart.some(emmo.Quantum),
emmo.hasTemporalPart.only(emmo.CausalChain | emmo.Quantum),
emmo.hasTemporalPart.some(emmo.CausalChain | emmo.Quantum),
}
)
assert set(
str(s) for s in emmo.CausalChain.get_indirect_is_a(skip_classes=False)
) == set(
str(s)
for s in {
Inverse(emmo.hasPart).value(emmo.universe),
emmo.CausalObject,
emmo.EMMO,
emmo.Item,
emmo.Particle,
emmo.hasPart.some(emmo.Quantum),
emmo.hasTemporalPart.only(emmo.CausalChain | emmo.Quantum),
emmo.hasTemporalPart.some(emmo.CausalChain | emmo.Quantum),
owl.Thing,
}
)

assert emmo.Atom.is_defined == False
assert emmo.Holistic.is_defined == True
# Comment out these tests for now because Owlready2 automatically converts
# `Inverse(emmo.hasPart)` to `emmo.isPartOf`.
#
# Also, check whether ancestors() does any inferences from disjoint unions, etc.
# If it does, it might be better to reley on ancestors() instead of implementing
# get_indirect_is_a() as a separate method
# assert emmo.CausalChain.get_indirect_is_a() == {
# Inverse(emmo.hasPart).value(emmo.universe),
# emmo.CausalParticle,
# emmo.CausalStructure,
# emmo.hasPart.some(emmo.Quantum),
# emmo.hasTemporalPart.only(emmo.CausalPath | emmo.Quantum),
# emmo.hasTemporalPart.some(emmo.CausalPath | emmo.Quantum),
# }
# assert emmo.CausalChain.get_indirect_is_a(skip_classes=False) == {
# Inverse(emmo.hasPart).value(emmo.universe),
# emmo.CausalObject,
# emmo.EMMO,
# emmo.Item,
# emmo.Particle,
# emmo.hasPart.some(emmo.Quantum),
# emmo.hasTemporalPart.only(emmo.CausalChain | emmo.Quantum),
# emmo.hasTemporalPart.some(emmo.CausalChain | emmo.Quantum),
# owl.Thing,
# }
14 changes: 7 additions & 7 deletions tests/test_manchester.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ def test_manchester():
Inverse(emmo.hasPart).value(emmo.universe),
)
# literal data restriction
check('hasSymbolData value "hello"', emmo.hasSymbolData.value("hello"))
check("hasSymbolData value 42", emmo.hasSymbolData.value(42))
check("hasSymbolData value 3.14", emmo.hasSymbolData.value(3.14))
check('hasSymbolValue value "hello"', emmo.hasSymbolValue.value("hello"))
check("hasSymbolValue value 42", emmo.hasSymbolValue.value(42))
check("hasSymbolValue value 3.14", emmo.hasSymbolValue.value(3.14))
check(
'hasSymbolData value "abc"^^xsd:string',
emmo.hasSymbolData.value("abc"),
'hasSymbolValue value "abc"^^xsd:string',
emmo.hasSymbolValue.value("abc"),
)
check(
'hasSymbolData value "hello"@en',
emmo.hasSymbolData.value(locstr("hello", "en")),
'hasSymbolValue value "hello"@en',
emmo.hasSymbolValue.value(locstr("hello", "en")),
)
check("emmo:hasPart some emmo:Atom", emmo.hasPart.some(emmo.Atom))

Expand Down