diff --git a/setup.cfg b/setup.cfg index 74673ef..ee15d9b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ep-stats -version = 2.3.0 +version = 2.3.1 description = Statistical package to evaluate ab tests in experimentation platform. long_description = file: README.md long_description_content_type = text/markdown diff --git a/src/epstats/toolkit/parser.py b/src/epstats/toolkit/parser.py index c8814aa..61f27d3 100644 --- a/src/epstats/toolkit/parser.py +++ b/src/epstats/toolkit/parser.py @@ -206,6 +206,8 @@ def __str__(self): return f"{self.value}" def evaluate_agg(self, goals): + # n_variants = goals["exp_variant_id"].nunique() + # return [self.value] * n_variants return self.value def evaluate_by_unit(self, goals): diff --git a/src/epstats/toolkit/statistics.py b/src/epstats/toolkit/statistics.py index a37d315..f6e3213 100644 --- a/src/epstats/toolkit/statistics.py +++ b/src/epstats/toolkit/statistics.py @@ -417,7 +417,7 @@ def power_from_required_sample_size_per_variant( power """ - if n_variants < 2: + if n_variants < 2 or required_sample_size_per_variant == 0: return np.nan required_sample_size_ratio = sample_size_per_variant / required_sample_size_per_variant diff --git a/tests/epstats/toolkit/test_statistics.py b/tests/epstats/toolkit/test_statistics.py index c57fc2a..24526c4 100644 --- a/tests/epstats/toolkit/test_statistics.py +++ b/tests/epstats/toolkit/test_statistics.py @@ -238,3 +238,23 @@ def test_power_from_required_sample_size_per_variant_nan_params(): required_sample_size_per_variant=np.nan, ) ) + + +@pytest.mark.parametrize( + "args", + [ + { + "n_variants": 1, + "sample_size_per_variant": 100, + "required_sample_size_per_variant": 100, + }, + { + "n_variants": 2, + "sample_size_per_variant": 0, + "required_sample_size_per_variant": 0, + }, + ], +) +def test_power_from_required_sample_size_per_variant_is_nan(args): + + assert np.isnan(Statistics.power_from_required_sample_size_per_variant(**args))