Skip to content

Commit

Permalink
docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Jan 31, 2024
1 parent 987282b commit 0d41cc3
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions rdt/hyper_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,20 @@ def get_config(self):
})

def _update_multi_column_config(self, column_name_to_transformer):
"""Update the multi column fields in the config.
Review all the existing multi column fields and update them if necessary.
Args:
column_name_to_transformer (dict):
Dict mapping column names to transformers to be used for that column.
Returns:
dict:
Dict mapping all the multi column fields to their transformers.
Include unchanged multi column fields, new multi column fields and
updated multi column fields.
"""
column_names = [
item for key in column_name_to_transformer.keys()
for item in (key if isinstance(key, tuple) else (key,))
Expand Down Expand Up @@ -203,6 +216,17 @@ def _update_multi_column_config(self, column_name_to_transformer):
return multi_columns_to_transformer

def _validate_multi_column_transformers(self, column_name_to_transformer):
"""Validate the given multi column transformers are valid.
Update the ``column_name_to_transformer`` dict to include changes required
by the multi column transformers. If a multi column transformer is no longer
valid according to its columns names, then it will be replaced by the default
transformer for the sdtype of the columns.
Args:
column_name_to_transformer (dict):
Dict mapping column names to transformers to be used for that column.
"""
multi_columns_to_transformer = self._update_multi_column_config(column_name_to_transformer)
for columns in list(multi_columns_to_transformer.keys()):
transformer = multi_columns_to_transformer[columns]
Expand All @@ -223,6 +247,17 @@ def _validate_multi_column_transformers(self, column_name_to_transformer):
return column_name_to_transformer

def _update_multi_column_transformers(self, column_name_to_transformer):
"""Update the transformer field for multi column fields.
Args:
column_name_to_transformer (dict):
Dict mapping column names to transformers to be used for that column.
Returns:
dict:
Updated ``column_name_to_transformer`` dict with everything to update
multi and single column fields.
"""
column_name_to_transformer = self._validate_multi_column_transformers(
column_name_to_transformer
)
Expand All @@ -242,6 +277,12 @@ def _update_multi_column_transformers(self, column_name_to_transformer):


def _update_single_column_transformers(self, column_name_to_transformer):
"""Update the transformer field for single column fields.
Args:
column_name_to_transformer (dict):
Dict mapping column names to transformers to be used for that column.
"""
for column, transformer in column_name_to_transformer.items():
if isinstance(column, tuple):
continue
Expand Down

0 comments on commit 0d41cc3

Please sign in to comment.