Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e46a9d

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
Conflicts: lib/matplotlib/units.py Restored six import on master
2 parents 6e43e72 + aeed94b commit 0e46a9d

File tree

14 files changed

+100
-14
lines changed

14 files changed

+100
-14
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ script:
175175
fi
176176
else
177177
cd doc
178-
python make.py html
178+
python make.py html -n 2
179179
# We don't build the LaTeX docs here, so linkchecker will complain
180180
touch build/html/Matplotlib.pdf
181181
# Linkchecker only works with python 2.7 for the time being

doc/make.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def html(buildername='html'):
5252
options = ''
5353
if warnings_as_errors:
5454
options = options + ' -W'
55-
if os.system('sphinx-build %s -b %s -d build/doctrees . build/%s' % (options, buildername, buildername)):
55+
if os.system('sphinx-build -j %d %s -b %s -d build/doctrees . build/%s' % (
56+
n_proc, options, buildername, buildername)):
5657
raise SystemExit("Building HTML failed.")
5758

5859
# Clean out PDF files from the _images directory
@@ -67,7 +68,7 @@ def htmlhelp():
6768
with open('build/htmlhelp/index.html', 'r+') as fh:
6869
content = fh.read()
6970
fh.seek(0)
70-
content = re.sub(r'<script>.*?</script>', '', content,
71+
content = re.sub(r'<script>.*?</script>', '', content,
7172
flags=re.MULTILINE| re.DOTALL)
7273
fh.write(content)
7374
fh.truncate()
@@ -146,6 +147,7 @@ def all():
146147

147148
small_docs = False
148149
warnings_as_errors = True
150+
n_proc = 1
149151

150152
# Change directory to the one containing this file
151153
current_dir = os.getcwd()
@@ -195,11 +197,16 @@ def all():
195197
parser.add_argument("--allowsphinxwarnings",
196198
help="Don't turn Sphinx warnings into errors",
197199
action="store_true")
200+
parser.add_argument("-n",
201+
help="Number of parallel workers to use")
202+
198203
args = parser.parse_args()
199204
if args.small:
200205
small_docs = True
201206
if args.allowsphinxwarnings:
202207
warnings_as_errors = False
208+
if args.n is not None:
209+
n_proc = int(args.n)
203210

204211
if args.cmd:
205212
for command in args.cmd:

doc/sphinxext/gen_gallery.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,6 @@ def setup(app):
168168
app.add_config_value('mpl_example_sections', [], True)
169169
except sphinx.errors.ExtensionError:
170170
pass # mpl_example_sections already defined
171+
172+
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
173+
return metadata

doc/sphinxext/gen_rst.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,6 @@ def setup(app):
169169
app.add_config_value('mpl_example_sections', [], True)
170170
except sphinx.errors.ExtensionError:
171171
pass # mpl_example_sections already defined
172+
173+
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
174+
return metadata

doc/sphinxext/github.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
143143

144144
def setup(app):
145145
"""Install the plugin.
146-
146+
147147
:param app: Sphinx application context.
148148
"""
149149
app.info('Initializing GitHub plugin')
@@ -152,4 +152,6 @@ def setup(app):
152152
app.add_role('ghuser', ghuser_role)
153153
app.add_role('ghcommit', ghcommit_role)
154154
app.add_config_value('github_project_url', None, 'env')
155-
return
155+
156+
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
157+
return metadata

doc/sphinxext/math_symbol_table.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ def setup(app):
138138
'math_symbol_table', math_symbol_table_directive,
139139
False, (0, 1, 0))
140140

141+
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
142+
return metadata
143+
141144
if __name__ == "__main__":
142145
# Do some verification of the tables
143146
from matplotlib import _mathtext_data

lib/matplotlib/backends/backend_agg.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,44 @@ def get_renderer(self, cleared=False):
480480
return self.renderer
481481

482482
def tostring_rgb(self):
483+
'''Get the image as an RGB byte string
484+
485+
`draw` must be called at least once before this function will work and
486+
to update the renderer for any subsequent changes to the Figure.
487+
488+
Returns
489+
-------
490+
bytes
491+
'''
483492
if __debug__: verbose.report('FigureCanvasAgg.tostring_rgb',
484493
'debug-annoying')
485494
return self.renderer.tostring_rgb()
486495

487496
def tostring_argb(self):
497+
'''Get the image as an ARGB byte string
498+
499+
`draw` must be called at least once before this function will work and
500+
to update the renderer for any subsequent changes to the Figure.
501+
502+
Returns
503+
-------
504+
bytes
505+
506+
'''
488507
if __debug__: verbose.report('FigureCanvasAgg.tostring_argb',
489508
'debug-annoying')
490509
return self.renderer.tostring_argb()
491510

492511
def buffer_rgba(self):
512+
'''Get the image as an RGBA byte string
513+
514+
`draw` must be called at least once before this function will work and
515+
to update the renderer for any subsequent changes to the Figure.
516+
517+
Returns
518+
-------
519+
bytes
520+
'''
493521
if __debug__: verbose.report('FigureCanvasAgg.buffer_rgba',
494522
'debug-annoying')
495523
return self.renderer.buffer_rgba()

lib/matplotlib/cbook.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,15 @@ def index_of(y):
24862486

24872487
def safe_first_element(obj):
24882488
if isinstance(obj, collections.Iterator):
2489+
# needed to accept `array.flat` as input.
2490+
# np.flatiter reports as an instance of collections.Iterator
2491+
# but can still be indexed via [].
2492+
# This has the side effect of re-setting the iterator, but
2493+
# that is acceptable.
2494+
try:
2495+
return obj[0]
2496+
except TypeError:
2497+
pass
24892498
raise RuntimeError("matplotlib does not support generators "
24902499
"as input")
24912500
return next(iter(obj))

lib/matplotlib/sphinxext/mathmpl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,6 @@ def depart_latex_math_latex(self, node):
118118
app.add_role('math', math_role)
119119
app.add_directive('math', math_directive,
120120
True, (0, 0, 0), **options_spec)
121+
122+
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
123+
return metadata

lib/matplotlib/sphinxext/only_directives.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ def visit_ignore(self, node):
6464
def depart_ignore(self, node):
6565
node.children = []
6666

67-
app.add_node(html_only,
68-
html=(visit_perform, depart_perform),
69-
latex=(visit_ignore, depart_ignore))
70-
app.add_node(latex_only,
71-
latex=(visit_perform, depart_perform),
72-
html=(visit_ignore, depart_ignore))
67+
app.add_node(html_only, html=(visit_perform, depart_perform))
68+
app.add_node(html_only, latex=(visit_ignore, depart_ignore))
69+
app.add_node(latex_only, latex=(visit_perform, depart_perform))
70+
app.add_node(latex_only, html=(visit_ignore, depart_ignore))
71+
72+
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
73+
return metadata

lib/matplotlib/tests/test_cbook.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,15 @@ class dummy():
511511
base_set = mapping[ref(objs[0])]
512512
for o in objs[1:]:
513513
assert mapping[ref(o)] is base_set
514+
515+
516+
def test_flatiter():
517+
x = np.arange(5)
518+
it = x.flat
519+
assert 0 == next(it)
520+
assert 1 == next(it)
521+
ret = cbook.safe_first_element(it)
522+
assert ret == 0
523+
524+
assert 0 == next(it)
525+
assert 1 == next(it)

lib/matplotlib/units.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def default_units(x, axis):
4444
from __future__ import (absolute_import, division, print_function,
4545
unicode_literals)
4646

47+
48+
import six
4749
from matplotlib.cbook import iterable, is_numlike, safe_first_element
4850
import numpy as np
4951

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,9 +2449,9 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None,
24492449

24502450
facecolors = []
24512451
if color is None:
2452-
# no color specified
2453-
facecolors = [None] * len(x)
2454-
elif len(color) == len(x):
2452+
color = [self._get_lines.get_next_color()]
2453+
2454+
if len(color) == len(x):
24552455
# bar colors specified, need to expand to number of faces
24562456
for c in color:
24572457
facecolors.extend([c] * 6)

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ def test_bar3d():
2020
ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)
2121

2222

23+
@cleanup
24+
def test_bar3d_dflt_smoke():
25+
fig = plt.figure()
26+
ax = fig.add_subplot(111, projection='3d')
27+
x = np.arange(4)
28+
y = np.arange(5)
29+
x2d, y2d = np.meshgrid(x, y)
30+
x2d, y2d = x2d.ravel(), y2d.ravel()
31+
z = x2d + y2d
32+
ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z)
33+
fig.canvas.draw()
34+
35+
2336
@image_comparison(baseline_images=['contour3d'], remove_text=True)
2437
def test_contour3d():
2538
fig = plt.figure()

0 commit comments

Comments
 (0)