Skip to content

Commit

Permalink
Minor fixes for Python 2/3 compatibility.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 230022543
  • Loading branch information
schien1729 authored and tensorflower-gardener committed Jan 19, 2019
1 parent 0b56f7c commit 7e2d796
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
8 changes: 2 additions & 6 deletions privacy/analysis/rdp_accountant.py
Expand Up @@ -45,11 +45,7 @@

import numpy as np
from scipy import special

try:
long
except NameError:
long = int
import six

########################
# LOG-SPACE ARITHMETIC #
Expand Down Expand Up @@ -91,7 +87,7 @@ def _log_print(logx):

def _compute_log_a_int(q, sigma, alpha):
"""Compute log(A_alpha) for integer alpha. 0 < q < 1."""
assert isinstance(alpha, (int, long))
assert isinstance(alpha, six.integer_types)

# Initialize with 0 in the log space.
log_a = -np.inf
Expand Down
7 changes: 1 addition & 6 deletions privacy/optimizers/gaussian_query_test.py
Expand Up @@ -24,11 +24,6 @@

from privacy.optimizers import gaussian_query

try:
xrange
except NameError:
xrange = range


def _run_query(query, records):
"""Executes query on the given set of records as a single sample.
Expand Down Expand Up @@ -114,7 +109,7 @@ def test_gaussian_average_with_noise(self):
query_result = _run_query(query, [record1, record2])

noised_averages = []
for _ in xrange(1000):
for _ in range(1000):
noised_averages.append(sess.run(query_result))

result_stddev = np.std(noised_averages)
Expand Down
7 changes: 1 addition & 6 deletions privacy/optimizers/nested_query_test.py
Expand Up @@ -30,11 +30,6 @@

_basic_query = gaussian_query.GaussianSumQuery(1.0, 0.0)

try:
xrange
except NameError:
xrange = range


def _run_query(query, records):
"""Executes query on the given set of records as a single sample.
Expand Down Expand Up @@ -145,7 +140,7 @@ def test_nested_query_with_noise(self):
query_result = _run_query(query, [record1, record2])

noised_averages = []
for _ in xrange(1000):
for _ in range(1000):
noised_averages.append(nest.flatten(sess.run(query_result)))

result_stddev = np.std(noised_averages, 0)
Expand Down

0 comments on commit 7e2d796

Please sign in to comment.