From df947966dbc07b67c711bc59fe2a04eb51cbe0b0 Mon Sep 17 00:00:00 2001 From: Kay Robbins <1189050+VisLab@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:43:01 -0600 Subject: [PATCH] Minor doc corrections in remodeling --- hed/tools/remodeling/backup_manager.py | 11 ++++++++++- hed/tools/remodeling/cli/run_remodel.py | 4 ++-- hed/tools/remodeling/dispatcher.py | 11 ++++++----- hed/tools/remodeling/operations/base_op.py | 2 +- .../remodeling/operations/factor_hed_tags_op.py | 15 +++++++++------ .../remodeling/operations/remap_columns_op.py | 2 +- hed/tools/remodeling/operations/split_rows_op.py | 8 ++++---- 7 files changed, 33 insertions(+), 20 deletions(-) diff --git a/hed/tools/remodeling/backup_manager.py b/hed/tools/remodeling/backup_manager.py index c9685b2fd..608f4331b 100644 --- a/hed/tools/remodeling/backup_manager.py +++ b/hed/tools/remodeling/backup_manager.py @@ -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: @@ -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: diff --git a/hed/tools/remodeling/cli/run_remodel.py b/hed/tools/remodeling/cli/run_remodel.py index 345f6d377..9e044bb8a 100644 --- a/hed/tools/remodeling/cli/run_remodel.py +++ b/hed/tools/remodeling/cli/run_remodel.py @@ -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) diff --git a/hed/tools/remodeling/dispatcher.py b/hed/tools/remodeling/dispatcher.py index 01975a536..4cc4df9f9 100644 --- a/hed/tools/remodeling/dispatcher.py +++ b/hed/tools/remodeling/dispatcher.py @@ -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): diff --git a/hed/tools/remodeling/operations/base_op.py b/hed/tools/remodeling/operations/base_op.py index a1bee66f1..4f04f6397 100644 --- a/hed/tools/remodeling/operations/base_op.py +++ b/hed/tools/remodeling/operations/base_op.py @@ -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. diff --git a/hed/tools/remodeling/operations/factor_hed_tags_op.py b/hed/tools/remodeling/operations/factor_hed_tags_op.py index 3f809de5e..763371171 100644 --- a/hed/tools/remodeling/operations/factor_hed_tags_op.py +++ b/hed/tools/remodeling/operations/factor_hed_tags_op.py @@ -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) diff --git a/hed/tools/remodeling/operations/remap_columns_op.py b/hed/tools/remodeling/operations/remap_columns_op.py index 90957d573..1c1492211 100644 --- a/hed/tools/remodeling/operations/remap_columns_op.py +++ b/hed/tools/remodeling/operations/remap_columns_op.py @@ -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. diff --git a/hed/tools/remodeling/operations/split_rows_op.py b/hed/tools/remodeling/operations/split_rows_op.py index 7a05741ab..3323af10e 100644 --- a/hed/tools/remodeling/operations/split_rows_op.py +++ b/hed/tools/remodeling/operations/split_rows_op.py @@ -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. """