From e1027947d6c1cbbab710b11d79a26a033c277011 Mon Sep 17 00:00:00 2001 From: Sebastian Daza Date: Wed, 11 Dec 2024 12:16:46 +0100 Subject: [PATCH 1/2] update --- tests/test_power_sim.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test_power_sim.py diff --git a/tests/test_power_sim.py b/tests/test_power_sim.py new file mode 100644 index 0000000..ed58952 --- /dev/null +++ b/tests/test_power_sim.py @@ -0,0 +1,29 @@ +import pytest +from experiment_utils.power_sim import PowerSim +from experiment_utils.spark_instance import * + + +def test_power_estimation(): + """Test power estimation""" + p = PowerSim(metric='proportion', relative_effect=False, variants=1, + nsim=1000, alpha=0.05, alternative='two-tailed') + try: + p.get_power(baseline=[0.33], effect=[0.03], sample_size=[3000]) + assert True + except Exception as e: + pytest.fail(f" raised an exception: {e}") + +def test_plot_power(): + """Test plot power""" + p = PowerSim(metric='proportion', relative_effect=False, + variants=2, alternative='two-tailed', + nsim=100, correction='holm') + try: + p.grid_sim_power(baseline_rates=[[0.33]], + effects=[[0.01, 0.03], [0.03, 0.05], [0.03, 0.07]], + sample_sizes= [[1000], [5000], [9000]], + threads=16, + plot=True) + assert True + except Exception as e: + pytest.fail(f" raised an exception: {e}") \ No newline at end of file From 3e25e16d63ea093d5798cbbcfea08a849bee9b2d Mon Sep 17 00:00:00 2001 From: Sebastian Daza Date: Wed, 11 Dec 2024 13:38:42 +0100 Subject: [PATCH 2/2] fix flake8 --- tests/test_power_sim.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_power_sim.py b/tests/test_power_sim.py index ed58952..2d2fd24 100644 --- a/tests/test_power_sim.py +++ b/tests/test_power_sim.py @@ -13,6 +13,7 @@ def test_power_estimation(): except Exception as e: pytest.fail(f" raised an exception: {e}") + def test_plot_power(): """Test plot power""" p = PowerSim(metric='proportion', relative_effect=False, @@ -20,10 +21,10 @@ def test_plot_power(): nsim=100, correction='holm') try: p.grid_sim_power(baseline_rates=[[0.33]], - effects=[[0.01, 0.03], [0.03, 0.05], [0.03, 0.07]], - sample_sizes= [[1000], [5000], [9000]], - threads=16, - plot=True) + effects=[[0.01, 0.03], [0.03, 0.05], [0.03, 0.07]], + sample_sizes=[[1000], [5000], [9000]], + threads=16, + plot=True) assert True except Exception as e: - pytest.fail(f" raised an exception: {e}") \ No newline at end of file + pytest.fail(f" raised an exception: {e}")