Skip to content

Commit

Permalink
Fixes thirt issue in #90
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirrr committed Oct 30, 2024
1 parent 1b2ac51 commit c723e7f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions owlapy/class_expression/restriction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""OWL Restrictions"""
from abc import ABCMeta, abstractmethod
from ..meta_classes import HasFiller, HasCardinality, HasOperands
from typing import TypeVar, Generic, Final, Sequence, Union, Iterable
from typing import TypeVar, Generic, Final, Sequence, Union, Iterable, Set
from .nary_boolean_expression import OWLObjectIntersectionOf, OWLObjectUnionOf
from .class_expression import OWLAnonymousClassExpression, OWLClassExpression
from ..owl_property import OWLPropertyExpression, OWLObjectPropertyExpression, OWLDataPropertyExpression
Expand Down Expand Up @@ -393,13 +393,15 @@ class OWLObjectOneOf(OWLAnonymousClassExpression, HasOperands[OWLIndividual]):
__slots__ = '_values'
type_index: Final = 3004

def __init__(self, values: Union[OWLIndividual, Iterable[OWLIndividual]]):
def __init__(self, values: OWLIndividual | Iterable[OWLIndividual]):
#assert isinstance(values, OWLIndividual) | isinstance(values, set)
# f"The input of OWLObjectOneOf must be either an OWLIndividual or a set of OWLIndividual. Currently, {type(values)}!"
if isinstance(values, OWLIndividual):
self._values = values,
else:
for _ in values:
assert isinstance(_, OWLIndividual)
self._values = tuple(values)
self._values = {i for i in values}

This comment has been minimized.

Copy link
@LckyLke

LckyLke Nov 7, 2024

Collaborator

self._values = frozenset(values)


def individuals(self) -> Iterable[OWLIndividual]:
"""Gets the individuals that are in the oneOf. These individuals represent the exact instances (extension)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/test_owlapy_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def test_owlapy_to_dl_str_and_back(self):
# (4)
i1 = OWLNamedIndividual(IRI.create(NS, 'heinz'))
i2 = OWLNamedIndividual(IRI.create(NS, 'marie'))
c = OWLObjectOneOf((i1, i2))
c = OWLObjectOneOf({i1, i2})
rendered_c = renderer.render(c)
self.assertEqual(c, parser.parse_expression(rendered_c))
self.assertEqual(rendered_c, "{heinz ⊔ marie}")
assert rendered_c== "{heinz ⊔ marie}" or rendered_c=="{marie ⊔ heinz}"
# (5)
c = OWLObjectHasValue(property=has_child, individual=i1)
rendered_c = renderer.render(c)
Expand Down Expand Up @@ -110,7 +110,7 @@ def test_owlapy_to_dl_str_and_back(self):
OWLNamedIndividual(IRI.create(NS, 'A')),
OWLNamedIndividual(IRI.create(NS, 'B'))]))
renderer_c = renderer.render(c)
self.assertEqual(renderer_c, "∃ hasChild.{A ⊔ B}")
assert renderer_c=="∃ hasChild.{A ⊔ B}" or renderer_c== "∃ hasChild.{B ⊔ A}"
self.assertEqual(c, parser.parse_expression(renderer_c))
# (16)
c = OWLObjectAllValuesFrom(property=has_child, filler=OWLObjectOneOf([
Expand Down
2 changes: 1 addition & 1 deletion tests/test_owlapy_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_ce_render(self):
i2 = OWLNamedIndividual(IRI.create(NS, 'marie'))
oneof = OWLObjectOneOf((i1, i2))
r = renderer.render(oneof)
self.assertEqual(r, "{heinz ⊔ marie}")
assert r=="{heinz ⊔ marie}" or r=="{marie ⊔ heinz}"

hasvalue = OWLObjectHasValue(property=has_child, individual=i1)
r = renderer.render(hasvalue)
Expand Down

0 comments on commit c723e7f

Please sign in to comment.