Skip to content

Commit

Permalink
More fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed May 2, 2019
1 parent 6fcf4fe commit f33af47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions xarray/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ def _determine_cmap_params(plot_data, vmin=None, vmax=None, cmap=None,
extend = _determine_extend(calc_data, vmin, vmax)

cmap_is_colormap = (
isinstance(cmap, mpl.colors.Colormap)
or isinstance(cmap, mpl.colors.LinearSegmentedColormap)
isinstance(cmap, mpl.colors.LinearSegmentedColormap)
or isinstance(cmap, mpl.colors.ListedColormap)
)

if ((levels is not None or isinstance(norm, mpl.colors.BoundaryNorm))
Expand Down
10 changes: 7 additions & 3 deletions xarray/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,16 @@ def test_cmap_sequential_option(self):

@pytest.mark.parametrize(
'cmap', [mpl.colors.LinearSegmentedColormap.from_list('name', ['r', 'g', 'b']),
mpl.colors.ListedColormap(['r', 'g', 'b']),
'RdBu_r'])
mpl.colors.ListedColormap(['r', 'g', 'b'])])
def test_do_nothing_if_provided_cmap(self, cmap):
cmap_params = _determine_cmap_params(self.data, cmap=cmap)
cmap_params = _determine_cmap_params(self.data, cmap=cmap, levels=7)
assert cmap_params['cmap'] is cmap

def test_do_something_if_provided_str_cmap(self):
cmap = 'RdBu_r'
cmap_params = _determine_cmap_params(self.data, cmap=cmap, levels=7)
assert cmap_params['cmap'] is not cmap

def test_cmap_sequential_explicit_option(self):
with xr.set_options(cmap_sequential=mpl.cm.magma):
cmap_params = _determine_cmap_params(self.data)
Expand Down

0 comments on commit f33af47

Please sign in to comment.