From d087fc58c40be0490151cb011802a609a774aaba Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Tue, 17 Sep 2019 14:49:31 +0000 Subject: [PATCH] Raise error if cmap is list of colors (#3310) * Raise error if cmap is list of colors * whats-new.rst --- doc/whats-new.rst | 2 ++ xarray/plot/utils.py | 6 ++---- xarray/tests/test_plot.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 492c9279e6b..567e74052d5 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -34,6 +34,8 @@ Breaking changes - :py:func:`~xarray.concat` now requires the ``dim`` argument. Its ``indexers``, ``mode`` and ``concat_over`` kwargs have now been removed. By `Deepak Cherian `_ +- Passing a list of colors in ``cmap`` will now raise an error, having been deprecated since + v0.6.1. - Most xarray objects now define ``__slots__``. This reduces overall RAM usage by ~22% (not counting the underlying numpy buffers); on CPython 3.7/x64, a trivial DataArray has gone down from 1.9kB to 1.5kB. diff --git a/xarray/plot/utils.py b/xarray/plot/utils.py index 53bbe8bacb9..f69a8af7a2f 100644 --- a/xarray/plot/utils.py +++ b/xarray/plot/utils.py @@ -737,11 +737,9 @@ def _process_cmap_cbar_kwargs( # we should not be getting a list of colors in cmap anymore # is there a better way to do this test? if isinstance(cmap, (list, tuple)): - warnings.warn( + raise ValueError( "Specifying a list of colors in cmap is deprecated. " - "Use colors keyword instead.", - DeprecationWarning, - stacklevel=3, + "Use colors keyword instead." ) cmap_kwargs = { diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index c9b041b3ba7..020a49b0114 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -1320,8 +1320,8 @@ def test_cmap_and_color_both(self): with pytest.raises(ValueError): self.plotmethod(colors="k", cmap="RdBu") - def list_of_colors_in_cmap_deprecated(self): - with pytest.raises(Exception): + def list_of_colors_in_cmap_raises_error(self): + with raises_regex(ValueError, "list of colors"): self.plotmethod(cmap=["k", "b"]) @pytest.mark.slow