Skip to content

Commit d087fc5

Browse files
authored
Raise error if cmap is list of colors (#3310)
* Raise error if cmap is list of colors * whats-new.rst
1 parent 756c941 commit d087fc5

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Breaking changes
3434
- :py:func:`~xarray.concat` now requires the ``dim`` argument. Its ``indexers``, ``mode``
3535
and ``concat_over`` kwargs have now been removed.
3636
By `Deepak Cherian <https://github.com/dcherian>`_
37+
- Passing a list of colors in ``cmap`` will now raise an error, having been deprecated since
38+
v0.6.1.
3739
- Most xarray objects now define ``__slots__``. This reduces overall RAM usage by ~22%
3840
(not counting the underlying numpy buffers); on CPython 3.7/x64, a trivial DataArray
3941
has gone down from 1.9kB to 1.5kB.

xarray/plot/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,9 @@ def _process_cmap_cbar_kwargs(
737737
# we should not be getting a list of colors in cmap anymore
738738
# is there a better way to do this test?
739739
if isinstance(cmap, (list, tuple)):
740-
warnings.warn(
740+
raise ValueError(
741741
"Specifying a list of colors in cmap is deprecated. "
742-
"Use colors keyword instead.",
743-
DeprecationWarning,
744-
stacklevel=3,
742+
"Use colors keyword instead."
745743
)
746744

747745
cmap_kwargs = {

xarray/tests/test_plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,8 @@ def test_cmap_and_color_both(self):
13201320
with pytest.raises(ValueError):
13211321
self.plotmethod(colors="k", cmap="RdBu")
13221322

1323-
def list_of_colors_in_cmap_deprecated(self):
1324-
with pytest.raises(Exception):
1323+
def list_of_colors_in_cmap_raises_error(self):
1324+
with raises_regex(ValueError, "list of colors"):
13251325
self.plotmethod(cmap=["k", "b"])
13261326

13271327
@pytest.mark.slow

0 commit comments

Comments
 (0)