Skip to content

Commit

Permalink
Merge pull request #459 from dvadym/format
Browse files Browse the repository at this point in the history
Run make format-style-python
  • Loading branch information
chinmayshah99 authored May 28, 2023
2 parents c4da243 + 6e12865 commit aadae4a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
5 changes: 2 additions & 3 deletions tests/algorithms/test_numerical_mechanisms.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ def test_gaussian_mechanism_create_from_std():
gaussian = num_mech.GaussianMechanism.create_from_standard_deviation(std)
assert gaussian.std == 2
value = gaussian.add_noise(100)
assert 80 <= value <= 120 # in 10*sigma
assert 80 <= value <= 120 # in 10*sigma
assert type(value) is int
value = gaussian.add_noise(200.0)
assert type(value) is float
assert 180 <= value <= 220 # in 10*sigma

assert 180 <= value <= 220 # in 10*sigma
26 changes: 22 additions & 4 deletions tests/algorithms/test_partition_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,24 @@ def test_gaussian_keep_and_return_noised_value(
100,
[0, 0, 0.12818308050524607, 1],
),
([10, 99, 109, 200], "laplace", 1, 1e-5, 1, 100, [0, 0, 0.08103083927575383, 1]),
([10, 99, 109, 200], "gaussian", 1, 1e-5, 1, 100, [0, 0, 0.017845473615190732, 1]),
(
[10, 99, 109, 200],
"laplace",
1,
1e-5,
1,
100,
[0, 0, 0.08103083927575383, 1],
),
(
[10, 99, 109, 200],
"gaussian",
1,
1e-5,
1,
100,
[0, 0, 0.017845473615190732, 1],
),
],
)
def test_pre_thresholding(
Expand All @@ -152,7 +168,7 @@ def test_pre_thresholding(
delta,
max_partitions_contributed,
pre_threshold,
expected_probs
expected_probs,
):
partition_selector = create_partition_strategy(
strategy, epsilon, delta, max_partitions_contributed, pre_threshold
Expand All @@ -175,4 +191,6 @@ def test_pre_thresholding(
assert sum(sims) == 0
else:
pred_prob_of_keep = np.mean(sims)
assert pred_prob_of_keep == pytest.approx(expected_prob, ACCURACY_THRESHOLD)
assert pred_prob_of_keep == pytest.approx(
expected_prob, ACCURACY_THRESHOLD
)

0 comments on commit aadae4a

Please sign in to comment.