From 1fc7128da0269d6a8836e548f732848e37972fbe Mon Sep 17 00:00:00 2001 From: cclauss Date: Fri, 8 Mar 2019 10:33:26 +0100 Subject: [PATCH 1/3] from six.moves import xrange __xrange()__ was removed in Python 3 in favor of a reworked version of __range()__. [flake8](http://flake8.pycqa.org) testing of https://github.com/tensorflow/privacy on Python 3.7.1 $ __flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics__ ``` ./privacy/optimizers/gaussian_query_test.py:65:16: F821 undefined name 'xrange' for _ in xrange(1000): ^ ./research/pate_2018/ICLR2018/rdp_bucketized.py:79:12: F821 undefined name 'xrange' for i in xrange(n): ^ ./research/pate_2018/ICLR2018/rdp_bucketized.py:106:12: F821 undefined name 'xrange' for i in xrange(n): ^ ./research/pate_2018/ICLR2018/rdp_bucketized.py:139:12: F821 undefined name 'xrange' for i in xrange(n): ^ 4 F821 undefined name 'xrange' 4 ``` __E901,E999,F821,F822,F823__ are the "_showstopper_" [flake8](http://flake8.pycqa.org) issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety. * F821: undefined name `name` * F822: undefined name `name` in `__all__` * F823: local variable name referenced before assignment * E901: SyntaxError or IndentationError * E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree --- research/pate_2018/ICLR2018/rdp_bucketized.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/research/pate_2018/ICLR2018/rdp_bucketized.py b/research/pate_2018/ICLR2018/rdp_bucketized.py index a5e7785..f84ace1 100644 --- a/research/pate_2018/ICLR2018/rdp_bucketized.py +++ b/research/pate_2018/ICLR2018/rdp_bucketized.py @@ -36,6 +36,8 @@ import math import os import sys +from six.moves import xrange + sys.path.append('..') # Main modules reside in the parent directory. from absl import app From d9780c043e9c577c8c7e5ad85fe9b83e4e535421 Mon Sep 17 00:00:00 2001 From: cclauss Date: Fri, 8 Mar 2019 10:35:01 +0100 Subject: [PATCH 2/3] from six.moves import xrange __xrange()__ was removed in Python 3 in favor of a reworked version of __range()__. [flake8](http://flake8.pycqa.org) testing of https://github.com/tensorflow/privacy on Python 3.7.1 $ __flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics__ ``` ./privacy/optimizers/gaussian_query_test.py:65:16: F821 undefined name 'xrange' for _ in xrange(1000): ^ ./research/pate_2018/ICLR2018/rdp_bucketized.py:79:12: F821 undefined name 'xrange' for i in xrange(n): ^ ./research/pate_2018/ICLR2018/rdp_bucketized.py:106:12: F821 undefined name 'xrange' for i in xrange(n): ^ ./research/pate_2018/ICLR2018/rdp_bucketized.py:139:12: F821 undefined name 'xrange' for i in xrange(n): ^ 4 F821 undefined name 'xrange' 4 ``` __E901,E999,F821,F822,F823__ are the "_showstopper_" [flake8](http://flake8.pycqa.org) issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety. * F821: undefined name `name` * F822: undefined name `name` in `__all__` * F823: local variable name referenced before assignment * E901: SyntaxError or IndentationError * E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree --- privacy/optimizers/gaussian_query_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/privacy/optimizers/gaussian_query_test.py b/privacy/optimizers/gaussian_query_test.py index 7b5be7f..b66a442 100644 --- a/privacy/optimizers/gaussian_query_test.py +++ b/privacy/optimizers/gaussian_query_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from absl.testing import parameterized import numpy as np +from six.moves import xrange import tensorflow as tf from privacy.optimizers import gaussian_query From be815437a60602886a3277057b32c90a0e5e774b Mon Sep 17 00:00:00 2001 From: Nicolas Papernot Date: Fri, 8 Mar 2019 09:47:15 -0800 Subject: [PATCH 3/3] reorder imports --- research/pate_2018/ICLR2018/rdp_bucketized.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/research/pate_2018/ICLR2018/rdp_bucketized.py b/research/pate_2018/ICLR2018/rdp_bucketized.py index f84ace1..8527b46 100644 --- a/research/pate_2018/ICLR2018/rdp_bucketized.py +++ b/research/pate_2018/ICLR2018/rdp_bucketized.py @@ -36,17 +36,16 @@ import math import os import sys -from six.moves import xrange - sys.path.append('..') # Main modules reside in the parent directory. from absl import app from absl import flags +import core as pate import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt # pylint: disable=g-import-not-at-top import numpy as np -import core as pate +from six.moves import xrange plt.style.use('ggplot')