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

Ontology fixes #934

Merged
merged 1 commit into from
May 28, 2024
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
2 changes: 1 addition & 1 deletion hed/schema/schema_io/ontology_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _convert_df_to_omn(df, annotation_properties=("",)):
equivalent_to = row[constants.equivalent_to]
equivalent_to = equivalent_to.replace(" and ", "\n\t\tand ")
subclass_of = row[constants.subclass_of]
if equivalent_to and equivalent_to != subclass_of:
if equivalent_to:
output_text += "\tEquivalentTo:\n"
output_text += f"\t\t{equivalent_to}"
else:
Expand Down
10 changes: 7 additions & 3 deletions hed/schema/schema_io/schema2df.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _get_tag_equivalent_to(self, tag_entry):
if self._get_as_ids and found_range and found_range != HedKey.NumericRange:
section = self._schema[found_range]
if any(section.get(v) is None for v in values):
raise ValueError(f"Cannot find schema entry for {v}")
raise ValueError(f"Cannot find schema entry for {values}")
for v in values:
test_id = section.get(v).attributes.get(HedKey.HedID)
if not test_id:
Expand Down Expand Up @@ -278,9 +278,13 @@ def _get_tag_equivalent_to(self, tag_entry):
if self._get_as_ids:
attribute_strings.append(f"(hed:HED_0000102 some {schema_id})")
else:
attribute_strings.append(f"(inHedSchema some {schema_name}")
attribute_strings.append(f"(inHedSchema some {schema_name})")

return " and ".join([subclass] + attribute_strings)
# If they match, we want to leave equivalent_to blank
final_out = " and ".join([subclass] + attribute_strings)
if final_out == subclass:
return ""
return final_out

def _get_subclass_of(self, tag_entry):
# Special case for HedTag
Expand Down