Convert six.moves.xrange() to range() for Python 3#10525
Merged
dstansby merged 1 commit intomatplotlib:masterfrom Feb 21, 2018
Merged
Convert six.moves.xrange() to range() for Python 3#10525dstansby merged 1 commit intomatplotlib:masterfrom
dstansby merged 1 commit intomatplotlib:masterfrom
Conversation
8b9f2e7 to
f73b62c
Compare
jklymak
approved these changes
Feb 19, 2018
Member
jklymak
left a comment
There was a problem hiding this comment.
Thanks this seems fine. I assume you did a grep for all instances of xrange...
Member
|
See #10526 for the solution to the problem with |
anntzer
reviewed
Feb 19, 2018
lib/matplotlib/cbook/__init__.py
Outdated
| 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))): |
Contributor
There was a problem hiding this comment.
these functions should just be deleted as they have been deprecated since 2.1
anntzer
reviewed
Feb 19, 2018
lib/matplotlib/cbook/__init__.py
Outdated
| return True | ||
| val = seq[0] | ||
| for i in xrange(1, len(seq)): | ||
| for i in range(1, len(seq)): |
anntzer
reviewed
Feb 19, 2018
lib/matplotlib/colorbar.py
Outdated
| 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)] |
Contributor
There was a problem hiding this comment.
probably better written using np.stack or a variant of it
anntzer
reviewed
Feb 19, 2018
lib/matplotlib/mathtext.py
Outdated
| # 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): |
Contributor
There was a problem hiding this comment.
already refactored in the py3mathtext PR
anntzer
reviewed
Feb 19, 2018
| for i, code_piece in enumerate(code_pieces): | ||
| images = [] | ||
| for j in xrange(1000): | ||
| for j in range(1000): |
Contributor
There was a problem hiding this comment.
probably should be itertools.count()...
anntzer
reviewed
Feb 19, 2018
| # 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)] |
dec88cf to
8cf8798
Compare
8cf8798 to
b64e2d1
Compare
efiring
approved these changes
Feb 19, 2018
dstansby
approved these changes
Feb 21, 2018
This was referenced Feb 21, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
As part of dropping support for Python 2, we can simplify the code by: