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

Skip to content

Commit a08fb44

Browse files
committed
Merge remote-tracking branch 'refs/remotes/matplotlib/master'
2 parents 2a4863c + 600464d commit a08fb44

21 files changed

+442
-44
lines changed

appveyor.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ test_script:
8888
# Now build the thing..
8989
- '%CMD_IN_ENV% python setup.py develop'
9090
# tests
91-
# for now, just let them pass to get the after_test parts...
92-
- python tests.py || cmd /c "exit /b 0"
91+
- python tests.py
92+
- python visual_tests.py
9393

9494
after_test:
9595
# After the tests were a success, build packages (wheels and conda)
@@ -126,6 +126,7 @@ artifacts:
126126
type: zip
127127

128128
on_failure:
129+
- python visual_tests.py
129130
- echo zipping images after a failure...
130-
- 7z a result_images.zip result_images\ >NUL:
131+
- 7z a result_images.zip result_images\ |grep -v "Compressing"
131132
- appveyor PushArtifact result_images.zip

doc/_templates/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ <h4>Need help?</h4>
151151

152152
<p>To keep up to date with what's going on in matplotlib, see
153153
the <a href="{{ pathto('users/whats_new.html', 1) }}">what's new
154-
page</a>, the more detailed <a href="{{ pathto('_static/CHANGELOG', 1)
155-
}}">changelog</a> or browse
156-
the <a href="https://github.com/matplotlib/matplotlib">source
154+
page</a> or browse the <a href="https://github.com/matplotlib/matplotlib">source
157155
code</a>. Anything that could require changes to your existing code
158156
is logged in the <a href="{{ pathto('api/api_changes.html', 1) }}">api
159157
changes</a> file.</p>

lib/matplotlib/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ def checkdep_dvipng():
351351

352352
def checkdep_ghostscript():
353353
if sys.platform == 'win32':
354-
gs_execs = ['gswin32c', 'gswin64c', 'gs']
354+
# mgs is the name in miktex
355+
gs_execs = ['gswin32c', 'gswin64c', 'mgs', 'gs']
355356
else:
356357
gs_execs = ['gs']
357358
for gs_exec in gs_execs:
@@ -553,7 +554,13 @@ def _create_tmp_config_dir():
553554
# Some restricted platforms (such as Google App Engine) do not provide
554555
# gettempdir.
555556
return None
556-
tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
557+
558+
try:
559+
username = getpass.getuser()
560+
except KeyError:
561+
username = str(os.getuid())
562+
tempdir = os.path.join(tempdir, 'matplotlib-%s' % username)
563+
557564
os.environ['MPLCONFIGDIR'] = tempdir
558565

559566
mkdirs(tempdir)

lib/matplotlib/artist.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ def set_axes(self, axes):
214214
215215
ACCEPTS: an :class:`~matplotlib.axes.Axes` instance
216216
"""
217-
warnings.warn(_get_axes_msg, mplDeprecation, stacklevel=1)
217+
warnings.warn(_get_axes_msg.format('set_axes'), mplDeprecation,
218+
stacklevel=1)
218219
self.axes = axes
219220

220221
def get_axes(self):
@@ -225,7 +226,8 @@ def get_axes(self):
225226
This has been deprecated in mpl 1.5, please use the
226227
axes property. Will be removed in 1.7 or 2.0.
227228
"""
228-
warnings.warn(_get_axes_msg, mplDeprecation, stacklevel=1)
229+
warnings.warn(_get_axes_msg.format('get_axes'), mplDeprecation,
230+
stacklevel=1)
229231
return self.axes
230232

231233
@property
@@ -1581,5 +1583,5 @@ def kwdoc(a):
15811583

15821584
docstring.interpd.update(Artist=kwdoc(Artist))
15831585

1584-
_get_axes_msg = """This has been deprecated in mpl 1.5, please use the
1586+
_get_axes_msg = """{} has been deprecated in mpl 1.5, please use the
15851587
axes property. A removal date has not been set."""

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,16 +3147,16 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
31473147
If True produces boxes with the Patch artist
31483148
31493149
showmeans : bool, default = False
3150-
If True, will toggle one the rendering of the means
3150+
If True, will toggle on the rendering of the means
31513151
31523152
showcaps : bool, default = True
3153-
If True, will toggle one the rendering of the caps
3153+
If True, will toggle on the rendering of the caps
31543154
31553155
showbox : bool, default = True
3156-
If True, will toggle one the rendering of box
3156+
If True, will toggle on the rendering of the box
31573157
31583158
showfliers : bool, default = True
3159-
If True, will toggle one the rendering of the fliers
3159+
If True, will toggle on the rendering of the fliers
31603160
31613161
boxprops : dict or None (default)
31623162
If provided, will set the plotting style of the boxes
@@ -3412,16 +3412,16 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
34123412
If `True`, will produce a notched box plot
34133413
34143414
showmeans : bool, default = False
3415-
If `True`, will toggle one the rendering of the means
3415+
If `True`, will toggle on the rendering of the means
34163416
34173417
showcaps : bool, default = True
3418-
If `True`, will toggle one the rendering of the caps
3418+
If `True`, will toggle on the rendering of the caps
34193419
34203420
showbox : bool, default = True
3421-
If `True`, will toggle one the rendering of box
3421+
If `True`, will toggle on the rendering of the box
34223422
34233423
showfliers : bool, default = True
3424-
If `True`, will toggle one the rendering of the fliers
3424+
If `True`, will toggle on the rendering of the fliers
34253425
34263426
boxprops : dict or None (default)
34273427
If provided, will set the plotting style of the boxes

lib/matplotlib/backends/backend_ps.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,10 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
14521452
# multiple
14531453
if sys.platform == 'win32': precmd = '%s &&'% os.path.splitdrive(tmpdir)[0]
14541454
else: precmd = ''
1455+
#Replace \\ for / so latex does not think there is a function call
1456+
latexfile = latexfile.replace("\\", "/")
1457+
# Replace ~ so Latex does not think it is line break
1458+
latexfile = latexfile.replace("~", "\\string~")
14551459
command = '%s cd "%s" && latex -interaction=nonstopmode "%s" > "%s"'\
14561460
%(precmd, tmpdir, latexfile, outfile)
14571461
verbose.report(command, 'debug')
@@ -1530,8 +1534,13 @@ def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
15301534

15311535
with io.open(outfile, 'rb') as fh:
15321536
if exit_status:
1533-
raise RuntimeError('ghostscript was not able to process \
1534-
your image.\nHere is the full report generated by ghostscript:\n\n' + fh.read())
1537+
output = fh.read()
1538+
m = "\n".join(["ghostscript was not able to process your image.",
1539+
"Here is the full report generated by ghostscript:",
1540+
"",
1541+
"%s"])
1542+
# use % to prevent problems with bytes
1543+
raise RuntimeError(m % output)
15351544
else:
15361545
verbose.report(fh.read(), 'debug')
15371546
os.remove(outfile)

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,9 @@ def destroy(*args):
609609
self.window.update()
610610
else:
611611
self.canvas.draw_idle()
612+
# Raise the new window.
613+
self.canvas.manager.window.attributes('-topmost', 1)
614+
self.canvas.manager.window.attributes('-topmost', 0)
612615
self._shown = True
613616

614617
def destroy(self, *args):

lib/matplotlib/dviread.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,8 @@ def find_tex_file(filename, format=None):
961961
`--format` option.
962962
963963
Apparently most existing TeX distributions on Unix-like systems
964-
use kpathsea. I hear MikTeX (a popular distribution on Windows)
965-
doesn't use kpathsea, so what do we do? (TODO)
964+
use kpathsea. It's also available as part of MikTeX, a popular
965+
distribution on Windows.
966966
967967
.. seealso::
968968

lib/matplotlib/testing/compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ def convert(filename, cache):
166166
"""
167167
base, extension = filename.rsplit('.', 1)
168168
if extension not in converter:
169-
raise ImageComparisonFailure(
170-
"Don't know how to convert %s files to png" % extension)
169+
from nose import SkipTest
170+
raise SkipTest("Don't know how to convert %s files to png" % extension)
171171
newname = base + '_' + extension + '.png'
172172
if not os.path.exists(filename):
173173
raise IOError("'%s' does not exist" % filename)

lib/matplotlib/testing/decorators.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def image_comparison(baseline_images=None, extensions=None, tol=0,
290290
291291
Otherwise, a list of extensions to test. For example ['png','pdf'].
292292
293-
*tol*: (default 13)
293+
*tol*: (default 0)
294294
The RMS threshold above which the test is considered failed.
295295
296296
*freetype_version*: str or tuple
@@ -426,3 +426,24 @@ def backend_switcher(*args, **kwargs):
426426

427427
return nose.tools.make_decorator(func)(backend_switcher)
428428
return switch_backend_decorator
429+
430+
431+
def skip_if_command_unavailable(cmd):
432+
"""
433+
skips a test if a command is unavailable.
434+
435+
Parameters
436+
----------
437+
cmd : list of str
438+
must be a complete command which should not
439+
return a non zero exit code, something like
440+
["latex", "-version"]
441+
"""
442+
from matplotlib.compat.subprocess import check_output
443+
try:
444+
check_output(cmd)
445+
except:
446+
from nose import SkipTest
447+
raise SkipTest('missing command: %s' % cmd[0])
448+
449+
return lambda f: f
Binary file not shown.
Binary file not shown.

lib/matplotlib/tests/test_axes.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import warnings
2727
from matplotlib.cbook import IgnoredKeywordWarning
2828

29+
import sys
30+
on_win = (sys.platform == 'win32')
31+
2932
# Note: Some test cases are run twice: once normally and once with labeled data
3033
# These two must be defined in the same test function or need to have
3134
# different baseline images to prevent race conditions when nose runs
@@ -2749,7 +2752,8 @@ def test_subplot_key_hash():
27492752

27502753
@image_comparison(baseline_images=['specgram_freqs',
27512754
'specgram_freqs_linear'],
2752-
remove_text=True, extensions=['png'], tol=0.03)
2755+
remove_text=True, extensions=['png'],
2756+
tol=0.05 if on_win else 0.03)
27532757
def test_specgram_freqs():
27542758
'''test axes.specgram in default (psd) mode with sinusoidal stimuli'''
27552759
n = 10000
@@ -2849,7 +2853,8 @@ def test_specgram_noise():
28492853

28502854
@image_comparison(baseline_images=['specgram_magnitude_freqs',
28512855
'specgram_magnitude_freqs_linear'],
2852-
remove_text=True, extensions=['png'], tol=0.03)
2856+
remove_text=True, extensions=['png'],
2857+
tol=0.05 if on_win else 0.03)
28532858
def test_specgram_magnitude_freqs():
28542859
'''test axes.specgram in magnitude mode with sinusoidal stimuli'''
28552860
n = 10000
@@ -2950,7 +2955,8 @@ def test_specgram_magnitude_noise():
29502955

29512956

29522957
@image_comparison(baseline_images=['specgram_angle_freqs'],
2953-
remove_text=True, extensions=['png'])
2958+
remove_text=True, extensions=['png'],
2959+
tol=0.003 if on_win else 0)
29542960
def test_specgram_angle_freqs():
29552961
'''test axes.specgram in angle mode with sinusoidal stimuli'''
29562962
n = 10000

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def test_savefig_to_stringio_with_distiller():
7171

7272
@cleanup
7373
@needs_tex
74+
@needs_ghostscript
7475
def test_savefig_to_stringio_with_usetex():
7576
matplotlib.rcParams['text.latex.unicode'] = True
7677
matplotlib.rcParams['text.usetex'] = True
@@ -90,6 +91,7 @@ def test_savefig_to_stringio_eps_afm():
9091

9192
@cleanup
9293
@needs_tex
94+
@needs_ghostscript
9395
def test_savefig_to_stringio_with_usetex_eps():
9496
matplotlib.rcParams['text.latex.unicode'] = True
9597
matplotlib.rcParams['text.usetex'] = True
@@ -132,6 +134,46 @@ def test_patheffects():
132134
fig.savefig(ps, format='ps')
133135

134136

137+
@cleanup
138+
@needs_tex
139+
@needs_ghostscript
140+
def test_tilde_in_tempfilename():
141+
# Tilde ~ in the tempdir path (e.g. TMPDIR, TMP oder TEMP on windows
142+
# when the username is very long and windows uses a short name) breaks
143+
# latex before https://github.com/matplotlib/matplotlib/pull/5928
144+
import tempfile
145+
import shutil
146+
import os
147+
import os.path
148+
149+
tempdir = None
150+
old_tempdir = tempfile.tempdir
151+
try:
152+
# change the path for new tempdirs, which is used
153+
# internally by the ps backend to write a file
154+
tempdir = tempfile.mkdtemp()
155+
base_tempdir = os.path.join(tempdir, "short~1")
156+
os.makedirs(base_tempdir)
157+
tempfile.tempdir = base_tempdir
158+
159+
# usetex results in the latex call, which does not like the ~
160+
plt.rc('text', usetex=True)
161+
plt.plot([1, 2, 3, 4])
162+
plt.xlabel(r'\textbf{time} (s)')
163+
#matplotlib.verbose.set_level("debug")
164+
output_eps = os.path.join(base_tempdir, 'tex_demo.eps')
165+
# use the PS backend to write the file...
166+
plt.savefig(output_eps, format="ps")
167+
finally:
168+
tempfile.tempdir = old_tempdir
169+
if tempdir:
170+
try:
171+
shutil.rmtree(tempdir)
172+
except Exception as e:
173+
# do not break if this is not removeable...
174+
print(e)
175+
176+
135177
if __name__ == '__main__':
136178
import nose
137179
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_dviread.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
unicode_literals)
33

44
from matplotlib.externals import six
5+
from matplotlib.testing.decorators import skip_if_command_unavailable
6+
57

68
from nose.tools import assert_equal, with_setup
79
import matplotlib.dviread as dr
@@ -60,6 +62,7 @@ def test_PsfontsMap():
6062
assert_equal(entry.filename, '/absolute/font9.pfb')
6163

6264

65+
@skip_if_command_unavailable(["kpsewhich", "-version"])
6366
def test_dviread():
6467
dir = os.path.join(os.path.dirname(__file__), 'baseline_images', 'dviread')
6568
with open(os.path.join(dir, 'test.json')) as f:

lib/matplotlib/tests/test_patches.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
from matplotlib import path as mpath
2121
from matplotlib import transforms as mtrans
2222

23+
import sys
24+
on_win = (sys.platform == 'win32')
25+
2326

2427
def test_Polygon_close():
2528
#: Github issue #1018 identified a bug in the Polygon handling
@@ -250,7 +253,7 @@ def test_wedge_movement():
250253

251254

252255
@image_comparison(baseline_images=['wedge_range'],
253-
remove_text=True)
256+
remove_text=True, tol=0.06 if on_win else 0)
254257
def test_wedge_range():
255258
ax = plt.axes()
256259

lib/matplotlib/tests/test_patheffects.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import mock
1818
from nose.tools import assert_equal
1919

20+
import sys
21+
on_win = (sys.platform == 'win32')
22+
2023

2124
@image_comparison(baseline_images=['patheffect1'], remove_text=True)
2225
def test_patheffect1():
@@ -110,7 +113,7 @@ def test_SimplePatchShadow_offset():
110113
assert_equal(pe._offset, (4, 5))
111114

112115

113-
@image_comparison(baseline_images=['collection'])
116+
@image_comparison(baseline_images=['collection'], tol=0.013 if on_win else 0)
114117
def test_collection():
115118
x, y = np.meshgrid(np.linspace(0, 10, 150), np.linspace(-5, 5, 100))
116119
data = np.sin(x) + np.cos(y)

lib/matplotlib/tests/test_triangulation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import matplotlib.cm as cm
1515
from matplotlib.path import Path
1616

17+
import sys
18+
on_win = (sys.platform == 'win32')
1719

1820
def test_delaunay():
1921
# No duplicate points, regular grid.
@@ -770,7 +772,8 @@ def z(x, y):
770772

771773

772774
@image_comparison(baseline_images=['tri_smooth_gradient'],
773-
extensions=['png'], remove_text=True)
775+
extensions=['png'], remove_text=True,
776+
tol=0.015 if on_win else 0)
774777
def test_tri_smooth_gradient():
775778
# Image comparison based on example trigradient_demo.
776779

0 commit comments

Comments
 (0)