Skip to content

Commit

Permalink
Raise error if cmap is list of colors (#3310)
Browse files Browse the repository at this point in the history
* Raise error if cmap is list of colors

* whats-new.rst
  • Loading branch information
dcherian authored Sep 17, 2019
1 parent 756c941 commit d087fc5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/dcherian>`_
- 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.
Expand Down
6 changes: 2 additions & 4 deletions xarray/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d087fc5

Please sign in to comment.