Skip to content

Commit

Permalink
Merge pull request #423 from dvadym/fix_formatting
Browse files Browse the repository at this point in the history
Fix formatting
  • Loading branch information
chinmayshah99 authored Jul 27, 2022
2 parents 37553f1 + 2824827 commit 25bbffc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
master_doc = "index"

# General information about the project.
project = u"PyDP"
copyright = u"2020, OpenMined"
author = u"OpenMined"
project = "PyDP"
copyright = "2020, OpenMined"
author = "OpenMined"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -262,7 +262,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "pydp", u"pydp Documentation", [author], 1)]
man_pages = [(master_doc, "pydp", "pydp Documentation", [author], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -277,7 +277,7 @@
(
master_doc,
"PyDP",
u"PyDP Documentation",
"PyDP Documentation",
author,
"OpenMined",
"TODO: One line description of project.",
Expand Down
2 changes: 1 addition & 1 deletion src/pydp/ml/mechanisms/geometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_variance(self, value):
return (
2
* leading_factor
* (geom_series + 3 * (geom_series ** 2) + 2 * (geom_series ** 3))
* (geom_series + 3 * (geom_series**2) + 2 * (geom_series**3))
)

def randomise(self, value):
Expand Down
12 changes: 6 additions & 6 deletions src/pydp/ml/mechanisms/laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ def get_variance(self, value):

shape = self._sensitivity / self._epsilon

variance = value ** 2 + shape * (
variance = value**2 + shape * (
self._lower_bound * np.exp((self._lower_bound - value) / shape)
- self._upper_bound * np.exp((value - self._upper_bound) / shape)
)
variance += (shape ** 2) * (
variance += (shape**2) * (
2
- np.exp((self._lower_bound - value) / shape)
- np.exp((value - self._upper_bound) / shape)
Expand Down Expand Up @@ -373,17 +373,17 @@ def get_variance(self, value):
if self._scale is None:
self._scale = self._find_scale()

variance = value ** 2
variance = value**2
variance -= (
np.exp((self._lower_bound - value) / self._scale) * (self._lower_bound ** 2)
np.exp((self._lower_bound - value) / self._scale) * (self._lower_bound**2)
+ np.exp((value - self._upper_bound) / self._scale)
* (self._upper_bound ** 2)
* (self._upper_bound**2)
) / 2
variance += self._scale * (
self._lower_bound * np.exp((self._lower_bound - value) / self._scale)
- self._upper_bound * np.exp((value - self._upper_bound) / self._scale)
)
variance += (self._scale ** 2) * (
variance += (self._scale**2) * (
2
- np.exp((self._lower_bound - value) / self._scale)
- np.exp((value - self._upper_bound) / self._scale)
Expand Down
2 changes: 1 addition & 1 deletion src/pydp/ml/util/accountant.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def total(self, spent_budget=None, slack=None):
for epsilon, _ in spent_budget:
epsilon_sum += epsilon
epsilon_exp_sum += (1 - np.exp(-epsilon)) * epsilon / (1 + np.exp(-epsilon))
epsilon_sq_sum += epsilon ** 2
epsilon_sq_sum += epsilon**2

total_epsilon_naive = epsilon_sum
total_delta = self.__total_delta_safe(spent_budget, slack)
Expand Down
2 changes: 1 addition & 1 deletion tests/algorithms/test_numerical_mechanisms.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_gaussian_mechanism():
priv_budg * epsilon, priv_budg * delta, l2_sensitivity
)
assert type(interval) is num_mech.ConfidenceInterval
bound = erfinv(-conf_level) * local_gaussian.std * (2 ** 0.5)
bound = erfinv(-conf_level) * local_gaussian.std * (2**0.5)
lower_bound, upper_bound = value - bound, value + bound
assert_almost_eq(lower_bound, interval.lower_bound)
assert_almost_eq(upper_bound, interval.upper_bound)
Expand Down

0 comments on commit 25bbffc

Please sign in to comment.