Skip to content
Open
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
18 changes: 10 additions & 8 deletions entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,11 @@ def direct_instances(Class, world = None):
def get_class_properties(Class):
l = set()
for r in _property_value_restrictions(Class, None):
if r.property._class_property_some and ((r.type == VALUE) or (r.type == SOME) or ((r.type == EXACTLY) and r.cardinality >= 1) or ((r.type == MIN) and r.cardinality >= 1)):
l.add(r.property)
elif r.property._class_property_only and (r.type == ONLY):
l.add(r.property)
prop = r.property
if getattr(prop, "_class_property_some", False) and ((r.type == VALUE) or (r.type == SOME) or ((r.type == EXACTLY) and r.cardinality >= 1) or ((r.type == MIN) and r.cardinality >= 1)):
l.add(prop)
elif getattr(prop, "_class_property_only", False) and (r.type == ONLY):
l.add(prop)

for storid in Class.namespace.world._get_triples_s_p(Class.storid):
Prop = Class.namespace.world._get_by_storid(storid)
Expand All @@ -507,10 +508,11 @@ def get_class_properties(Class):
def INDIRECT_get_class_properties(Class):
l = set()
for r in _inherited_properties_value_restrictions(Class, None, set()):
if r.property._class_property_some and ((r.type == VALUE) or (r.type == SOME) or ((r.type == EXACTLY) and r.cardinality >= 1) or ((r.type == MIN) and r.cardinality >= 1)):
l.add(r.property)
elif r.property._class_property_only and (r.type == ONLY):
l.add(r.property)
prop = r.property
if getattr(prop, "_class_property_some", False) and ((r.type == VALUE) or (r.type == SOME) or ((r.type == EXACTLY) and r.cardinality >= 1) or ((r.type == MIN) and r.cardinality >= 1)):
l.add(prop)
elif getattr(prop, "_class_property_only", False) and (r.type == ONLY):
l.add(prop)

for storid in Class.namespace.world._get_triples_s_p(Class.storid):
Prop = Class.namespace.world._get_by_storid(storid)
Expand Down
15 changes: 15 additions & 0 deletions test/regtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5955,6 +5955,21 @@ class D(Thing):
assert isinstance(r.property, Inverse)
self.assert_triple(r.property.storid, owl_inverse_property, P.storid, None, world)

def test_inverse_2_get_class_properties(self):
world = self.new_world()
n = world.get_ontology("http://www.test.org/test.owl")

with n:
class P(ObjectProperty): pass
class C(Thing): pass
class D(Thing):
is_a = [Inverse(P).some(C)]
class E(D): pass

assert set(D.get_class_properties()) == set()
assert set(D.INDIRECT_get_class_properties()) == set()
assert set(E.INDIRECT_get_class_properties()) == set()

def test_inverse_3(self):
world = self.new_world()
n = world.get_ontology("http://www.test.org/test.owl")
Expand Down