Skip to content

Add vega deprecations to tests on master #7987

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 2 commits into from
Jan 30, 2017
Merged
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
25 changes: 14 additions & 11 deletions lib/matplotlib/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,19 +608,22 @@ def test_pandas_iterable():
assert_array_equal(cm1.colors, cm2.colors)


def test_colormap_reversing():
@pytest.mark.parametrize('name', cm.cmap_d)
def test_colormap_reversing(name):
"""Check the generated _lut data of a colormap and corresponding
reversed colormap if they are almost the same."""
for name in cm.cmap_d:
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
cmap = plt.get_cmap(name)
assert len(w) == (1 if name in ('spectral', 'spectral_r') else 0)
cmap_r = cmap.reversed()
if not cmap_r._isinit:
cmap._init()
cmap_r._init()
assert_array_almost_equal(cmap._lut[:-3], cmap_r._lut[-4::-1])
should_have_warning = {'spectral', 'spectral_r', 'Vega10', 'Vega10_r',
'Vega20', 'Vega20_r', 'Vega20b', 'Vega20b_r',
'Vega20c', 'Vega20c_r'}
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
cmap = plt.get_cmap(name)
assert len(w) == (1 if name in should_have_warning else 0)
Copy link
Member

Choose a reason for hiding this comment

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

How about adding some more data in the AssertionError message if this doesn't match? Something like

assert len(w) == (1 if name in should_have_warning else 0), (name, [wg.message for wg in w])

would help the next person who wants to debug why this assertion is failing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, name is already available though the parametrization and will be printed as part of the test name. Pytest also prints out w, but unfortunately using the repr which doesn't look that great for warnings, so maybe adding that to the message wouldn't be a bad idea.

cmap_r = cmap.reversed()
if not cmap_r._isinit:
cmap._init()
cmap_r._init()
assert_array_almost_equal(cmap._lut[:-3], cmap_r._lut[-4::-1])


@cleanup
Expand Down