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: 4 additions & 2 deletions hed/models/base_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ def to_excel(self, file):

Parameters:
file (str or file-like): Location to save this base input.
Raises:
ValueError: if empty file object or file cannot be opened.

:raises ValueError:
- if empty file object or file cannot be opened.

"""
if not file:
raise ValueError("Empty file name or object passed in to BaseInput.save.")
Expand Down
4 changes: 2 additions & 2 deletions hed/models/definition_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def get_definition(self, replace_tag, placeholder_value=None, return_copy_of_tag
str: The expanded def tag name
HedGroup: The contents of this definition(including the def tag itself)

Raises:
ValueError: If a placeholder_value is passed, but this definition doesn't have a placeholder.
:raises ValueError:
- If a placeholder_value is passed, but this definition doesn't have a placeholder.

"""
if self.takes_value == (placeholder_value is None):
Expand Down
4 changes: 2 additions & 2 deletions hed/models/hed_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def append(self, tag_or_group):
Parameters:
tag_or_group (HedTag or HedGroup): The new object to add to this group.

Raises:
ValueError: If a HedGroupFrozen.
:raises ValueError:
If a HedGroupFrozen.

"""
tag_or_group._parent = self
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 @@ -179,8 +179,8 @@ def split_into_groups(hed_string, hed_schema=None, def_dict=None):
Returns:
list: A list of HedTag and/or HedGroup.

Raises:
ValueError: If the string is significantly malformed, such as mismatched parentheses.
:raises ValueError:
- If the string is significantly malformed, such as mismatched parentheses.

Notes:
- The parse tree consists of tag groups, tags, and delimiters.
Expand Down
4 changes: 2 additions & 2 deletions hed/models/hed_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def short_base_tag(self, new_tag_val):
Parameters:
new_tag_val (str): The new short_base_tag for this tag.

Raises:
ValueError: If tags cannot unidentified.
:raises ValueError:
- If tags cannot unidentified.

Note:
- Generally this is used to swap def to def-expand.
Expand Down
16 changes: 10 additions & 6 deletions hed/models/sidecar.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ def load_sidecar_file(self, file):
Parameters:
file (str or FileLike): If a string, this is a filename. Otherwise, it will be parsed as a file-like.

Raises:
HedFileError: If the file was not found or could not be parsed into JSON.
:raises HedFileError:
- If the file was not found or could not be parsed into JSON.

"""
if not file:
return {}
Expand All @@ -143,8 +144,10 @@ def load_sidecar_files(self, files):

Parameters:
files (str or FileLike or list): A string or file-like object representing a JSON file, or a list of such.
Raises:
HedFileError: If the file was not found or could not be parsed into JSON.

:raises HedFileError:
- If the file was not found or could not be parsed into JSON.

"""
if not files:
return {}
Expand Down Expand Up @@ -184,8 +187,9 @@ def _load_json_file(self, fp):
Parameters:
fp (File-like): The JSON source stream.

Raises:
HedFileError: If the file cannot be parsed.
:raises HedFileError:
- If the file cannot be parsed.

"""
try:
return json.load(fp)
Expand Down
4 changes: 2 additions & 2 deletions hed/schema/hed_schema_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def __init__(self, schema_list):
Returns:
HedSchemaGroup: the container created.

Raises:
HedFileError: If multiple schemas have the same library prefixes.
:raises HedFileError:
- If multiple schemas have the same library prefixes.

"""
if len(schema_list) == 0:
Expand Down
16 changes: 8 additions & 8 deletions hed/schema/hed_schema_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def from_string(schema_string, file_type=".xml", schema_namespace=None):
Returns:
(HedSchema): The loaded schema.

Raises:
HedFileError: If empty string or invalid extension is passed.
:raises HedFileError:
- If empty string or invalid extension is passed.

Notes:
- The loading is determined by file type.
Expand Down Expand Up @@ -78,8 +78,8 @@ def load_schema(hed_path=None, schema_namespace=None):
Returns:
HedSchema: The loaded schema.

Raises:
HedFileError: If there are any fatal issues when loading the schema.
:raises HedFileError:
- If there are any fatal issues when loading the schema.

"""
if not hed_path:
Expand Down Expand Up @@ -129,8 +129,8 @@ def _load_schema_version(xml_version=None, xml_folder=None):
Returns:
HedSchema or HedSchemaGroup: The requested HedSchema object.

Raises:
HedFileError: If the xml_version is not valid.
:raises HedFileError:
- If the xml_version is not valid.

Notes:
- The library schema files have names of the form HED_(LIBRARY_NAME)_(version).xml.
Expand Down Expand Up @@ -178,8 +178,8 @@ def load_schema_version(xml_version=None, xml_folder=None):
Returns:
HedSchema or HedSchemaGroup: The schema or schema group extracted.

Raises:
HedFileError: If the xml_version is not valid.
:raises HedFileError:
- If the xml_version is not valid.

Notes:
- Loads the latest schema value if an empty version is given (string or list).
Expand Down
8 changes: 4 additions & 4 deletions hed/schema/schema_validation_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def validate_attributes(attrib_dict, filename):
Returns:
list: List of issues. Each issue is a dictionary.

Raises:
HedFileError: if invalid or version not found in the dictionary.
:raises HedFileError:
- If invalid or version not found in the dictionary.

"""
validate_present_attributes(attrib_dict, filename)
Expand Down Expand Up @@ -111,8 +111,8 @@ def find_rooted_entry(tag_entry, schema, loading_merged):
rooted_tag(HedTagEntry or None): The base tag entry from the standard schema
Returns None if this tag isn't rooted

Raises:
HedValueError: Raises if the tag doesn't exist or similar
:raises HedValueError:
- If the tag doesn't exist or similar

"""
rooted_tag = tag_entry.has_attribute(constants.HedKey.Rooted, return_value=True)
Expand Down
8 changes: 4 additions & 4 deletions hed/tools/analysis/analysis_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def get_expression_parsers(queries, query_names=None):
Returns:
DataFrame - containing the search strings

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

"""
expression_parsers = []
Expand Down Expand Up @@ -93,8 +93,8 @@ def search_strings(hed_strings, queries, query_names=None):
Returns:
DataFrame - containing the factor vectors with results of the queries

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

"""

Expand Down
12 changes: 6 additions & 6 deletions hed/tools/analysis/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self, data, schema):
data (TabularInput): A tabular input file.
schema (HedSchema): A HED schema

Raises:
HedFileError: if there are any unmatched offsets.
:raises HedFileError:
- if there are any unmatched offsets.

"""

Expand Down Expand Up @@ -46,8 +46,8 @@ def iter_context(self):
def _create_event_list(self):
""" Create a list of events of extended duration.

Raises:
HedFileError: If the hed_strings contain unmatched offsets.
:raises HedFileError:
- If the hed_strings contain unmatched offsets.

"""

Expand Down Expand Up @@ -107,8 +107,8 @@ def _update_onset_list(self, group, onset_dict, event_index):
onset_dict (dict): A dictionary of OnsetGroup objects that keep track of span of an event.
event_index (int): The event number in the list.

Raises:
HedFileError if an unmatched offset is encountered.
:raises HedFileError:
- if an unmatched offset is encountered.

Notes:
- Modifies onset_dict and onset_list.
Expand Down
12 changes: 6 additions & 6 deletions hed/tools/analysis/hed_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def __init__(self, hed_strings, hed_schema):
hed_strings (list): A list of HedString objects to be managed.
hed_schema (HedSchema): A HedSchema

Raises:
HedFileError: if there are any unmatched offsets.
:raises HedFileError:
- If there are any unmatched offsets.

Notes:
The constructor has the side-effect of splitting each element of the hed_strings list into two
Expand Down Expand Up @@ -69,8 +69,8 @@ def iter_context(self):
def _create_onset_list(self):
""" Create a list of events of extended duration.

Raises:
HedFileError: If the hed_strings contain unmatched offsets.
:raises HedFileError:
- If the hed_strings contain unmatched offsets.

"""

Expand Down Expand Up @@ -122,8 +122,8 @@ def _update_onset_list(self, group, onset_dict, event_index, is_offset=False):
event_index (int): The event number in the list.
is_offset (bool): True if processing an offset.

Raises:
HedFileError if an unmatched offset is encountered.
:raises HedFileError:
- If an unmatched offset is encountered.

Notes:
- Modifies onset_dict and onset_list.
Expand Down
5 changes: 3 additions & 2 deletions hed/tools/analysis/hed_type_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ def __init__(self, hed_strings, hed_schema, definitions):
hed_schema (HedSchema or HedSchemaGroup): The HED schema to use for processing.
definitions (dict): A dictionary of DefinitionEntry objects.

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

"""

self.definitions = definitions
Expand Down
4 changes: 2 additions & 2 deletions hed/tools/analysis/hed_type_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def __init__(self, context_manager, definitions, name, type_tag="condition-varia
name (str): Name of the tabular file as a unique identifier.
type_tag (str): Lowercase short form of the tag to be managed.

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

"""
self.name = name
Expand Down
12 changes: 6 additions & 6 deletions hed/tools/analysis/key_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def make_template(self, additional_cols=None):
Returns:
DataFrame: A dataframe containing the template.

Raises:
HedFileError: If additional columns are not disjoint from the key columns.
:raises HedFileError:
- If additional columns are not disjoint from the key columns.

Notes:
- The template consists of the unique key columns in this map plus additional columns.
Expand All @@ -90,8 +90,8 @@ def remap(self, data):
- DataFrame: New dataframe with columns remapped.
- list: List of row numbers that had no correspondence in the mapping.

Raises:
HedFileError: If data is missing some of the key columns.
:raises HedFileError:
- If data is missing some of the key columns.

"""

Expand Down Expand Up @@ -145,8 +145,8 @@ def update(self, data, allow_missing=True, keep_counts=True):
Returns:
list: The indices of duplicates.

Raises:
HedFileError: If there are missing keys and allow_missing is False.
:raises HedFileError:
- If there are missing keys and allow_missing is False.

"""
df = get_new_dataframe(data)
Expand Down
12 changes: 6 additions & 6 deletions hed/tools/bids/bids_file_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def __init__(self, collection_name, files, entities=('sub', 'ses', 'task', 'run'
files (list or dict): Full paths of files to include.
entities (tuple): Entity names to use in creating the keys.

Raises:
HedFileError: If files has inappropriate values.
:raises HedFileError:
- If files has inappropriate values.

Notes:
- This function is used for cross listing BIDS style files for different studies.
Expand Down Expand Up @@ -117,8 +117,8 @@ def make_dict(self, files, entities):
Returns:
dict: A dictionary whose keys are entity keys and values are BidsFile objects.

Raises:
HedFileError: If incorrect format is passed or something not recognizable as a Bids file.
:raises HedFileError:
- If incorrect format is passed or something not recognizable as a Bids file.

"""
file_dict = {}
Expand Down Expand Up @@ -244,8 +244,8 @@ def _correct_file(cls, the_file):
Returns:
BidsFile: Either the original file or a newly created BidsTabularFile.

Raises:
HedFileError: If the_file isn't str or BidsFile.
:raises HedFileError:
- If the_file isn't str or BidsFile.

"""
if isinstance(the_file, str):
Expand Down
4 changes: 2 additions & 2 deletions hed/tools/bids/bids_tabular_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ def _correct_file(cls, the_file):
Returns:
BidsTabularFile: Either the original file or a newly created BidsTabularFile.

Raises:
HedFileError: If the_file isn't str or BidsTabularFile.
:raises HedFileError:
- If the_file isn't str or BidsTabularFile.

"""
if isinstance(the_file, str):
Expand Down
Loading