Skip to content

Commit

Permalink
Merge pull request #194 from linkml/linkml-issue-875
Browse files Browse the repository at this point in the history
Adding domain_of to induced slot.
  • Loading branch information
cmungall committed Jul 20, 2022
2 parents dd2378e + dddaab7 commit 3617c37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions linkml_runtime/utils/schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,9 @@ def induced_slot(self, slot_name: SLOT_NAME, class_name: CLASS_NAME = None, impo
islot.name = mangled_name
if not islot.alias:
islot.alias = underscore(slot_name)
for c in self.all_classes().values():
if islot.name in c.slots or islot.name in c.attributes:
islot.domain_of.append(c.name)
return deepcopy(islot)

@lru_cache()
Expand Down
2 changes: 2 additions & 0 deletions tests/test_utils/test_schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def test_schemaview(self):
assert view.induced_slot('related to', 'FamilialRelationship').range == 'Person'
assert view.get_slot('related to').range == 'Thing'
assert view.induced_slot('related to', 'Relationship').range == 'Thing'
# https://github.com/linkml/linkml/issues/875
self.assertCountEqual(['Thing', 'Place'], view.induced_slot('name').domain_of)

a = view.get_class('activity')
self.assertCountEqual(a.exact_mappings, ['prov:Activity'])
Expand Down

0 comments on commit 3617c37

Please sign in to comment.