From 61201f79ddc3aec0930419c425839c3380663b05 Mon Sep 17 00:00:00 2001 From: dcherian Date: Mon, 16 Sep 2019 08:12:38 -0600 Subject: [PATCH 1/2] Raise error if cmap is list of colors --- xarray/plot/utils.py | 6 ++---- xarray/tests/test_plot.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) 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 From 86c2dd15955bb31ab749f1ab5b55925145c610b4 Mon Sep 17 00:00:00 2001 From: dcherian Date: Tue, 17 Sep 2019 08:45:39 -0600 Subject: [PATCH 2/2] whats-new.rst --- doc/whats-new.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index ab4b17ff16d..d5be0e84ffb 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.