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

Account for any_of/exactly_one_of in get_classes_by_slot() and get_slots_by_enum() #318

Closed
wants to merge 2 commits into from
Closed
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
14 changes: 14 additions & 0 deletions linkml_runtime/utils/schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,17 +1585,27 @@
classes_set = set() # use set to avoid duplicates
all_classes = self.all_classes()

# direct slots
for c_name, c in all_classes.items():
if slot.name in c.slots:
classes_set.add(c_name)
if slot.any_of or slot.exactly_one_of:
for x in slot.any_of + slot.exactly_one_of:
if x.range:
classes_set.append(c_name)

Check warning on line 1595 in linkml_runtime/utils/schemaview.py

View check run for this annotation

Codecov / codecov/patch

linkml_runtime/utils/schemaview.py#L1595

Added line #L1595 was not covered by tests

# add indirect slots
if include_induced:
for c_name in all_classes:
induced_slot_names = [
ind_slot.name for ind_slot in self.class_induced_slots(c_name)
]
if slot.name in induced_slot_names:
classes_set.add(c_name)
if slot.any_of or slot.exactly_one_of:
for x in slot.any_of + slot.exactly_one_of:
if x.range:
classes_set.append(c_name)

Check warning on line 1608 in linkml_runtime/utils/schemaview.py

View check run for this annotation

Codecov / codecov/patch

linkml_runtime/utils/schemaview.py#L1608

Added line #L1608 was not covered by tests

return list(classes_set)

Expand All @@ -1610,6 +1620,10 @@
for s in self.all_slots().values():
if s.range == enum_name and s not in enum_slots:
enum_slots.append(s)
if s.any_of or s.exactly_one_of:
for x in s.any_of + s.exactly_one_of:
if x.range == enum_name and s not in enum_slots:
enum_slots.append(s)

Check warning on line 1626 in linkml_runtime/utils/schemaview.py

View check run for this annotation

Codecov / codecov/patch

linkml_runtime/utils/schemaview.py#L1626

Added line #L1626 was not covered by tests
for class_definition in self.all_classes().values():
if class_definition.slot_usage:
for slot_definition in class_definition.slot_usage.values():
Expand Down
Loading