Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pydp/algorithms/laplacian/_count.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
from .._algorithm import MetaAlgorithm

from typing import Union


class Count(MetaAlgorithm):
"""
Count Explanation
TODO
"""

def __init__(self, epsilon: float = 1.0, dtype: str = "int"):
super().__init__(epsilon=epsilon, dtype=dtype)
def __init__(
self,
epsilon: float = 1.0,
l0_sensitivity: int = 1,
linf_sensitivity: int = 1,
dtype: str = "int",
):
super().__init__(
epsilon=epsilon,
l0_sensitivity=l0_sensitivity,
linf_sensitivity=linf_sensitivity,
dtype=dtype,
)
15 changes: 15 additions & 0 deletions tests/algorithms/test_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ def test_count_datatypes(self):
assert isinstance(res, int)


@pytest.mark.parametrize("dtype_in", ["int", "float"])
class TestCount:
def test_basic(self, dtype_in):
n = 100
c = [1 for _ in range(100)]
count = Count(epsilon=1, dtype=dtype_in)
assert n - 10 < count.quick_result(c) < n + 10

def test_l0_linf(self, dtype_in):
n = 100
c = [1 for _ in range(100)]
count = Count(epsilon=1, l0_sensitivity=1, linf_sensitivity=1, dtype=dtype_in)
assert n - 10 < count.quick_result(c) < n + 10


# TODO: port the following tests
#
# TEST(CountTest, MergeTest)
Expand Down