Skip to content

Commit

Permalink
fix: assert variables approx conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariush Wahdany committed Jan 4, 2024
1 parent fcff128 commit e3bf740
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dp_learning_ff/mechanisms.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ def approxzCDP_to_approxDP(
delta: Optional[float] = None,
return_tuple: bool = False,
):
assert epsilon >= xi + rho, "epsilon must be >= xi + rho"
if epsilon is None and delta is None:
raise ValueError("Either epsilon or delta must be set")
if epsilon is not None and delta is not None:
raise ValueError("Only one of epsilon and delta must be set")
if delta is None:
assert epsilon >= xi + rho, "epsilon must be >= xi + rho"
excess_epsilon = epsilon - xi - rho
scaled_excess_epsilon = excess_epsilon / (2 * rho)
delta_excess = np.exp(-((excess_epsilon) ** 2) / (4 * rho)) * min(
Expand All @@ -125,6 +125,8 @@ def approxzCDP_to_approxDP(
if not return_tuple:
return delta
else:
assert delta <= 1, "delta must be <= 1"
assert delta > 0, "delta must be > 0"

def obj(x):
return approxzCDP_to_approxDP(
Expand Down

0 comments on commit e3bf740

Please sign in to comment.