mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-08 22:45:43 +00:00
449 lines
18 KiB
Diff
449 lines
18 KiB
Diff
diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py
|
|
index aff6cddf492..491a9b2c5d6 100644
|
|
--- a/lib/matplotlib/backends/backend_agg.py
|
|
+++ b/lib/matplotlib/backends/backend_agg.py
|
|
@@ -391,7 +391,7 @@ def post_processing(image, dpi):
|
|
self._update_methods()
|
|
|
|
if w > 0 and h > 0:
|
|
- img = np.fromstring(buffer, np.uint8)
|
|
+ img = np.frombuffer(buffer, np.uint8)
|
|
img, ox, oy = post_processing(img.reshape((h, w, 4)) / 255.,
|
|
self.dpi)
|
|
gc = self.new_gc()
|
|
diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py
|
|
index 2712d64291a..290341146d8 100644
|
|
--- a/lib/matplotlib/dates.py
|
|
+++ b/lib/matplotlib/dates.py
|
|
@@ -1369,10 +1369,9 @@ def get_locator(self, dmin, dmax):
|
|
else:
|
|
locator = MicrosecondLocator(interval, tz=self.tz)
|
|
if dmin.year > 20 and interval < 1000:
|
|
- _log.warn('Plotting microsecond time intervals is not'
|
|
- ' well supported. Please see the'
|
|
- ' MicrosecondLocator documentation'
|
|
- ' for details.')
|
|
+ _log.warning('Plotting microsecond time intervals is not well '
|
|
+ 'supported. Please see the MicrosecondLocator '
|
|
+ 'documentation for details.')
|
|
|
|
locator.set_axis(self.axis)
|
|
|
|
diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py
|
|
index 58a28c8f689..3bdcccf4882 100644
|
|
--- a/lib/matplotlib/image.py
|
|
+++ b/lib/matplotlib/image.py
|
|
@@ -1447,9 +1447,9 @@ def pil_to_array(pilImage):
|
|
# return MxN luminance array of uint16
|
|
raw = pilImage.tobytes('raw', pilImage.mode)
|
|
if pilImage.mode.endswith('B'):
|
|
- x = np.fromstring(raw, '>u2')
|
|
+ x = np.frombuffer(raw, '>u2')
|
|
else:
|
|
- x = np.fromstring(raw, '<u2')
|
|
+ x = np.frombuffer(raw, '<u2')
|
|
return x.reshape(pilImage.size[::-1]).astype('=u2')
|
|
else: # try to convert to an rgba image
|
|
try:
|
|
diff --git a/lib/matplotlib/testing/conftest.py b/lib/matplotlib/testing/conftest.py
|
|
index 9dc180c9600..fb306594780 100644
|
|
--- a/lib/matplotlib/testing/conftest.py
|
|
+++ b/lib/matplotlib/testing/conftest.py
|
|
@@ -24,19 +24,19 @@ def mpl_test_settings(request):
|
|
original_settings = matplotlib.rcParams.copy()
|
|
|
|
backend = None
|
|
- backend_marker = request.keywords.get('backend')
|
|
+ backend_marker = request.node.get_closest_marker('backend')
|
|
if backend_marker is not None:
|
|
assert len(backend_marker.args) == 1, \
|
|
"Marker 'backend' must specify 1 backend."
|
|
- backend = backend_marker.args[0]
|
|
+ backend, = backend_marker.args
|
|
prev_backend = matplotlib.get_backend()
|
|
|
|
style = '_classic_test' # Default of cleanup and image_comparison too.
|
|
- style_marker = request.keywords.get('style')
|
|
+ style_marker = request.node.get_closest_marker('style')
|
|
if style_marker is not None:
|
|
assert len(style_marker.args) == 1, \
|
|
"Marker 'style' must specify 1 style."
|
|
- style = style_marker.args[0]
|
|
+ style, = style_marker.args
|
|
|
|
matplotlib.testing.setup()
|
|
if backend is not None:
|
|
@@ -64,7 +64,7 @@ def mpl_image_comparison_parameters(request, extension):
|
|
# pytest won't get confused.
|
|
# We annotate the decorated function with any parameters captured by this
|
|
# fixture so that they can be used by the wrapper in image_comparison.
|
|
- baseline_images = request.keywords['baseline_images'].args[0]
|
|
+ baseline_images, = request.node.get_closest_marker('baseline_images').args
|
|
if baseline_images is None:
|
|
# Allow baseline image list to be produced on the fly based on current
|
|
# parametrization.
|
|
diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py
|
|
index 0ce6e625249..d008446dcbf 100644
|
|
--- a/lib/matplotlib/testing/decorators.py
|
|
+++ b/lib/matplotlib/testing/decorators.py
|
|
@@ -223,15 +223,25 @@ def _xfail_if_format_is_uncomparable(extension):
|
|
|
|
def _mark_xfail_if_format_is_uncomparable(extension):
|
|
if isinstance(extension, six.string_types):
|
|
- will_fail = extension not in comparable_formats()
|
|
+ name = extension
|
|
+ marks = []
|
|
+ elif isinstance(extension, tuple):
|
|
+ # Extension might be a pytest ParameterSet instead of a plain string.
|
|
+ # Unfortunately, this type is not exposed, so since it's a namedtuple,
|
|
+ # check for a tuple instead.
|
|
+ name = extension.values[0]
|
|
+ marks = list(extension.marks)
|
|
else:
|
|
# Extension might be a pytest marker instead of a plain string.
|
|
- will_fail = extension.args[0] not in comparable_formats()
|
|
- if will_fail:
|
|
- fail_msg = 'Cannot compare %s files on this system' % extension
|
|
+ name = extension.args[0]
|
|
+ marks = [extension.mark]
|
|
+
|
|
+ if name not in comparable_formats():
|
|
+ fail_msg = 'Cannot compare %s files on this system' % (name, )
|
|
import pytest
|
|
- return pytest.mark.xfail(extension, reason=fail_msg, strict=False,
|
|
- raises=ImageComparisonFailure)
|
|
+ marks += [pytest.mark.xfail(reason=fail_msg, strict=False,
|
|
+ raises=ImageComparisonFailure)]
|
|
+ return pytest.param(name, marks=marks)
|
|
else:
|
|
return extension
|
|
|
|
diff --git a/lib/matplotlib/tests/test_backend_pdf.py b/lib/matplotlib/tests/test_backend_pdf.py
|
|
index 13fa0374ec7..c028eed8f2e 100644
|
|
--- a/lib/matplotlib/tests/test_backend_pdf.py
|
|
+++ b/lib/matplotlib/tests/test_backend_pdf.py
|
|
@@ -8,6 +8,7 @@
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
+import warnings
|
|
|
|
import numpy as np
|
|
import pytest
|
|
@@ -20,9 +21,11 @@
|
|
_determinism_check)
|
|
|
|
|
|
-needs_usetex = pytest.mark.xfail(
|
|
- not checkdep_usetex(True),
|
|
- reason="This test needs a TeX installation")
|
|
+with warnings.catch_warnings():
|
|
+ warnings.simplefilter('ignore')
|
|
+ needs_usetex = pytest.mark.skipif(
|
|
+ not checkdep_usetex(True),
|
|
+ reason="This test needs a TeX installation")
|
|
|
|
|
|
@image_comparison(baseline_images=['pdf_use14corefonts'],
|
|
diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py
|
|
index 8bf6e7dde38..46cb355c986 100644
|
|
--- a/lib/matplotlib/tests/test_backend_ps.py
|
|
+++ b/lib/matplotlib/tests/test_backend_ps.py
|
|
@@ -4,6 +4,7 @@
|
|
|
|
import io
|
|
import re
|
|
+import warnings
|
|
|
|
import numpy as np
|
|
import pytest
|
|
@@ -17,27 +18,30 @@
|
|
_determinism_check)
|
|
|
|
|
|
-needs_ghostscript = pytest.mark.xfail(
|
|
- matplotlib.checkdep_ghostscript()[0] is None,
|
|
- reason="This test needs a ghostscript installation")
|
|
-
|
|
-
|
|
-needs_usetex = pytest.mark.xfail(
|
|
- not matplotlib.checkdep_usetex(True),
|
|
- reason="This test needs a TeX installation")
|
|
+with warnings.catch_warnings():
|
|
+ warnings.simplefilter('ignore')
|
|
+ needs_ghostscript = pytest.mark.skipif(
|
|
+ matplotlib.checkdep_ghostscript()[0] is None,
|
|
+ reason="This test needs a ghostscript installation")
|
|
+ needs_usetex = pytest.mark.skipif(
|
|
+ not matplotlib.checkdep_usetex(True),
|
|
+ reason="This test needs a TeX installation")
|
|
|
|
|
|
# This tests tends to hit a TeX cache lock on AppVeyor.
|
|
@pytest.mark.flaky(reruns=3)
|
|
@pytest.mark.parametrize('format, use_log, rcParams', [
|
|
('ps', False, {}),
|
|
- needs_ghostscript(('ps', False, {'ps.usedistiller': 'ghostscript'})),
|
|
- needs_usetex(needs_ghostscript(('ps', False, {'text.latex.unicode': True,
|
|
- 'text.usetex': True}))),
|
|
+ pytest.param('ps', False, {'ps.usedistiller': 'ghostscript'},
|
|
+ marks=needs_ghostscript),
|
|
+ pytest.param('ps', False, {'text.latex.unicode': True,
|
|
+ 'text.usetex': True},
|
|
+ marks=[needs_ghostscript, needs_usetex]),
|
|
('eps', False, {}),
|
|
('eps', True, {'ps.useafm': True}),
|
|
- needs_usetex(needs_ghostscript(('eps', False, {'text.latex.unicode': True,
|
|
- 'text.usetex': True}))),
|
|
+ pytest.param('eps', False, {'text.latex.unicode': True,
|
|
+ 'text.usetex': True},
|
|
+ marks=[needs_ghostscript, needs_usetex]),
|
|
], ids=[
|
|
'ps',
|
|
'ps with distiller',
|
|
diff --git a/lib/matplotlib/tests/test_backend_qt4.py b/lib/matplotlib/tests/test_backend_qt4.py
|
|
index a621329772e..ede4bca9078 100644
|
|
--- a/lib/matplotlib/tests/test_backend_qt4.py
|
|
+++ b/lib/matplotlib/tests/test_backend_qt4.py
|
|
@@ -29,7 +29,7 @@
|
|
py_qt_ver = QtCore.__version_info__[0]
|
|
|
|
if py_qt_ver != 4:
|
|
- pytestmark = pytest.mark.xfail(reason='Qt4 is not available')
|
|
+ pytestmark = pytest.mark.skipif(reason='Qt4 is not available')
|
|
|
|
|
|
@pytest.mark.backend('Qt4Agg')
|
|
diff --git a/lib/matplotlib/tests/test_backend_svg.py b/lib/matplotlib/tests/test_backend_svg.py
|
|
index e0cbdfa8bce..da93e2d3880 100644
|
|
--- a/lib/matplotlib/tests/test_backend_svg.py
|
|
+++ b/lib/matplotlib/tests/test_backend_svg.py
|
|
@@ -6,6 +6,7 @@
|
|
from io import BytesIO
|
|
import os
|
|
import tempfile
|
|
+import warnings
|
|
import xml.parsers.expat
|
|
|
|
import pytest
|
|
@@ -16,9 +17,11 @@
|
|
from matplotlib import dviread
|
|
|
|
|
|
-needs_usetex = pytest.mark.xfail(
|
|
- not matplotlib.checkdep_usetex(True),
|
|
- reason="This test needs a TeX installation")
|
|
+with warnings.catch_warnings():
|
|
+ warnings.simplefilter('ignore')
|
|
+ needs_usetex = pytest.mark.skipif(
|
|
+ not matplotlib.checkdep_usetex(True),
|
|
+ reason="This test needs a TeX installation")
|
|
|
|
|
|
def test_visibility():
|
|
@@ -130,7 +133,7 @@ def _test_determinism_save(filename, usetex):
|
|
"filename, usetex",
|
|
# unique filenames to allow for parallel testing
|
|
[("determinism_notex.svg", False),
|
|
- needs_usetex(("determinism_tex.svg", True))])
|
|
+ pytest.param("determinism_tex.svg", True, marks=needs_usetex)])
|
|
def test_determinism(filename, usetex):
|
|
import sys
|
|
from subprocess import check_output, STDOUT, CalledProcessError
|
|
diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py
|
|
index df7a5d08a10..8cd4585bffc 100644
|
|
--- a/lib/matplotlib/tests/test_backends_interactive.py
|
|
+++ b/lib/matplotlib/tests/test_backends_interactive.py
|
|
@@ -31,8 +31,10 @@ def _get_testable_interactive_backends():
|
|
reason = "No $DISPLAY"
|
|
elif any(importlib.util.find_spec(dep) is None for dep in deps):
|
|
reason = "Missing dependency"
|
|
- backends.append(pytest.mark.skip(reason=reason)(backend) if reason
|
|
- else backend)
|
|
+ if reason:
|
|
+ backend = pytest.param(
|
|
+ backend, marks=pytest.mark.skip(reason=reason))
|
|
+ backends.append(backend)
|
|
return backends
|
|
|
|
|
|
diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py
|
|
index e6da25789f0..c8a23347f65 100644
|
|
--- a/lib/matplotlib/tests/test_image.py
|
|
+++ b/lib/matplotlib/tests/test_image.py
|
|
@@ -23,14 +23,6 @@
|
|
import pytest
|
|
|
|
|
|
-try:
|
|
- from PIL import Image
|
|
- HAS_PIL = True
|
|
-except ImportError:
|
|
- HAS_PIL = False
|
|
-needs_pillow = pytest.mark.xfail(not HAS_PIL, reason='Test requires Pillow')
|
|
-
|
|
-
|
|
@image_comparison(baseline_images=['image_interps'], style='mpl20')
|
|
def test_image_interps():
|
|
'make the basic nearest, bilinear and bicubic interps'
|
|
@@ -113,8 +105,8 @@ def test_image_python_io():
|
|
plt.imread(buffer)
|
|
|
|
|
|
-@needs_pillow
|
|
def test_imread_pil_uint16():
|
|
+ pytest.importorskip("PIL")
|
|
img = plt.imread(os.path.join(os.path.dirname(__file__),
|
|
'baseline_images', 'test_image', 'uint16.tif'))
|
|
assert (img.dtype == np.uint16)
|
|
@@ -122,8 +114,8 @@ def test_imread_pil_uint16():
|
|
|
|
|
|
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python 3.6+")
|
|
-@needs_pillow
|
|
def test_imread_fspath():
|
|
+ pytest.importorskip("PIL")
|
|
from pathlib import Path
|
|
img = plt.imread(
|
|
Path(__file__).parent / 'baseline_images/test_image/uint16.tif')
|
|
@@ -497,8 +489,8 @@ def test_nonuniformimage_setnorm():
|
|
im.set_norm(plt.Normalize())
|
|
|
|
|
|
-@needs_pillow
|
|
def test_jpeg_2d():
|
|
+ Image = pytest.importorskip('PIL.Image')
|
|
# smoke test that mode-L pillow images work.
|
|
imd = np.ones((10, 10), dtype='uint8')
|
|
for i in range(10):
|
|
@@ -509,8 +501,9 @@ def test_jpeg_2d():
|
|
ax.imshow(im)
|
|
|
|
|
|
-@needs_pillow
|
|
def test_jpeg_alpha():
|
|
+ Image = pytest.importorskip('PIL.Image')
|
|
+
|
|
plt.figure(figsize=(1, 1), dpi=300)
|
|
# Create an image that is all black, with a gradient from 0-1 in
|
|
# the alpha channel from left to right.
|
|
diff --git a/lib/matplotlib/tests/test_mathtext.py b/lib/matplotlib/tests/test_mathtext.py
|
|
index cdc1093e141..af6701a0f1d 100644
|
|
--- a/lib/matplotlib/tests/test_mathtext.py
|
|
+++ b/lib/matplotlib/tests/test_mathtext.py
|
|
@@ -271,7 +271,7 @@ def test_single_minus_sign():
|
|
|
|
buff = io.BytesIO()
|
|
plt.savefig(buff, format="rgba", dpi=1000)
|
|
- array = np.fromstring(buff.getvalue(), dtype=np.uint8)
|
|
+ array = np.frombuffer(buff.getvalue(), dtype=np.uint8)
|
|
|
|
# If this fails, it would be all white
|
|
assert not np.all(array == 0xff)
|
|
diff --git a/lib/matplotlib/tests/test_simplification.py b/lib/matplotlib/tests/test_simplification.py
|
|
index fca140877bd..1b3ccb3f019 100644
|
|
--- a/lib/matplotlib/tests/test_simplification.py
|
|
+++ b/lib/matplotlib/tests/test_simplification.py
|
|
@@ -273,7 +273,7 @@ def test_start_with_moveto():
|
|
# Python 2 case
|
|
decodebytes = base64.decodestring
|
|
|
|
- verts = np.fromstring(decodebytes(data), dtype='<i4')
|
|
+ verts = np.frombuffer(decodebytes(data), dtype='<i4')
|
|
verts = verts.reshape((len(verts) // 2, 2))
|
|
path = Path(verts)
|
|
segs = path.iter_segments(transforms.IdentityTransform(),
|
|
diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py
|
|
index 7bc878accc9..e438766b703 100644
|
|
--- a/lib/matplotlib/tests/test_text.py
|
|
+++ b/lib/matplotlib/tests/test_text.py
|
|
@@ -14,9 +14,11 @@
|
|
from matplotlib.testing.decorators import image_comparison
|
|
|
|
|
|
-needs_usetex = pytest.mark.xfail(
|
|
- not matplotlib.checkdep_usetex(True),
|
|
- reason="This test needs a TeX installation")
|
|
+with warnings.catch_warnings():
|
|
+ warnings.simplefilter('ignore')
|
|
+ needs_usetex = pytest.mark.skipif(
|
|
+ not matplotlib.checkdep_usetex(True),
|
|
+ reason="This test needs a TeX installation")
|
|
|
|
|
|
@image_comparison(baseline_images=['font_styles'])
|
|
diff --git a/lib/matplotlib/tests/test_usetex.py b/lib/matplotlib/tests/test_usetex.py
|
|
index 5d6a939e8a1..e3b1c1f6ce3 100644
|
|
--- a/lib/matplotlib/tests/test_usetex.py
|
|
+++ b/lib/matplotlib/tests/test_usetex.py
|
|
@@ -1,4 +1,5 @@
|
|
from __future__ import absolute_import, division, print_function
|
|
+import warnings
|
|
|
|
import pytest
|
|
|
|
@@ -7,8 +8,14 @@
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
-@pytest.mark.skipif(not matplotlib.checkdep_usetex(True),
|
|
- reason='Missing TeX or Ghostscript or dvipng')
|
|
+with warnings.catch_warnings():
|
|
+ warnings.simplefilter('ignore')
|
|
+ needs_usetex = pytest.mark.skipif(
|
|
+ not matplotlib.checkdep_usetex(True),
|
|
+ reason='Missing TeX of Ghostscript or dvipng')
|
|
+
|
|
+
|
|
+@needs_usetex
|
|
@image_comparison(baseline_images=['test_usetex'],
|
|
extensions=['pdf', 'png'],
|
|
tol=0.3)
|
|
diff --git a/lib/matplotlib/tri/triinterpolate.py b/lib/matplotlib/tri/triinterpolate.py
|
|
index e0c2047489a..f3c6deb0c97 100644
|
|
--- a/lib/matplotlib/tri/triinterpolate.py
|
|
+++ b/lib/matplotlib/tri/triinterpolate.py
|
|
@@ -581,9 +581,9 @@ def _compute_tri_eccentricities(tris_pts):
|
|
The so-called eccentricity parameters [1] needed for
|
|
HCT triangular element.
|
|
"""
|
|
- a = np.expand_dims(tris_pts[:, 2, :]-tris_pts[:, 1, :], axis=2)
|
|
- b = np.expand_dims(tris_pts[:, 0, :]-tris_pts[:, 2, :], axis=2)
|
|
- c = np.expand_dims(tris_pts[:, 1, :]-tris_pts[:, 0, :], axis=2)
|
|
+ a = np.expand_dims(tris_pts[:, 2, :] - tris_pts[:, 1, :], axis=2)
|
|
+ b = np.expand_dims(tris_pts[:, 0, :] - tris_pts[:, 2, :], axis=2)
|
|
+ c = np.expand_dims(tris_pts[:, 1, :] - tris_pts[:, 0, :], axis=2)
|
|
# Do not use np.squeeze, this is dangerous if only one triangle
|
|
# in the triangulation...
|
|
dot_a = _prod_vectorized(_transpose_vectorized(a), a)[:, 0, 0]
|
|
@@ -1071,9 +1071,9 @@ def get_dof_vec(tri_z, tri_dz, J):
|
|
J1 = _prod_vectorized(_ReducedHCT_Element.J0_to_J1, J)
|
|
J2 = _prod_vectorized(_ReducedHCT_Element.J0_to_J2, J)
|
|
|
|
- col0 = _prod_vectorized(J, np.expand_dims(tri_dz[:, 0, :], axis=3))
|
|
- col1 = _prod_vectorized(J1, np.expand_dims(tri_dz[:, 1, :], axis=3))
|
|
- col2 = _prod_vectorized(J2, np.expand_dims(tri_dz[:, 2, :], axis=3))
|
|
+ col0 = _prod_vectorized(J, np.expand_dims(tri_dz[:, 0, :], axis=2))
|
|
+ col1 = _prod_vectorized(J1, np.expand_dims(tri_dz[:, 1, :], axis=2))
|
|
+ col2 = _prod_vectorized(J2, np.expand_dims(tri_dz[:, 2, :], axis=2))
|
|
|
|
dfdksi = _to_matrix_vectorized([
|
|
[col0[:, 0, 0], col1[:, 0, 0], col2[:, 0, 0]],
|
|
diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py
|
|
index 0a506db92ad..d6e57b9b4e6 100644
|
|
--- a/lib/mpl_toolkits/tests/test_mplot3d.py
|
|
+++ b/lib/mpl_toolkits/tests/test_mplot3d.py
|
|
@@ -125,9 +125,10 @@ def test_lines3d():
|
|
|
|
|
|
# Reason for flakiness of SVG test is still unknown.
|
|
-@image_comparison(baseline_images=['mixedsubplot'], remove_text=True,
|
|
- extensions=['png', 'pdf',
|
|
- pytest.mark.xfail('svg', strict=False)])
|
|
+@image_comparison(
|
|
+ baseline_images=['mixedsubplot'], remove_text=True,
|
|
+ extensions=['png', 'pdf',
|
|
+ pytest.param('svg', marks=pytest.mark.xfail(strict=False))])
|
|
def test_mixedsubplots():
|
|
def f(t):
|
|
s1 = np.cos(2*np.pi*t)
|