Skip to content

Suppress/fix some test warnings. #11705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,8 @@ def _transform(self, a):
"""
Inplace transformation.
"""
masked = np.abs(a) > self.linthresh
with np.errstate(invalid="ignore"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this throw an invalid warning in the first place? It's not obvious to me that _transform should be getting invalid values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can definitely pass nans in (they're ignored at a later stage, by the low-level path handling machinery).

masked = np.abs(a) > self.linthresh
sign = np.sign(a[masked])
log = (self._linscale_adj + np.log(np.abs(a[masked]) / self.linthresh))
log *= sign * self.linthresh
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ def test_scatter_marker(self):
c=[(1, 0, 0), 'y', 'b', 'lime'],
s=[60, 50, 40, 30],
edgecolors=['k', 'r', 'g', 'b'],
verts=verts)
marker=verts)

@image_comparison(baseline_images=['scatter_2D'], remove_text=True,
extensions=['png'])
Expand Down
10 changes: 5 additions & 5 deletions lib/matplotlib/tests/test_font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def test_otf():
if os.path.exists(fname):
assert is_opentype_cff_font(fname)

otf_files = [f for f in fontManager.ttffiles if 'otf' in f]
for f in otf_files:
with open(f, 'rb') as fd:
res = fd.read(4) == b'OTTO'
assert res == is_opentype_cff_font(f)
for f in fontManager.ttflist:
if 'otf' in f.fname:
with open(f.fname, 'rb') as fd:
res = fd.read(4) == b'OTTO'
assert res == is_opentype_cff_font(f.fname)


@pytest.mark.skipif(not has_fclist, reason='no fontconfig installed')
Expand Down
7 changes: 5 additions & 2 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from contextlib import ExitStack
from copy import copy
import io
import os
Expand Down Expand Up @@ -875,8 +876,10 @@ def test_empty_imshow(make_norm):
def test_imshow_float128():
fig, ax = plt.subplots()
ax.imshow(np.zeros((3, 3), dtype=np.longdouble))
# Ensure that drawing doesn't cause crash
fig.canvas.draw()
with (ExitStack() if np.can_cast(np.longdouble, np.float64, "equiv")
else pytest.warns(UserWarning)):
# Ensure that drawing doesn't cause crash.
fig.canvas.draw()


def test_imshow_bool():
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from numpy.testing import assert_almost_equal, assert_array_equal
import pytest

from matplotlib.cbook import MatplotlibDeprecationWarning
from matplotlib.patches import Polygon, Rectangle
from matplotlib.testing.decorators import image_comparison, check_figures_equal
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -344,8 +345,9 @@ def test_patch_str():
s = mpatches.Shadow(p, 1, 1)
assert str(s) == "Shadow(ConnectionPatch((1, 2), (3, 4)))"

p = mpatches.YAArrow(plt.gcf(), (1, 0), (2, 1), width=0.1)
assert str(p) == "YAArrow()"
with pytest.warns(MatplotlibDeprecationWarning):
p = mpatches.YAArrow(plt.gcf(), (1, 0), (2, 1), width=0.1)
assert str(p) == "YAArrow()"

# Not testing Arrow, FancyArrow here
# because they seem to exist only for historical reasons.
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest

import matplotlib as mpl
from matplotlib.cbook import MatplotlibDeprecationWarning
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import numpy as np
Expand Down Expand Up @@ -120,8 +121,7 @@ def test_Bug_2543():
# printed in the test suite.
with warnings.catch_warnings():
warnings.filterwarnings('ignore',
message='.*(deprecated|obsolete)',
category=UserWarning)
category=MatplotlibDeprecationWarning)
with mpl.rc_context():
_copy = mpl.rcParams.copy()
for key in _copy:
Expand Down