Skip to content

Commit

Permalink
Add doc strings back
Browse files Browse the repository at this point in the history
  • Loading branch information
IanCa committed Mar 20, 2024
1 parent f6fbfb5 commit a74eb54
Showing 1 changed file with 99 additions and 11 deletions.
110 changes: 99 additions & 11 deletions hed/schema/schema_attribute_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@


def tag_is_placeholder_check(hed_schema, tag_entry, attribute_name):
"""Check if comma separated list has valid HedTags."""
"""Check if comma separated list has valid HedTags.
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
if not tag_entry.name.endswith("/#"):
issues += ErrorHandler.format_error(SchemaWarnings.SCHEMA_NON_PLACEHOLDER_HAS_CLASS, tag_entry.name,
Expand All @@ -30,7 +38,15 @@ def tag_is_placeholder_check(hed_schema, tag_entry, attribute_name):


def attribute_is_deprecated(hed_schema, tag_entry, attribute_name):
""" Check if the attribute is deprecated. does not check value."""
""" Check if the attribute is deprecated. does not check value.
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
# Attributes has to check properties
section_key = HedSectionKey.Attributes
Expand All @@ -50,7 +66,15 @@ def attribute_is_deprecated(hed_schema, tag_entry, attribute_name):

# todo: This needs to be refactored, these next several functions are near identical
def tag_exists_check(hed_schema, tag_entry, attribute_name):
"""Check if the list of possible tags exists in the schema."""
"""Check if the list of possible tags exists in the schema.
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
possible_tags = tag_entry.attributes.get(attribute_name, "")
split_tags = possible_tags.split(",")
Expand All @@ -72,7 +96,15 @@ def tag_exists_check(hed_schema, tag_entry, attribute_name):


def unit_class_exists(hed_schema, tag_entry, attribute_name):
"""Check if comma separated list is valid unit classes."""
"""Check if comma separated list is valid unit classes.
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
possible_unit_classes = tag_entry.attributes.get(attribute_name, "")
split_tags = possible_unit_classes.split(",")
Expand All @@ -94,7 +126,15 @@ def unit_class_exists(hed_schema, tag_entry, attribute_name):


def value_class_exists(hed_schema, tag_entry, attribute_name):
"""Check if comma separated list is valid value classes."""
"""Check if comma separated list is valid value classes.
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
possible_value_classes = tag_entry.attributes.get(attribute_name, "")
split_tags = possible_value_classes.split(",")
Expand All @@ -117,7 +157,15 @@ def value_class_exists(hed_schema, tag_entry, attribute_name):


def unit_exists(hed_schema, tag_entry, attribute_name):
"""Check the given unit is valid, and not deprecated."""
"""Check the given unit is valid, and not deprecated.
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
unit = tag_entry.attributes.get(attribute_name, "")
unit_entry = tag_entry.get_derivative_unit_entry(unit)
Expand All @@ -137,7 +185,15 @@ def unit_exists(hed_schema, tag_entry, attribute_name):

# This is effectively unused and can never fail - The schema would catch these errors and refuse to load
def tag_exists_base_schema_check(hed_schema, tag_entry, attribute_name):
"""Check if the single tag is a partnered schema tag"""
"""Check if the single tag is a partnered schema tag
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
rooted_tag = tag_entry.attributes.get(attribute_name, "")
if rooted_tag and rooted_tag not in hed_schema.tags:
Expand All @@ -150,7 +206,15 @@ def tag_exists_base_schema_check(hed_schema, tag_entry, attribute_name):


def tag_is_deprecated_check(hed_schema, tag_entry, attribute_name):
""" Check if the element has a valid deprecatedFrom attribute, and that any children have it"""
""" Check if the element has a valid deprecatedFrom attribute, and that any children have it
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
deprecated_version = tag_entry.attributes.get(attribute_name, "")
library_name = tag_entry.has_attribute(HedKey.InLibrary, return_value=True)
Expand All @@ -177,7 +241,15 @@ def tag_is_deprecated_check(hed_schema, tag_entry, attribute_name):


def conversion_factor(hed_schema, tag_entry, attribute_name):
"""Check if the conversion_factor on is valid"""
"""Check if the conversion_factor on is valid
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
cf = tag_entry.attributes.get(attribute_name, "1.0")
try:
Expand All @@ -193,7 +265,15 @@ def conversion_factor(hed_schema, tag_entry, attribute_name):


def allowed_characters_check(hed_schema, tag_entry, attribute_name):
""" Check allowed character has a valid value"""
""" Check allowed character has a valid value
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []
allowed_strings = character_types

Expand All @@ -208,7 +288,15 @@ def allowed_characters_check(hed_schema, tag_entry, attribute_name):


def in_library_check(hed_schema, tag_entry, attribute_name):
"""Check if the library attribute is a valid schema name"""
"""Check if the library attribute is a valid schema name
Parameters:
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
Returns:
issues(list): A list of issues from validating this attribute.
"""
issues = []

library = tag_entry.attributes.get(attribute_name, "")
Expand Down

0 comments on commit a74eb54

Please sign in to comment.