Skip to content
6 changes: 3 additions & 3 deletions hed/models/base_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def expand_defs(self, hed_schema, def_dict):

Parameters:
hed_schema (HedSchema or None): The schema to use to identify defs
def_dict (DefinitionDict): The definitions to expand
def_dict (DefinitionDict): The type_defs to expand
"""
from df_util import expand_defs
expand_defs(self._dataframe, hed_schema=hed_schema, def_dict=def_dict, columns=self._mapper.get_tag_columns())
Expand Down Expand Up @@ -325,7 +325,7 @@ def validate(self, hed_schema, extra_def_dicts=None, name=None, error_handler=No

Parameters:
hed_schema(HedSchema): The schema to use for validation
extra_def_dicts(list of DefDict or DefDict): all definitions to use for validation
extra_def_dicts(list of DefDict or DefDict): all type_defs to use for validation
name(str): The name to report errors from this file as
error_handler (ErrorHandler): Error context to use. Creates a new one if None
Returns:
Expand Down Expand Up @@ -470,7 +470,7 @@ def get_def_dict(self, hed_schema, extra_def_dicts=None):
Note: Baseclass implementation returns just extra_def_dicts.

Parameters:
hed_schema(HedSchema): used to identify tags to find definitions(if needed)
hed_schema(HedSchema): used to identify tags to find type_defs(if needed)
extra_def_dicts (list, DefinitionDict, or None): Extra dicts to add to the list.

Returns:
Expand Down
4 changes: 2 additions & 2 deletions hed/models/column_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, sidecar=None, tag_columns=None, column_prefix_dictionary=None
Parameters:
sidecar (Sidecar): A sidecar to gather column data from.
tag_columns: (list): A list of ints or strings containing the columns that contain the HED tags.
Sidecar column definitions will take precedent if there is a conflict with tag_columns.
Sidecar column type_defs will take precedent if there is a conflict with tag_columns.
column_prefix_dictionary (dict): Dictionary with keys that are column numbers/names and values are HED tag
prefixes to prepend to the tags in that column before processing.
optional_tag_columns (list): A list of ints or strings containing the columns that contain
Expand Down Expand Up @@ -383,7 +383,7 @@ def get_def_dict(self, hed_schema, extra_def_dicts=None):
""" Return def dicts from every column description.

Parameters:
hed_schema (Schema): A HED schema object to use for extracting definitions.
hed_schema (Schema): A HED schema object to use for extracting type_defs.
extra_def_dicts (list, DefinitionDict, or None): Extra dicts to add to the list.

Returns:
Expand Down
12 changes: 6 additions & 6 deletions hed/models/def_expand_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def get_group(self):


class DefExpandGatherer:
"""Class for gathering definitions from a series of def-expands, including possibly ambiguous ones"""
"""Class for gathering type_defs from a series of def-expands, including possibly ambiguous ones"""
def __init__(self, hed_schema, known_defs=None, ambiguous_defs=None, errors=None):
"""Initialize the DefExpandGatherer class.

Parameters:
hed_schema (HedSchema): The HED schema to be used for processing.
known_defs (dict, optional): A dictionary of known definitions.
ambiguous_defs (dict, optional): A dictionary of ambiguous def-expand definitions.
known_defs (dict, optional): A dictionary of known type_defs.
ambiguous_defs (dict, optional): A dictionary of ambiguous def-expand type_defs.

"""
self.hed_schema = hed_schema
Expand All @@ -101,10 +101,10 @@ def process_def_expands(self, hed_strings, known_defs=None):

Parameters:
hed_strings (pd.Series or list): A Pandas Series or list of HED strings to be processed.
known_defs (dict, optional): A dictionary of known definitions to be added.
known_defs (dict, optional): A dictionary of known type_defs to be added.

Returns:
tuple: A tuple containing the DefinitionDict, ambiguous definitions, and errors.
tuple: A tuple containing the DefinitionDict, ambiguous type_defs, and errors.
"""
if not isinstance(hed_strings, pd.Series):
hed_strings = pd.Series(hed_strings)
Expand All @@ -120,7 +120,7 @@ def process_def_expands(self, hed_strings, known_defs=None):
return self.def_dict, self.ambiguous_defs, self.errors

def _process_def_expand(self, string):
"""Process a single HED string to extract definitions and handle known and ambiguous definitions.
"""Process a single HED string to extract type_defs and handle known and ambiguous type_defs.

Parameters:
string (str): The HED string to be processed.
Expand Down
32 changes: 16 additions & 16 deletions hed/models/definition_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@


class DefinitionDict:
""" Gathers definitions from a single source.
""" Gathers type_defs from a single source.

"""

def __init__(self, def_dicts=None, hed_schema=None):
""" Definitions to be considered a single source.
""" Definitions to be considered a single source.

Parameters:
def_dicts (str or list or DefinitionDict): DefDict or list of DefDicts/strings or
a single string whose definitions should be added.
def_dicts (str or list or DefinitionDict): DefDict or list of DefDicts/strings or
a single string whose type_defs should be added.
hed_schema(HedSchema or None): Required if passing strings or lists of strings, unused otherwise.

:raises TypeError:
Expand All @@ -30,14 +30,14 @@ def __init__(self, def_dicts=None, hed_schema=None):
self.add_definitions(def_dicts, hed_schema)

def add_definitions(self, def_dicts, hed_schema=None):
""" Add definitions from dict(s) to this dict.
""" Add type_defs from dict(s) to this dict.

Parameters:
def_dicts (list or DefinitionDict or dict): DefinitionDict or list of DefinitionDicts/strings/dicts whose
def_dicts (list, DefinitionDict, or dict): DefinitionDict or list of DefinitionDicts/strings/dicts whose
definitions should be added.
Note dict form expects DefinitionEntries in the same form as a DefinitionDict
hed_schema(HedSchema or None): Required if passing strings or lists of strings, unused otherwise.

:raises TypeError:
- Bad type passed as def_dicts
"""
Expand All @@ -63,7 +63,7 @@ def _add_definition(self, def_tag, def_value):
self.defs[def_tag] = def_value

def _add_definitions_from_dict(self, def_dict):
""" Add the definitions found in the given definition dictionary to this mapper.
""" Add the type_defs found in the given definition dictionary to this mapper.

Parameters:
def_dict (DefinitionDict or dict): DefDict whose definitions should be added.
Expand Down Expand Up @@ -92,29 +92,29 @@ def __len__(self):
return len(self.defs)

def items(self):
""" Returns the dictionary of definitions
""" Returns the dictionary of type_defs

Alias for .defs.items()

Returns:
def_entries({str: DefinitionEntry}): A list of definitions
def_entries({str: DefinitionEntry}): A list of type_defs
"""
return self.defs.items()

@property
def issues(self):
"""Returns issues about duplicate definitions."""
"""Returns issues about duplicate type_defs."""
return self._issues

def check_for_definitions(self, hed_string_obj, error_handler=None):
""" Check string for definition tags, adding them to self.

Parameters:
hed_string_obj (HedString): A single hed string to gather definitions from.
error_handler (ErrorHandler or None): Error context used to identify where definitions are found.
hed_string_obj (HedString): A single hed string to gather type_defs from.
error_handler (ErrorHandler or None): Error context used to identify where type_defs are found.

Returns:
list: List of issues encountered in checking for definitions. Each issue is a dictionary.
list: List of issues encountered in checking for type_defs. Each issue is a dictionary.
"""
def_issues = []
for definition_tag, group in hed_string_obj.find_top_level_tags(anchor_tags={DefTagNames.DEFINITION_KEY}):
Expand Down Expand Up @@ -302,7 +302,7 @@ def get_as_strings(def_dict):
""" Convert the entries to strings of the contents

Parameters:
def_dict(DefinitionDict or dict): A dict of definitions
def_dict(DefinitionDict or dict): A dict of type_defs

Returns:
dict(str: str): definition name and contents
Expand Down
12 changes: 6 additions & 6 deletions hed/models/df_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_assembled(tabular_file, sidecar, hed_schema, extra_def_dicts=None, join_
Returns:
tuple:
hed_strings(list of HedStrings):A list of HedStrings or a list of lists of HedStrings
def_dict(DefinitionDict): The definitions from this Sidecar
def_dict(DefinitionDict): The type_defs from this Sidecar
"""
if isinstance(sidecar, str):
sidecar = Sidecar(sidecar)
Expand Down Expand Up @@ -105,7 +105,7 @@ def expand_defs(df, hed_schema, def_dict, columns=None):
Parameters:
df (pd.Dataframe or pd.Series): The dataframe or series to modify
hed_schema (HedSchema or None): The schema to use to identify defs
def_dict (DefinitionDict): The definitions to expand
def_dict (DefinitionDict): The type_defs to expand
columns (list or None): The columns to modify on the dataframe
"""
if isinstance(df, pd.Series):
Expand Down Expand Up @@ -133,18 +133,18 @@ def _expand_defs(hed_string, hed_schema, def_dict):


def process_def_expands(hed_strings, hed_schema, known_defs=None, ambiguous_defs=None):
""" Gather def-expand tags in the strings/compare with known definitions to find any differences
""" Gather def-expand tags in the strings/compare with known type_defs to find any differences

Parameters:
hed_strings (list or pd.Series): A list of HED strings to process.
hed_schema (HedSchema): The schema to use
known_defs (DefinitionDict or list or str or None):
A DefinitionDict or anything its constructor takes. These are the known definitions going in, that must
A DefinitionDict or anything its constructor takes. These are the known type_defs going in, that must
match perfectly.
ambiguous_defs (dict): A dictionary containing ambiguous definitions
ambiguous_defs (dict): A dictionary containing ambiguous type_defs
format TBD. Currently def name key: list of lists of HED tags values
Returns:
tuple: A tuple containing the DefinitionDict, ambiguous definitions, and errors.
tuple: A tuple containing the DefinitionDict, ambiguous type_defs, and errors.
"""

from hed.models.def_expand_gather import DefExpandGatherer
Expand Down
4 changes: 2 additions & 2 deletions hed/models/hed_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def copy(self):
def remove_definitions(self):
""" Remove definition tags and groups from this string.

This does not validate definitions and will blindly removing invalid ones as well.
This does not validate type_defs and will blindly removing invalid ones as well.
"""
definition_groups = self.find_top_level_tags({DefTagNames.DEFINITION_KEY}, include_groups=1)
if definition_groups:
Expand Down Expand Up @@ -178,7 +178,7 @@ def split_into_groups(hed_string, hed_schema, def_dict=None):
Parameters:
hed_string (str): A hed string consisting of tags and tag groups to be processed.
hed_schema (HedSchema): HED schema to use to identify tags.
def_dict(DefinitionDict): The definitions to identify
def_dict(DefinitionDict): The type_defs to identify
Returns:
list: A list of HedTag and/or HedGroup.

Expand Down
2 changes: 1 addition & 1 deletion hed/models/model_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class DefTagNames:
""" Source names for definitions, def labels, and expanded labels"""
""" Source names for type_defs, def labels, and expanded labels"""

DEF_ORG_KEY = 'Def'
DEF_EXPAND_ORG_KEY = 'Def-expand'
Expand Down
12 changes: 6 additions & 6 deletions hed/models/sidecar.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def all_hed_columns(self):

@property
def def_dict(self):
"""This is the definitions from this sidecar.
"""This is the type_defs from this sidecar.

Generally you should instead call get_def_dict to get the relevant definitions
Generally you should instead call get_def_dict to get the relevant type_defs

Returns:
DefinitionDict: The definitions for this sidecar
DefinitionDict: The type_defs for this sidecar
"""
return self._def_dict

Expand All @@ -76,7 +76,7 @@ def get_def_dict(self, hed_schema, extra_def_dicts=None):
""" Returns the definition dict for this sidecar.

Parameters:
hed_schema(HedSchema): used to identify tags to find definitions
hed_schema(HedSchema): used to identify tags to find type_defs
extra_def_dicts (list, DefinitionDict, or None): Extra dicts to add to the list.

Returns:
Expand Down Expand Up @@ -192,14 +192,14 @@ def _load_json_file(self, fp):
raise HedFileError(HedExceptions.CANNOT_PARSE_JSON, str(e), self.name) from e

def extract_definitions(self, hed_schema, error_handler=None):
""" Gather and validate definitions in metadata.
""" Gather and validate type_defs in metadata.

Parameters:
hed_schema (HedSchema): The schema to used to identify tags.
error_handler (ErrorHandler or None): The error handler to use for context, uses a default one if None.

Returns:
DefinitionDict: Contains all the definitions located in the sidecar.
DefinitionDict: Contains all the type_defs located in the sidecar.

"""
if error_handler is None:
Expand Down
2 changes: 1 addition & 1 deletion hed/models/tabular_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_def_dict(self, hed_schema, extra_def_dicts=None):
""" Returns the definition dict for this sidecar.

Parameters:
hed_schema(HedSchema): used to identify tags to find definitions
hed_schema(HedSchema): used to identify tags to find type_defs
extra_def_dicts (list, DefinitionDict, or None): Extra dicts to add to the list.

Returns:
Expand Down
2 changes: 1 addition & 1 deletion hed/models/timeseries_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, file=None, sidecar=None, extra_def_dicts=None, name=None):
name (str): The name to display for this file for error purposes.

Notes:
- The extra_def_dicts are external definitions that override the ones in the object.
- The extra_def_dicts are external type_defs that override the ones in the object.

"""

Expand Down
4 changes: 2 additions & 2 deletions hed/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from .analysis.file_dictionary import FileDictionary
# from .analysis.hed_context_manager import OnsetGroup, HedContextManager
from .analysis.hed_type_definitions import HedTypeDefinitions
from .analysis.hed_type_defs import HedTypeDefs
from .analysis.hed_type_factors import HedTypeFactors
from .analysis.hed_type_values import HedTypeValues
from .analysis.hed_type import HedType
from .analysis.hed_type_manager import HedTypeManager
from .analysis.hed_type_counts import HedTypeCount
from .analysis.key_map import KeyMap
Expand Down
4 changes: 2 additions & 2 deletions hed/tools/analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
""" Basic analysis tools. """
from .file_dictionary import FileDictionary
# from .hed_context_manager import OnsetGroup, HedContextManager
from .hed_type_definitions import HedTypeDefinitions
from .hed_type_defs import HedTypeDefs
from .hed_type_factors import HedTypeFactors
from .hed_type_values import HedTypeValues
from .hed_type import HedType
from .hed_type_manager import HedTypeManager
from .hed_type_counts import HedTypeCount
from .key_map import KeyMap
Expand Down
14 changes: 7 additions & 7 deletions hed/tools/analysis/analysis_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def assemble_hed(data_input, sidecar, schema, columns_included=None, expand_defs

Parameters:
data_input (TabularInput): The tabular input file whose HED annotations are to be assembled.
sidecar (Sidecar): Sidecar with definitions.
sidecar (Sidecar): Sidecar with type_defs.
schema (HedSchema): Hed schema
columns_included (list or None): A list of additional column names to include.
If None, only the list of assembled tags is included.
expand_defs (bool): If True, definitions are expanded when the events are assembled.
expand_defs (bool): If True, type_defs are expanded when the events are assembled.

Returns:
DataFrame or None: A DataFrame with the assembled events.
Expand All @@ -41,7 +41,7 @@ def assemble_hed(data_input, sidecar, schema, columns_included=None, expand_defs
else:
df = data_input.dataframe[eligible_columns].copy(deep=True)
df['HED_assembled'] = hed_string_list
# definitions = data_input.get_definitions().gathered_defs
# type_defs = data_input.get_definitions().gathered_defs
return df, definitions


Expand Down Expand Up @@ -95,7 +95,7 @@ def search_strings(hed_strings, queries, query_names=None):

:raises ValueError:
- If query names are invalid or duplicated.

"""

expression_parsers, query_names = get_expression_parsers(queries, query_names=query_names)
Expand All @@ -113,7 +113,7 @@ def search_strings(hed_strings, queries, query_names=None):
# Parameters:
# table (TabularInput): The input file to be searched.
# hed_schema (HedSchema or HedschemaGroup): If provided the HedStrings are converted to canonical form.
# expand_defs (bool): If True, definitions are expanded when the events are assembled.
# expand_defs (bool): If True, type_defs are expanded when the events are assembled.
#
# Returns:
# list: A list of HedString objects.
Expand All @@ -139,7 +139,7 @@ def search_strings(hed_strings, queries, query_names=None):
# """
#
# eligible_columns, missing_columns = separate_values(list(data_input.dataframe.columns), columns_included)
# hed_list, definitions = df_util.get_assembled(data_input, sidecar, hed_schema, extra_def_dicts=None, join_columns=True,
# hed_list, type_defs = df_util.get_assembled(data_input, sidecar, hed_schema, extra_def_dicts=None, join_columns=True,
# shrink_defs=False, expand_defs=True)
# expression = QueryParser(query)
# hed_tags = []
Expand Down Expand Up @@ -187,7 +187,7 @@ def search_strings(hed_strings, queries, query_names=None):
# list: A list of the removed Defs.
#
# Notes:
# - the hed_string_obj passed in no longer has definitions.
# - the hed_string_obj passed in no longer has type_defs.
#
# """
# to_remove = []
Expand Down
2 changes: 1 addition & 1 deletion hed/tools/analysis/annotation_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def _flatten_val_col(col_key, col_dict):
#
# Returns:
# str: A HED string extracted from the row.
# str: A string representing the description (without the Description tag.
# str: A string representing the description (without the Description tag).
#
# Notes:
# If description_tag is True the entire tag string is included with description.
Expand Down
Loading