Skip to content

Commit 63e37ec

Browse files
committed
bug fixes
1 parent 5d51d38 commit 63e37ec

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

flasc/analysis/expected_power_analysis.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ def _total_uplift_expected_power_with_standard_error(
317317
df_, test_cols=test_cols, bin_cols_with_df_name=bin_cols_with_df_name
318318
)
319319

320-
# with pl.Config(tbl_cols=-1):
321-
# print(df_cov)
320+
with pl.Config(tbl_cols=-1):
321+
print(df_cov)
322322

323323
# In current version of code, covarariances are either set to 0 or set to
324324
# product of variances
@@ -368,8 +368,8 @@ def _total_uplift_expected_power_with_standard_error(
368368
bin_cols_without_df_name=bin_cols_without_df_name,
369369
)
370370

371-
# with pl.Config(tbl_cols=-1):
372-
# print(df_bin)
371+
with pl.Config(tbl_cols=-1):
372+
print(df_bin)
373373

374374
# Join the covariance dataframe to df_bin
375375
df_bin = df_bin.join(df_cov, on=bin_cols_with_df_name, how="left")
@@ -463,9 +463,21 @@ def _total_uplift_expected_power_with_standard_error(
463463
# pow_farm_var
464464
df_sub = df_sub.pivot(
465465
on="df_name",
466-
index=bin_cols_without_df_name + ["weight"],
466+
index=bin_cols_without_df_name, # + ["weight"],
467467
)
468468

469+
# Assign the weight column to be the mean of weight_[uplift_pair[0]]
470+
# and weight_[uplift_pair[1]]
471+
df_sub = df_sub.with_columns(
472+
weight=(pl.col(f"weight_{uplift_pair[0]}") + pl.col(f"weight_{uplift_pair[1]}")) / 2
473+
)
474+
475+
# Remove the weight_pair columns
476+
df_sub = df_sub.drop([f"weight_{uplift_pair[0]}", f"weight_{uplift_pair[1]}"])
477+
478+
with pl.Config(tbl_cols=-1):
479+
print(df_sub)
480+
469481
# Compute the expected power ratio per bin
470482
df_sub = df_sub.with_columns(
471483
expected_power_ratio=pl.col(f"pow_farm_{uplift_pair[1]}")

flasc/analysis/expected_power_analysis_utilities.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,9 @@ def _fill_cov_with_var(
362362
.alias(cov_col)
363363
)
364364

365-
# Remove the null_map column
366-
df_cov = df_cov.drop("null_map")
365+
# Remove the null_map column if exists
366+
if "null_map" in df_cov.columns:
367+
df_cov = df_cov.drop("null_map")
367368

368369
return df_cov
369370

0 commit comments

Comments
 (0)