Skip to content

Commit 0bc0028

Browse files
committed
Update analysis
1 parent f6de7ab commit 0bc0028

File tree

2 files changed

+95
-11
lines changed

2 files changed

+95
-11
lines changed

flasc/analysis/expected_power_analysis.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def _total_uplift_expected_power_with_standard_error(
374374
with pl.Config(tbl_cols=-1):
375375
print(df_bin)
376376

377-
# Synchronize the null values
377+
# Synchronize the null values in the mean columns
378378
df_bin = _synchronize_nulls(
379379
df_bin=df_bin,
380380
sync_cols=[f"{col}_mean" for col in test_cols],
@@ -393,6 +393,9 @@ def _total_uplift_expected_power_with_standard_error(
393393
pl.any_horizontal([pl.col(f"{c}_mean").is_not_null() for c in test_cols])
394394
)
395395

396+
with pl.Config(tbl_cols=-1):
397+
print(df_bin)
398+
396399
# with pl.Config(tbl_cols=-1):
397400
# print(df_bin)
398401

tests/expected_power_analysis_test.py

+91-10
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def test__get_num_points_pair():
353353
)
354354

355355
# Test that df_count and df_expected are essentially equal
356-
assert_frame_equal(df_count, df_expected, check_row_order=False, check_dtype=False)
356+
assert_frame_equal(df_count, df_expected, check_row_order=False, check_dtypes=False)
357357

358358

359359
def test_compute_covariance():
@@ -474,7 +474,7 @@ def test_fill_cov_with_var_dont_fill_all():
474474

475475
filled_df = _fill_cov_with_var(test_df, test_cols=["pow_000", "pow_001"], fill_all=False)
476476

477-
assert_frame_equal(filled_df, expected_df, check_row_order=False, check_dtype=False)
477+
assert_frame_equal(filled_df, expected_df, check_row_order=False, check_dtypes=False)
478478

479479

480480
def test_fill_cov_with_var_fill_all():
@@ -513,7 +513,7 @@ def test_fill_cov_with_var_fill_all():
513513

514514
filled_df = _fill_cov_with_var(test_df, test_cols=["pow_000", "pow_001"], fill_all=True)
515515

516-
assert_frame_equal(filled_df, expected_df, check_row_order=False, check_dtype=False)
516+
assert_frame_equal(filled_df, expected_df, check_row_order=False, check_dtypes=False)
517517

518518

519519
def test_set_cov_to_zero():
@@ -552,7 +552,7 @@ def test_set_cov_to_zero():
552552

553553
zero_cov_df = _set_cov_to_zero(test_df, test_cols=["pow_000", "pow_001"])
554554

555-
assert_frame_equal(zero_cov_df, expected_df, check_row_order=False, check_dtype=False)
555+
assert_frame_equal(zero_cov_df, expected_df, check_row_order=False, check_dtypes=False)
556556

557557

558558
def test_synchronize_cov_nulls_back_to_mean():
@@ -599,7 +599,7 @@ def test_synchronize_cov_nulls_back_to_mean():
599599
test_cols=["pow_000", "pow_001"],
600600
)
601601

602-
assert_frame_equal(df_res, expected_df_bin, check_row_order=False, check_dtype=False)
602+
assert_frame_equal(df_res, expected_df_bin, check_row_order=False, check_dtypes=False)
603603

604604

605605
def test_total_uplift_expected_power_with_standard_error():
@@ -624,7 +624,7 @@ def test_total_uplift_expected_power_with_standard_error():
624624

625625

626626
def test_center_uplift_identical():
627-
a_in = load_data()
627+
a_in = load_repeated_data()
628628

629629
epao_single = total_uplift_expected_power(
630630
a_in=a_in,
@@ -667,10 +667,91 @@ def test_center_uplift_identical():
667667
use_standard_error=True,
668668
)
669669

670-
# print(epao_single.uplift_results)
671-
# print(epao_boot.uplift_results)
672-
# print(epao_standard.uplift_results)
673-
674670
assert epao_single.uplift_results["scada_uplift"] == 1.1
675671
assert epao_boot.uplift_results["scada_uplift"]["energy_uplift_ctr"] == 1.1
676672
assert epao_standard.uplift_results["scada_uplift"]["energy_uplift_ctr"] == 1.1
673+
674+
675+
def test_uncertain_intervals():
676+
a_in = load_repeated_data()
677+
678+
epao_boot = total_uplift_expected_power(
679+
a_in=a_in,
680+
uplift_pairs=[("baseline", "wake_steering")],
681+
uplift_names=["scada_uplift"],
682+
test_turbines=[0, 1],
683+
use_predefined_wd=True,
684+
use_predefined_ws=True,
685+
wd_step=1.0,
686+
wd_min=0.5,
687+
ws_min=0.5,
688+
use_standard_error=False,
689+
N=10,
690+
)
691+
692+
epao_standard_zero = total_uplift_expected_power(
693+
a_in=a_in,
694+
uplift_pairs=[("baseline", "wake_steering")],
695+
uplift_names=["scada_uplift"],
696+
test_turbines=[0, 1],
697+
use_predefined_wd=True,
698+
use_predefined_ws=True,
699+
wd_step=1.0,
700+
wd_min=0.5,
701+
ws_min=0.5,
702+
use_standard_error=True,
703+
set_cov_to_zero_or_var="zero",
704+
)
705+
706+
epao_standard_var = total_uplift_expected_power(
707+
a_in=a_in,
708+
uplift_pairs=[("baseline", "wake_steering")],
709+
uplift_names=["scada_uplift"],
710+
test_turbines=[0, 1],
711+
use_predefined_wd=True,
712+
use_predefined_ws=True,
713+
wd_step=1.0,
714+
wd_min=0.5,
715+
ws_min=0.5,
716+
use_standard_error=True,
717+
set_cov_to_zero_or_var="var",
718+
)
719+
720+
print("Bootstrapping")
721+
print(epao_boot.uplift_results["scada_uplift"]["energy_uplift_ctr"])
722+
print(epao_boot.uplift_results["scada_uplift"]["energy_uplift_lb"])
723+
print(epao_boot.uplift_results["scada_uplift"]["energy_uplift_ub"])
724+
assert (
725+
epao_boot.uplift_results["scada_uplift"]["energy_uplift_lb"]
726+
<= epao_boot.uplift_results["scada_uplift"]["energy_uplift_ctr"]
727+
)
728+
assert (
729+
epao_boot.uplift_results["scada_uplift"]["energy_uplift_ub"]
730+
>= epao_boot.uplift_results["scada_uplift"]["energy_uplift_ctr"]
731+
)
732+
733+
print("Standard error zero")
734+
print(epao_standard_zero.uplift_results["scada_uplift"]["energy_uplift_ctr"])
735+
print(epao_standard_zero.uplift_results["scada_uplift"]["energy_uplift_lb"])
736+
print(epao_standard_zero.uplift_results["scada_uplift"]["energy_uplift_ub"])
737+
assert (
738+
epao_standard_zero.uplift_results["scada_uplift"]["energy_uplift_lb"]
739+
<= epao_standard_zero.uplift_results["scada_uplift"]["energy_uplift_ctr"]
740+
)
741+
assert (
742+
epao_standard_zero.uplift_results["scada_uplift"]["energy_uplift_ub"]
743+
>= epao_standard_zero.uplift_results["scada_uplift"]["energy_uplift_ctr"]
744+
)
745+
746+
print("Standard error var")
747+
print(epao_standard_var.uplift_results["scada_uplift"]["energy_uplift_ctr"])
748+
print(epao_standard_var.uplift_results["scada_uplift"]["energy_uplift_lb"])
749+
print(epao_standard_var.uplift_results["scada_uplift"]["energy_uplift_ub"])
750+
assert (
751+
epao_standard_var.uplift_results["scada_uplift"]["energy_uplift_lb"]
752+
<= epao_standard_var.uplift_results["scada_uplift"]["energy_uplift_ctr"]
753+
)
754+
assert (
755+
epao_standard_var.uplift_results["scada_uplift"]["energy_uplift_ub"]
756+
>= epao_standard_var.uplift_results["scada_uplift"]["energy_uplift_ctr"]
757+
)

0 commit comments

Comments
 (0)