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

Skip to content

Commit 85c9742

Browse files
authored
Merge pull request #12316 from QuLogic/travis-warnings
Fix some warnings from Travis
2 parents c15a2b8 + d82d0f7 commit 85c9742

12 files changed

+66
-37
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def post_processing(image, dpi):
356356
self._update_methods()
357357

358358
if w > 0 and h > 0:
359-
img = np.fromstring(buffer, np.uint8)
359+
img = np.frombuffer(buffer, np.uint8)
360360
img, ox, oy = post_processing(img.reshape((h, w, 4)) / 255.,
361361
self.dpi)
362362
gc = self.new_gc()

lib/matplotlib/dates.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,10 +1348,9 @@ def get_locator(self, dmin, dmax):
13481348
else:
13491349
locator = MicrosecondLocator(interval, tz=self.tz)
13501350
if dmin.year > 20 and interval < 1000:
1351-
_log.warn('Plotting microsecond time intervals is not'
1352-
' well supported. Please see the'
1353-
' MicrosecondLocator documentation'
1354-
' for details.')
1351+
_log.warning('Plotting microsecond time intervals is not well '
1352+
'supported. Please see the MicrosecondLocator '
1353+
'documentation for details.')
13551354

13561355
locator.set_axis(self.axis)
13571356

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,9 +1460,9 @@ def pil_to_array(pilImage):
14601460
# return MxN luminance array of uint16
14611461
raw = pilImage.tobytes('raw', pilImage.mode)
14621462
if pilImage.mode.endswith('B'):
1463-
x = np.fromstring(raw, '>u2')
1463+
x = np.frombuffer(raw, '>u2')
14641464
else:
1465-
x = np.fromstring(raw, '<u2')
1465+
x = np.frombuffer(raw, '<u2')
14661466
return x.reshape(pilImage.size[::-1]).astype('=u2')
14671467
else: # try to convert to an rgba image
14681468
try:

lib/matplotlib/testing/decorators.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,25 @@ def _xfail_if_format_is_uncomparable(extension):
158158

159159
def _mark_xfail_if_format_is_uncomparable(extension):
160160
if isinstance(extension, str):
161-
will_fail = extension not in comparable_formats()
161+
name = extension
162+
marks = []
163+
elif isinstance(extension, tuple):
164+
# Extension might be a pytest ParameterSet instead of a plain string.
165+
# Unfortunately, this type is not exposed, so since it's a namedtuple,
166+
# check for a tuple instead.
167+
name = extension.values[0]
168+
marks = list(extension.marks)
162169
else:
163170
# Extension might be a pytest marker instead of a plain string.
164-
will_fail = extension.args[0] not in comparable_formats()
165-
if will_fail:
166-
fail_msg = 'Cannot compare %s files on this system' % extension
171+
name = extension.args[0]
172+
marks = [extension.mark]
173+
174+
if name not in comparable_formats():
175+
fail_msg = 'Cannot compare %s files on this system' % (name, )
167176
import pytest
168-
return pytest.mark.xfail(extension, reason=fail_msg, strict=False,
169-
raises=ImageComparisonFailure)
177+
marks += [pytest.mark.xfail(reason=fail_msg, strict=False,
178+
raises=ImageComparisonFailure)]
179+
return pytest.param(name, marks=marks)
170180
else:
171181
return extension
172182

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import sys
44
import tempfile
5+
import warnings
56

67
import numpy as np
78
import pytest
@@ -14,9 +15,11 @@
1415
_determinism_check)
1516

1617

17-
needs_usetex = pytest.mark.skipif(
18-
not checkdep_usetex(True),
19-
reason="This test needs a TeX installation")
18+
with warnings.catch_warnings():
19+
warnings.simplefilter('ignore')
20+
needs_usetex = pytest.mark.skipif(
21+
not checkdep_usetex(True),
22+
reason="This test needs a TeX installation")
2023

2124

2225
@image_comparison(baseline_images=['pdf_use14corefonts'],

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44
import re
55
import tempfile
6+
import warnings
67

78
import pytest
89

@@ -14,12 +15,14 @@
1415
_determinism_check)
1516

1617

17-
needs_ghostscript = pytest.mark.skipif(
18-
matplotlib.checkdep_ghostscript()[0] is None,
19-
reason="This test needs a ghostscript installation")
20-
needs_usetex = pytest.mark.skipif(
21-
not matplotlib.checkdep_usetex(True),
22-
reason="This test needs a TeX installation")
18+
with warnings.catch_warnings():
19+
warnings.simplefilter('ignore')
20+
needs_ghostscript = pytest.mark.skipif(
21+
matplotlib.checkdep_ghostscript()[0] is None,
22+
reason="This test needs a ghostscript installation")
23+
needs_usetex = pytest.mark.skipif(
24+
not matplotlib.checkdep_usetex(True),
25+
reason="This test needs a TeX installation")
2326

2427

2528
# This tests tends to hit a TeX cache lock on AppVeyor.

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from io import BytesIO
33
import os
44
import tempfile
5+
import warnings
56
import xml.parsers.expat
67

78
import pytest
@@ -12,9 +13,11 @@
1213
from matplotlib import dviread
1314

1415

15-
needs_usetex = pytest.mark.skipif(
16-
not matplotlib.checkdep_usetex(True),
17-
reason="This test needs a TeX installation")
16+
with warnings.catch_warnings():
17+
warnings.simplefilter('ignore')
18+
needs_usetex = pytest.mark.skipif(
19+
not matplotlib.checkdep_usetex(True),
20+
reason="This test needs a TeX installation")
1821

1922

2023
def test_visibility():

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def test_single_minus_sign():
267267

268268
buff = io.BytesIO()
269269
plt.savefig(buff, format="rgba", dpi=1000)
270-
array = np.fromstring(buff.getvalue(), dtype=np.uint8)
270+
array = np.frombuffer(buff.getvalue(), dtype=np.uint8)
271271

272272
# If this fails, it would be all white
273273
assert not np.all(array == 0xff)

lib/matplotlib/tests/test_simplification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def test_start_with_moveto():
264264
AABHqP//ej8AAD6z//+FPwAANb7//48/AAAsyf//lz8AACPU//+ePwAAGt///6M/AAAR6v//pj8A
265265
AAj1//+nPwAA/////w=="""
266266

267-
verts = np.fromstring(base64.decodebytes(data), dtype='<i4')
267+
verts = np.frombuffer(base64.decodebytes(data), dtype='<i4')
268268
verts = verts.reshape((len(verts) // 2, 2))
269269
path = Path(verts)
270270
segs = path.iter_segments(transforms.IdentityTransform(),

lib/matplotlib/tests/test_text.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
from matplotlib.testing.decorators import image_comparison
1212

1313

14-
needs_usetex = pytest.mark.skipif(
15-
not matplotlib.checkdep_usetex(True),
16-
reason="This test needs a TeX installation")
14+
with warnings.catch_warnings():
15+
warnings.simplefilter('ignore')
16+
needs_usetex = pytest.mark.skipif(
17+
not matplotlib.checkdep_usetex(True),
18+
reason="This test needs a TeX installation")
1719

1820

1921
@image_comparison(baseline_images=['font_styles'])
@@ -134,8 +136,8 @@ def test_multiline2():
134136
ax.set_xlim([0, 1.4])
135137
ax.set_ylim([0, 2])
136138
ax.axhline(0.5, color='C2', linewidth=0.3)
137-
sts = ['Line', '2 Lineg\n 2 Lg', '$\sum_i x $', 'hi $\sum_i x $\ntest',
138-
'test\n $\sum_i x $', '$\sum_i x $\n $\sum_i x $']
139+
sts = ['Line', '2 Lineg\n 2 Lg', '$\\sum_i x $', 'hi $\\sum_i x $\ntest',
140+
'test\n $\\sum_i x $', '$\\sum_i x $\n $\\sum_i x $']
139141
renderer = fig.canvas.get_renderer()
140142

141143
def draw_box(ax, tt):

lib/matplotlib/tests/test_usetex.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
import warnings
2+
13
import pytest
24

35
import matplotlib
46
from matplotlib.testing.decorators import image_comparison
57
import matplotlib.pyplot as plt
68

79

8-
@pytest.mark.skipif(not matplotlib.checkdep_usetex(True),
9-
reason='Missing TeX or Ghostscript or dvipng')
10+
with warnings.catch_warnings():
11+
warnings.simplefilter('ignore')
12+
needs_usetex = pytest.mark.skipif(
13+
not matplotlib.checkdep_usetex(True),
14+
reason='Missing TeX of Ghostscript or dvipng')
15+
16+
17+
@needs_usetex
1018
@image_comparison(baseline_images=['test_usetex'],
1119
extensions=['pdf', 'png'],
1220
tol=0.3)

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ def test_lines3d():
133133

134134

135135
# Reason for flakiness of SVG test is still unknown.
136-
@image_comparison(baseline_images=['mixedsubplot'], remove_text=True,
137-
extensions=['png', 'pdf',
138-
pytest.mark.xfail('svg', strict=False)])
136+
@image_comparison(
137+
baseline_images=['mixedsubplot'], remove_text=True,
138+
extensions=['png', 'pdf',
139+
pytest.param('svg', marks=pytest.mark.xfail(strict=False))])
139140
def test_mixedsubplots():
140141
def f(t):
141142
s1 = np.cos(2*np.pi*t)

0 commit comments

Comments
 (0)