diff --git a/examples/api/custom_projection_example.py b/examples/api/custom_projection_example.py index 7dc0ca2b1e41..1747027146ba 100644 --- a/examples/api/custom_projection_example.py +++ b/examples/api/custom_projection_example.py @@ -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): @@ -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): diff --git a/lib/matplotlib/cm.py b/lib/matplotlib/cm.py index adc2c14b824c..7e61585ead44 100644 --- a/lib/matplotlib/cm.py +++ b/lib/matplotlib/cm.py @@ -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 @@ -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: @@ -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) diff --git a/lib/matplotlib/projections/geo.py b/lib/matplotlib/projections/geo.py index a428b1380cb6..00071e6d05dc 100644 --- a/lib/matplotlib/projections/geo.py +++ b/lib/matplotlib/projections/geo.py @@ -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): diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index 122b6fd4a677..961d68cfe8df 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -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(): verifiers['svg'] = lambda filename: [ 'xmllint', '--valid', '--nowarning', '--noout', filename] diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index ca341e74cf42..7123beaa327f 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -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 @@ -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() diff --git a/lib/matplotlib/tests/test_path.py b/lib/matplotlib/tests/test_path.py index c29289ae81f2..71fcb7c89bc7 100644 --- a/lib/matplotlib/tests/test_path.py +++ b/lib/matplotlib/tests/test_path.py @@ -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():
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: