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
11 changes: 10 additions & 1 deletion hed/tools/remodeling/backup_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def create_backup(self, file_list, backup_name=None, verbose=True):
bool: True if the backup was successful. False if a backup of that name already exists.

Raises:
Exceptions when file errors of any kind occur during the creation of a backup.
HedFileError
- For missing or incorrect files.

OS-related error
- OS-related error when file copying occurs.

"""
if not backup_name:
Expand Down Expand Up @@ -79,6 +83,11 @@ def get_backup(self, backup_name):

Returns:
The dictionary with the backup info.

Notes:
- The dictionary with backup information has keys that are the paths of
the backed up files relative to the backup root. The values in this
dictionary are the dates on which the particular file was backed up.

"""
if backup_name not in self.backups_dict:
Expand Down
4 changes: 2 additions & 2 deletions hed/tools/remodeling/cli/run_remodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def main(arg_list=None):

Raises:
HedFileError
- if the data root directory does not exist.
- if the specified backup does not exist.
- if the data root directory does not exist.
- if the specified backup does not exist.

"""
args, operations = parse_arguments(arg_list)
Expand Down
11 changes: 6 additions & 5 deletions hed/tools/remodeling/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ def get_data_file(self, file_designator):
DataFrame: DataFrame after reading the path.

Raises:
HedFileError: If a valid file cannot be found.
HedFileError
- If a valid file cannot be found.

Note:
Notes:
- If a string is passed and there is a backup manager,
the string must correspond to the full path of the file in the original dataset.
In this case, the corresponding backup file is read and returned.
In this case, the corresponding backup file is read and returned.
- If a string is passed and there is no backup manager,
the data file corresponding to the file_designator is read and returned.
- If a Pandas DataFrame is passed, a copy is returned.
the data file corresponding to the file_designator is read and returned.
- If a Pandas DataFrame is passed, a copy is returned.

"""
if isinstance(file_designator, pd.DataFrame):
Expand Down
2 changes: 1 addition & 1 deletion hed/tools/remodeling/operations/base_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def check_parameters(self, parameters):
raise TypeError("BadType", f"{param_value} has type {type(param_value)} not {param_type}")

def do_op(self, dispatcher, df, name, sidecar=None):
""" Base class method to be overridden with by each operation.
""" Base class method to be overridden by each operation.

Parameters:
dispatcher (Dispatcher): Manages the operation I/O.
Expand Down
15 changes: 9 additions & 6 deletions hed/tools/remodeling/operations/factor_hed_tags_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ def __init__(self, parameters):
Raises:

KeyError
- If a required parameter is missing.
- If an unexpected parameter is provided.
- If a required parameter is missing.

- If an unexpected parameter is provided.

TypeError
- If a parameter has the wrong type.
- If a parameter has the wrong type.

ValueError
- If the specification is missing a valid operation.
- If the length of query names is not empty and not same length as queries.
- If there are duplicate query names.
- If the specification is missing a valid operation.

- If the length of query names is not empty and not same length as queries.

- If there are duplicate query names.

"""
super().__init__(self.PARAMS, parameters)
Expand Down
2 changes: 1 addition & 1 deletion hed/tools/remodeling/operations/remap_columns_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RemapColumnsOp(BaseOp):
- **ignore_missing** (*bool*): If True, entries whose key column values are not in map_list are ignored.

Optional remodeling parameters:
**integer_sources** (*list*): Sour columns that should be treated as integers rather than strings.
**integer_sources** (*list*): Source columns that should be treated as integers rather than strings.

Notes:
Each list element list is of length m + n with the key columns followed by mapped columns.
Expand Down
8 changes: 4 additions & 4 deletions hed/tools/remodeling/operations/split_rows_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@


class SplitRowsOp(BaseOp):
""" Split rows in a tabular file into multiple rows based on a column.
""" Split rows in a tabular file into multiple rows based on parameters.

Required remodeling parameters:
- **anchor_column** (*str*): The column in which new items are generated.
- **new_events** (*dict*): Mapping of new values based on values in the anchor_column.
- **remove_parent_row** (*bool*): If true, columns not in column_order are placed at end.
- **anchor_column** (*str*): The column in which the names of new items are stored.
- **new_events** (*dict*): Mapping of new values based on values in the original row.
- **remove_parent_row** (*bool*): If true, the original row that was split is removed.

"""

Expand Down