-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Convert six.moves.xrange() to range() for Python 3 #10525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8b9f2e7
to
f73b62c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks this seems fine. I assume you did a grep for all instances of xrange...
See #10526 for the solution to the problem with |
lib/matplotlib/cbook/__init__.py
Outdated
@@ -941,7 +941,7 @@ def get_split_ind(seq, N): | |||
|
|||
s_len = 0 | |||
# todo: use Alex's xrange pattern from the cbook for efficiency | |||
for (word, ind) in zip(seq, xrange(len(seq))): | |||
for (word, ind) in zip(seq, range(len(seq))): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these functions should just be deleted as they have been deprecated since 2.1
lib/matplotlib/cbook/__init__.py
Outdated
@@ -1098,7 +1098,7 @@ def allequal(seq): | |||
if len(seq) < 2: | |||
return True | |||
val = seq[0] | |||
for i in xrange(1, len(seq)): | |||
for i in range(1, len(seq)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
lib/matplotlib/colorbar.py
Outdated
@@ -561,9 +561,9 @@ def add_lines(self, levels, colors, linewidths, erase=True): | |||
x = np.array([0.0, 1.0]) | |||
X, Y = np.meshgrid(x, y) | |||
if self.orientation == 'vertical': | |||
xy = [list(zip(X[i], Y[i])) for i in xrange(N)] | |||
xy = [list(zip(X[i], Y[i])) for i in range(N)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better written using np.stack or a variant of it
lib/matplotlib/mathtext.py
Outdated
@@ -2641,7 +2641,7 @@ def symbol(self, s, loc, toks): | |||
if c in self._spaced_symbols: | |||
# iterate until we find previous character, needed for cases | |||
# such as ${ -2}$, $ -2$, or $ -2$. | |||
for i in six.moves.xrange(1, loc + 1): | |||
for i in range(1, loc + 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already refactored in the py3mathtext PR
@@ -597,7 +596,7 @@ def render_figures(code, code_path, output_dir, output_base, context, | |||
all_exists = True | |||
for i, code_piece in enumerate(code_pieces): | |||
images = [] | |||
for j in xrange(1000): | |||
for j in range(1000): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably should be itertools.count()...
@@ -529,9 +529,9 @@ def _edges(self, X, Y): | |||
# Using the non-array form of these line segments is much | |||
# simpler than making them into arrays. | |||
if self.orientation == 'vertical': | |||
return [list(zip(X[i], Y[i])) for i in xrange(1, N-1)] | |||
return [list(zip(X[i], Y[i])) for i in range(1, N-1)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above re np.stack
dec88cf
to
8cf8798
Compare
8cf8798
to
b64e2d1
Compare
PR Summary
As part of dropping support for Python 2, we can simplify the code by: