Skip to content

Commit

Permalink
Merge pull request #31 from ONSdigital/395-add-kwargs-low-level-fun
Browse files Browse the repository at this point in the history
Add kwargs to arguments
  • Loading branch information
AntonZogk authored Jun 24, 2024
2 parents 6e8013c + a0bcfb9 commit 6ea8d2a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/apply_imputation_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def create_and_merge_imputation_values(
auxiliary,
construction_link,
imputation_types=("c", "fir", "bir", "fic"),
**kwargs
):
"""
Loop through different imputation types and merge the results according
Expand Down Expand Up @@ -44,6 +45,8 @@ def create_and_merge_imputation_values(
tuple. If 'fic' is selected 'c' must also be selected and proceed 'fic'.
For 'fic' to produce the correct result, the C marker must be in the first
period for a given reference.
kwargs : mapping, optional
A dictionary of keyword arguments passed into func.
Returns
-------
Expand Down
4 changes: 3 additions & 1 deletion src/calculate_imputation_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def calculate_imputation_link(
target_variable: str,
predictive_variable: str,
link_col: str,
**kwargs
) -> pd.DataFrame:
"""
Calculate link between target_variable and predictive_variable by strata,
Expand All @@ -32,7 +33,8 @@ def calculate_imputation_link(
Column name of the predicted target variable.
link_col : str
Name to use for the new column containing imputation link
kwargs : mapping, optional
A dictionary of keyword arguments passed into func.
Returns
-------
df : pd.DataFrame
Expand Down
5 changes: 3 additions & 2 deletions src/construction_matches.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pandas as pd


def flag_construction_matches(dataframe, target, period, auxiliary):
def flag_construction_matches(dataframe, target, period, auxiliary, **kwargs):
"""
Add flag to indicate whether the record has non-null target, period and
auxiliary variables, and is therefore valid to use when calculating
Expand All @@ -16,7 +16,8 @@ def flag_construction_matches(dataframe, target, period, auxiliary):
name of column containing time period
auxiliary : string
name of column containing auxiliary information
kwargs : mapping, optional
A dictionary of keyword arguments passed into func.
Returns
-------
pandas.DataFrame
Expand Down
3 changes: 3 additions & 0 deletions src/cumulative_imputation_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def get_cumulative_links(
period,
imputation_link,
time_difference=1,
**kwargs
):
"""
Create cumulative imputation links for multiple consecutive periods
Expand All @@ -33,6 +34,8 @@ def get_cumulative_links(
column name containing imputation links
time_difference : int
time difference between predictive and target period in months
kwargs : mapping, optional
A dictionary of keyword arguments passed into func
Returns
-------
Expand Down
15 changes: 13 additions & 2 deletions src/flag_and_count_matched_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@


def flag_matched_pair(
df, forward_or_backward, target, period, reference, strata, time_difference=1
df,
forward_or_backward,
target,
period,
reference,
strata,
time_difference=1,
**kwargs
):
"""
function to flag matched pairs using the shift method
Expand All @@ -24,6 +31,8 @@ def flag_matched_pair(
column name containing strata information (sic)
time_difference: int
lookup distance for matched pairs
kwargs : mapping, optional
A dictionary of keyword arguments passed into func.
Returns
-------
Expand Down Expand Up @@ -54,7 +63,7 @@ def flag_matched_pair(
return df


def count_matches(df, flag, period, strata):
def count_matches(df, flag, period, strata, **kwargs):
"""
function to flag matched pairs using the shift method
Expand All @@ -70,6 +79,8 @@ def count_matches(df, flag, period, strata):
column name containing time period
strata : str
column name containing strata information (sic)
kwargs : mapping, optional
A dictionary of keyword arguments passed into func.
Returns
-------
Expand Down
3 changes: 3 additions & 0 deletions src/imputation_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def create_impute_flags(
strata: str,
auxiliary: str,
predictive_auxiliary: str,
**kwargs
):

"""
Expand Down Expand Up @@ -36,6 +37,8 @@ def create_impute_flags(
predictive_auxiliary: str
Column name containing predictive auxiliary data, this is created,
by flag_matched_pair_merge function.
kwargs : mapping, optional
A dictionary of keyword arguments passed into func.
Returns
-------
Expand Down

0 comments on commit 6ea8d2a

Please sign in to comment.