From 443653a60a584da8366a33923e65e44b575eb3dc Mon Sep 17 00:00:00 2001 From: Derek Tropf Date: Wed, 21 Feb 2018 13:07:49 -0500 Subject: [PATCH 1/3] Convert six.moves.xrange() to range for Python 3 Remove import of xrange() and convert xrange() to range() --- lib/matplotlib/cbook/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 423319df6d43..68f9e10b4c27 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -10,7 +10,7 @@ unicode_literals) import six -from six.moves import xrange, zip +from six.moves import zip from itertools import repeat import collections import datetime @@ -900,7 +900,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))): s_len += len(word) + 1 # +1 to account for the len(' ') if s_len >= N: return ind From d4700d00772891725603f8ee97023d62dc7ff502 Mon Sep 17 00:00:00 2001 From: Derek Tropf Date: Wed, 21 Feb 2018 13:25:12 -0500 Subject: [PATCH 2/3] Convert xrange() to itertools.count() Import itertools and use itertools.count() to convert xrange() for Python3 --- lib/matplotlib/sphinxext/plot_directive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/sphinxext/plot_directive.py b/lib/matplotlib/sphinxext/plot_directive.py index 89e46b04fdd7..3301c4b1bd15 100644 --- a/lib/matplotlib/sphinxext/plot_directive.py +++ b/lib/matplotlib/sphinxext/plot_directive.py @@ -136,7 +136,7 @@ import six from six.moves import xrange -import sys, os, shutil, io, re, textwrap +import sys, os, shutil, io, re, textwrap, itertools from os.path import relpath import traceback import warnings @@ -597,7 +597,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 itertools.count(0): if len(code_pieces) > 1: img = ImageFile('%s_%02d_%02d' % (output_base, i, j), output_dir) else: From 4299bc3eb85add70bb1789bc5fcd7d3e20e28d9c Mon Sep 17 00:00:00 2001 From: Derek Tropf Date: Wed, 21 Feb 2018 13:26:16 -0500 Subject: [PATCH 3/3] Remove six.moves.xrange() import for Python3 --- lib/matplotlib/sphinxext/plot_directive.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/sphinxext/plot_directive.py b/lib/matplotlib/sphinxext/plot_directive.py index 3301c4b1bd15..b7f36409d516 100644 --- a/lib/matplotlib/sphinxext/plot_directive.py +++ b/lib/matplotlib/sphinxext/plot_directive.py @@ -134,7 +134,6 @@ unicode_literals) import six -from six.moves import xrange import sys, os, shutil, io, re, textwrap, itertools from os.path import relpath