Skip to content

Fix/hide some deprecations #7857

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 5 commits into from
Jan 29, 2017
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
14 changes: 6 additions & 8 deletions examples/api/custom_projection_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,9 @@ def set_longitude_grid(self, degrees):
class -- it provides a more convenient interface to set the
ticking than set_xticks would.
"""
number = (360.0 / degrees) + 1
self.xaxis.set_major_locator(
FixedLocator(
np.linspace(-np.pi, np.pi, number, True)[1:-1]))
# Skip -180 and 180, which are the fixed limits.
grid = np.arange(-180 + degrees, 180, degrees)
self.xaxis.set_major_locator(FixedLocator(np.deg2rad(grid)))
self.xaxis.set_major_formatter(self.ThetaFormatter(degrees))

def set_latitude_grid(self, degrees):
Expand All @@ -311,10 +310,9 @@ def set_latitude_grid(self, degrees):
class -- it provides a more convenient interface than
set_yticks would.
"""
number = (180.0 / degrees) + 1
self.yaxis.set_major_locator(
FixedLocator(
np.linspace(-np.pi / 2.0, np.pi / 2.0, number, True)[1:-1]))
# Skip -90 and 90, which are the fixed limits.
grid = np.arange(-90 + degrees, 90, degrees)
self.yaxis.set_major_locator(FixedLocator(np.deg2rad(grid)))
self.yaxis.set_major_formatter(self.ThetaFormatter(degrees))

def set_longitude_grid_ends(self, degrees):
Expand Down
26 changes: 11 additions & 15 deletions lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import six

import os
import warnings as _warnings # To remove once spectral is removed
import numpy as np
from numpy import ma
import matplotlib as mpl
Expand Down Expand Up @@ -69,7 +68,8 @@ def _generate_cmap(name, lutsize):
"""Generates the requested cmap from its *name*. The lut size is
*lutsize*."""

spec = datad[name]
# Use superclass method to avoid deprecation warnings during initial load.
spec = dict.__getitem__(datad, name)

# Generate the colormap object.
if 'red' in spec:
Expand All @@ -81,19 +81,15 @@ def _generate_cmap(name, lutsize):

LUTSIZE = mpl.rcParams['image.lut']

# We silence warnings here to avoid raising the deprecation warning for
# spectral/spectral_r when this module is imported.
with _warnings.catch_warnings():
_warnings.simplefilter("ignore")
# Generate the reversed specifications (all at once, to avoid
# modify-when-iterating).
datad.update({cmapname + '_r': _reverse_cmap_spec(spec)
for cmapname, spec in six.iteritems(datad)})

# Precache the cmaps with ``lutsize = LUTSIZE``.
# Also add the reversed ones added in the section above:
for cmapname in datad:
cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE)
# Generate the reversed specifications (all at once, to avoid
# modify-when-iterating).
datad.update({cmapname + '_r': _reverse_cmap_spec(spec)
for cmapname, spec in six.iteritems(datad)})

# Precache the cmaps with ``lutsize = LUTSIZE``.
# Also add the reversed ones added in the section above:
for cmapname in datad:
cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE)

cmap_d.update(cmaps_listed)

Expand Down
16 changes: 7 additions & 9 deletions lib/matplotlib/projections/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,18 @@ def set_longitude_grid(self, degrees):
"""
Set the number of degrees between each longitude grid.
"""
number = (360.0 / degrees) + 1
self.xaxis.set_major_locator(
FixedLocator(
np.linspace(-np.pi, np.pi, number, True)[1:-1]))
# Skip -180 and 180, which are the fixed limits.
grid = np.arange(-180 + degrees, 180, degrees)
self.xaxis.set_major_locator(FixedLocator(np.deg2rad(grid)))
self.xaxis.set_major_formatter(self.ThetaFormatter(degrees))

def set_latitude_grid(self, degrees):
"""
Set the number of degrees between each longitude grid.
Set the number of degrees between each latitude grid.
"""
number = (180.0 / degrees) + 1
self.yaxis.set_major_locator(
FixedLocator(
np.linspace(-np.pi / 2.0, np.pi / 2.0, number, True)[1:-1]))
# Skip -90 and 90, which are the fixed limits.
grid = np.arange(-90 + degrees, 90, degrees)
self.yaxis.set_major_locator(FixedLocator(np.deg2rad(grid)))
self.yaxis.set_major_formatter(self.ThetaFormatter(degrees))

def set_longitude_grid_ends(self, degrees):
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/testing/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def convert(filename, cache):
verifiers = {}

# Turning this off, because it seems to cause multiprocessing issues
if matplotlib.checkdep_xmllint() and False:
if False and matplotlib.checkdep_xmllint():
Copy link
Member

Choose a reason for hiding this comment

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

iirc @anntzer deletes this in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

I deprecated it, so during the deprecation period the "False" should indeed come first to avoid triggering a deprecation warning.

Copy link
Member

Choose a reason for hiding this comment

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

ah, fair enough.

verifiers['svg'] = lambda filename: [
'xmllint', '--valid', '--nowarning', '--noout', filename]

Expand Down
8 changes: 6 additions & 2 deletions lib/matplotlib/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import six
import itertools
import pytest
import warnings
from distutils.version import LooseVersion as V

import numpy as np
import pytest

from numpy.testing import assert_equal
from numpy.testing.utils import assert_array_equal, assert_array_almost_equal
Expand Down Expand Up @@ -612,7 +613,10 @@ def test_colormap_reversing():
"""Check the generated _lut data of a colormap and corresponding
reversed colormap if they are almost the same."""
for name in cm.cmap_d:
cmap = plt.get_cmap(name)
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()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_make_compound_path_empty():
def test_xkcd():
np.random.seed(0)

x = np.linspace(0, 2.0 * np.pi, 100.0)
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)

with plt.xkcd():
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy