From d72378f913280731fd569a7f004a600b6f6c9abe Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 24 Dec 2018 03:55:12 +0100 Subject: [PATCH] Fix Python 3 compatibility issues --- privacy/analysis/rdp_accountant.py | 5 +++++ privacy/optimizers/dp_optimizer_test.py | 5 +++++ privacy/optimizers/gaussian_query_test.py | 5 +++++ privacy/optimizers/nested_query_test.py | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/privacy/analysis/rdp_accountant.py b/privacy/analysis/rdp_accountant.py index 4910385..ebb0229 100644 --- a/privacy/analysis/rdp_accountant.py +++ b/privacy/analysis/rdp_accountant.py @@ -46,6 +46,11 @@ import sys import numpy as np from scipy import special +try: + long +except NameError: + long = int + ######################## # LOG-SPACE ARITHMETIC # ######################## diff --git a/privacy/optimizers/dp_optimizer_test.py b/privacy/optimizers/dp_optimizer_test.py index a5f24d2..fe8e461 100644 --- a/privacy/optimizers/dp_optimizer_test.py +++ b/privacy/optimizers/dp_optimizer_test.py @@ -24,6 +24,11 @@ import tensorflow as tf from privacy.optimizers import dp_optimizer +try: + xrange +except NameError: + xrange = range + def loss(val0, val1): """Loss function that is minimized at the mean of the input points.""" diff --git a/privacy/optimizers/gaussian_query_test.py b/privacy/optimizers/gaussian_query_test.py index 43c9085..37b8789 100644 --- a/privacy/optimizers/gaussian_query_test.py +++ b/privacy/optimizers/gaussian_query_test.py @@ -24,6 +24,11 @@ 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. diff --git a/privacy/optimizers/nested_query_test.py b/privacy/optimizers/nested_query_test.py index 134dbb2..add2fe1 100644 --- a/privacy/optimizers/nested_query_test.py +++ b/privacy/optimizers/nested_query_test.py @@ -30,6 +30,11 @@ 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.