-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
| 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
| 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
| 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
| # 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
| 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()...
| # 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: