Minor fixes for Python 2/3 compatibility.

PiperOrigin-RevId: 230022543
This commit is contained in:
Steve Chien 2019-01-18 17:33:00 -08:00 committed by A. Unique TensorFlower
parent 0b56f7c016
commit 7e2d796bde
3 changed files with 4 additions and 18 deletions

View file

@ -45,11 +45,7 @@ import sys
import numpy as np
from scipy import special
try:
long
except NameError:
long = int
import six
########################
# LOG-SPACE ARITHMETIC #
@ -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

View file

@ -24,11 +24,6 @@ import tensorflow as tf
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.
@ -114,7 +109,7 @@ class GaussianQueryTest(tf.test.TestCase, parameterized.TestCase):
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)

View file

@ -30,11 +30,6 @@ nest = tf.contrib.framework.nest
_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.
@ -145,7 +140,7 @@ class NestedQueryTest(tf.test.TestCase, parameterized.TestCase):
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)