Add a test to check that not more compositions than max_compositions is requested (#21)

* Add a test to check we don't allow more compositions than
max_compositions

* Fix typo in calling compositions

Co-authored-by: Lukas Wutschitz <lukas.wutschitz@microsoft.com>
This commit is contained in:
Lukas Wutschitz 2021-11-10 15:00:49 +00:00 коммит произвёл GitHub
Родитель f4690b8956
Коммит 9d736f934d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -96,5 +96,5 @@ class Accountant:
approximation of true epsilon,
upper bound of true epsilon
"""
f_n = self.composer.compute_composition(num_compositions=num_compositions)
f_n = self.compute_compositions(num_compositions=num_compositions)
return f_n.compute_epsilon(self.delta, self.delta_error, self.eps_error)

Просмотреть файл

@ -31,6 +31,18 @@ class TestAccountant:
assert delta_upper == pytest.approx(delta_exact, rel=1e-3)
assert delta_lower == pytest.approx(delta_exact, rel=1e-3)
def test_throw_exceeding_max_compositions(self):
with pytest.raises(ValueError):
accountant = Accountant(
noise_multiplier=100.0,
sampling_probability=1.0,
delta=1e-8,
eps_error=0.01,
max_compositions=10000
)
accountant.compute_compositions(10001)
def test_throw_error_small_delta(self):
with pytest.raises(ValueError):
accountant = Accountant(