Skip to content
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
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 type_defs to expand
def_dict (DefinitionDict): The definitions 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 type_defs to use for validation
extra_def_dicts(list of DefDict or DefDict): all definitions 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 type_defs(if needed)
hed_schema(HedSchema): used to identify tags to find definitions(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 type_defs will take precedent if there is a conflict with tag_columns.
Sidecar column definitions 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 type_defs.
hed_schema (Schema): A HED schema object to use for extracting definitions.
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 type_defs from a series of def-expands, including possibly ambiguous ones"""
"""Class for gathering definitions 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 type_defs.
ambiguous_defs (dict, optional): A dictionary of ambiguous def-expand type_defs.
known_defs (dict, optional): A dictionary of known definitions.
ambiguous_defs (dict, optional): A dictionary of ambiguous def-expand definitions.

"""
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 type_defs to be added.
known_defs (dict, optional): A dictionary of known definitions to be added.

Returns:
tuple: A tuple containing the DefinitionDict, ambiguous type_defs, and errors.
tuple: A tuple containing the DefinitionDict, ambiguous definitions, 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 type_defs and handle known and ambiguous type_defs.
"""Process a single HED string to extract definitions and handle known and ambiguous definitions.

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


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

"""

Expand All @@ -16,7 +16,7 @@ def __init__(self, def_dicts=None, hed_schema=None):

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

:raises TypeError:
Expand All @@ -30,7 +30,7 @@ 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 type_defs from dict(s) to this dict.
""" Add definitions from dict(s) to this dict.

Parameters:
def_dicts (list, DefinitionDict, or dict): DefinitionDict or list of DefinitionDicts/strings/dicts whose
Expand Down Expand Up @@ -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 type_defs found in the given definition dictionary to this mapper.
""" Add the definitions 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 type_defs
""" Returns the dictionary of definitions

Alias for .defs.items()

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

@property
def issues(self):
"""Returns issues about duplicate type_defs."""
"""Returns issues about duplicate definitions."""
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 type_defs from.
error_handler (ErrorHandler or None): Error context used to identify where type_defs are found.
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.

Returns:
list: List of issues encountered in checking for type_defs. Each issue is a dictionary.
list: List of issues encountered in checking for definitions. 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 type_defs
def_dict(DefinitionDict or dict): A dict of definitions

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 type_defs from this Sidecar
def_dict(DefinitionDict): The definitions 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 type_defs to expand
def_dict (DefinitionDict): The definitions 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 type_defs to find any differences
""" Gather def-expand tags in the strings/compare with known definitions 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 type_defs going in, that must
A DefinitionDict or anything its constructor takes. These are the known definitions going in, that must
match perfectly.
ambiguous_defs (dict): A dictionary containing ambiguous type_defs
ambiguous_defs (dict): A dictionary containing ambiguous definitions
format TBD. Currently def name key: list of lists of HED tags values
Returns:
tuple: A tuple containing the DefinitionDict, ambiguous type_defs, and errors.
tuple: A tuple containing the DefinitionDict, ambiguous definitions, 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 type_defs and will blindly removing invalid ones as well.
This does not validate definitions 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 type_defs to identify
def_dict(DefinitionDict): The definitions 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 type_defs, def labels, and expanded labels"""
""" Source names for definitions, 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 type_defs from this sidecar.
"""This is the definitions from this sidecar.

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

Returns:
DefinitionDict: The type_defs for this sidecar
DefinitionDict: The definitions 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 type_defs
hed_schema(HedSchema): used to identify tags to find definitions
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 type_defs in metadata.
""" Gather and validate definitions 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 type_defs located in the sidecar.
DefinitionDict: Contains all the definitions 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 type_defs
hed_schema(HedSchema): used to identify tags to find definitions
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 type_defs that override the ones in the object.
- The extra_def_dicts are external definitions that override the ones in the object.

"""

Expand Down
11 changes: 5 additions & 6 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 type_defs.
sidecar (Sidecar): Sidecar with definitions.
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, type_defs are expanded when the events are assembled.
expand_defs (bool): If True, definitions are expanded when the events are assembled.

Returns:
DataFrame or None: A DataFrame with the assembled events.
Expand All @@ -41,7 +41,6 @@ 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
# type_defs = data_input.get_definitions().gathered_defs
return df, definitions


Expand Down Expand Up @@ -113,7 +112,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, type_defs are expanded when the events are assembled.
# expand_defs (bool): If True, definitions are expanded when the events are assembled.
#
# Returns:
# list: A list of HedString objects.
Expand All @@ -139,7 +138,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, type_defs = df_util.get_assembled(data_input, sidecar, hed_schema, extra_def_dicts=None, join_columns=True,
# hed_list, definitions = 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 +186,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 type_defs.
# - the hed_string_obj passed in no longer has definitions.
#
# """
# to_remove = []
Expand Down
2 changes: 1 addition & 1 deletion hed/tools/analysis/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, input_data, hed_schema, extra_defs=None):
Parameters:
input_data (TabularInput): Represents an events file with its sidecar.
hed_schema (HedSchema): HED schema used in this
extra_defs (DefinitionDict): Extra type_defs not included in the input_data information.
extra_defs (DefinitionDict): Extra definitions not included in the input_data information.

:raises HedFileError:
- if there are any unmatched offsets.
Expand Down
4 changes: 2 additions & 2 deletions hed/tools/analysis/hed_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, event_manager, name, type_tag="condition-variable"):
type_tag (str): Lowercase short form of the tag to be managed.

:raises HedFileError:
- On errors such as unmatched onsets or missing type_defs.
- On errors such as unmatched onsets or missing definitions.

"""
self.name = name
Expand Down Expand Up @@ -59,7 +59,7 @@ def type_variables(self):
return set(self._type_map.keys())

def get_type_def_names(self):
""" Return the type_defs """
""" Return the type defs names """
tag_list = []
for variable, factor in self._type_map.items():
tag_list = tag_list + [key for key in factor.levels.keys()]
Expand Down
2 changes: 1 addition & 1 deletion hed/tools/analysis/hed_type_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def add_descriptions(self, type_defs):
""" Update this summary based on the type variable map.

Parameters:
type_defs (HedTypeDefinitions): Contains the information about the value of a type.
type_defs (HedTypeDefs): Contains the information about the value of a type.

"""

Expand Down
4 changes: 2 additions & 2 deletions hed/tools/analysis/hed_type_defs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Manages type_defs associated with a type such as condition-variable. """
""" Manages definitions associated with a type such as condition-variable. """

from hed.models.hed_tag import HedTag
from hed.models.definition_dict import DefinitionDict
Expand Down Expand Up @@ -84,7 +84,7 @@ def _extract_def_map(self):
return def_map

def _extract_type_map(self):
""" Extract the type_defs associated with each type value and add them to the dictionary. """
""" Extract the definitions associated with each type value and add them to the dictionary. """

type_map = {}
for def_name, def_values in self.def_map.items():
Expand Down
Loading