Skip to content

Commit e5eec12

Browse files
committed
Remove redundant upper_f initialization and None check
The initialization of upper_f = None and subsequent None check were unnecessary because the if-elif-else chain guarantees that upper_f is always assigned to a function before use: - If df is DataFrame or str → upper_f = upper_f_dataframe - If df is list of str → upper_f = upper_f_str_list - If df is list of DataFrame → upper_f = upper_f_df_list - Otherwise → raises TypeError (execution doesn't continue) The final 'if upper_f is None' check at line 477-478 could never be True, and the initialization only existed to silence a 'possibly unbound' warning. Simplifies code logic without changing behavior. Addresses reviewer feedback about unnecessary complexity.
1 parent 681180c commit e5eec12

1 file changed

Lines changed: 0 additions & 7 deletions

File tree

src/bootstrap.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,6 @@ def Bootstrap_reduce_mem(df, group_on, bs_params_list, bootstrap_dir, name_fcn=N
334334
DataFrame containing the bootstrap results.
335335
"""
336336
bs_params_list = list(bs_params_list)
337-
338-
# Initialize upper_f to avoid possibly unbound warning
339-
upper_f = None
340337

341338
if isinstance(df, pd.DataFrame) or isinstance(df, str):
342339
if isinstance(df, str):
@@ -472,10 +469,6 @@ def bs_params_eval(bs_params):
472469
raise TypeError(f"Unsupported type for df[0]: {type(df[0])}")
473470
else:
474471
raise TypeError(f"Unsupported type for df: {type(df)}")
475-
476-
# Ensure upper_f is defined
477-
if upper_f is None:
478-
raise RuntimeError("upper_f was not properly initialized")
479472

480473
bs_filenames = [upper_f(df_group, bs_params_list) for df_group in df]
481474
return bs_filenames

0 commit comments

Comments
 (0)