Skip to content

Commit

Permalink
Fixing histogram2d test
Browse files Browse the repository at this point in the history
  • Loading branch information
naoise-h committed Sep 12, 2023
1 parent 8c02c7a commit 6f60db3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/tools/test_histogram2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from diffprivlib.accountant import BudgetAccountant
from diffprivlib.tools.histograms import histogram2d
from diffprivlib.utils import PrivacyLeakWarning, BudgetError
from diffprivlib.utils import PrivacyLeakWarning, BudgetError, check_random_state


class TestHistogram2d(TestCase):
Expand Down Expand Up @@ -60,9 +60,11 @@ def test_different_result(self):
self.assertTrue((hist != dp_hist).any())

def test_density(self):
rng = check_random_state(1)

x = np.array([1, 2, 3, 4, 5])
y = np.array([5, 7, 1, 5, 9])
dp_hist, _, _ = histogram2d(x, y, epsilon=1, bins=3, range=[(0, 10), (0, 10)], density=True)
dp_hist, _, _ = histogram2d(x, y, epsilon=1, bins=3, range=[(0, 10), (0, 10)], density=True, random_state=rng)

# print(dp_hist.sum())

Expand Down

0 comments on commit 6f60db3

Please sign in to comment.