From a8580f76b39451c4119dd13ab4d524f3f4f28e14 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 12 Jul 2015 14:36:27 -0500 Subject: [PATCH] Always create a colorbar and update tests --- skimage/io/_plugins/matplotlib_plugin.py | 3 +-- skimage/io/tests/test_mpl_imshow.py | 19 +++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/skimage/io/_plugins/matplotlib_plugin.py b/skimage/io/_plugins/matplotlib_plugin.py index 1ad1e4aa..421ddc6d 100644 --- a/skimage/io/_plugins/matplotlib_plugin.py +++ b/skimage/io/_plugins/matplotlib_plugin.py @@ -147,8 +147,7 @@ def imshow(im, *args, **kwargs): kwargs.setdefault('vmin', lo) kwargs.setdefault('vmax', hi) ax_im = plt.imshow(im, *args, **kwargs) - if cmap != _default_colormap: - plt.colorbar() + plt.colorbar() return ax_im imread = plt.imread diff --git a/skimage/io/tests/test_mpl_imshow.py b/skimage/io/tests/test_mpl_imshow.py index 166c8cbc..50827956 100644 --- a/skimage/io/tests/test_mpl_imshow.py +++ b/skimage/io/tests/test_mpl_imshow.py @@ -19,7 +19,6 @@ im_lo = imf / 1000 im_hi = imf + 10 - def n_subplots(ax_im): """Return the number of subplots in the figure containing an ``AxesImage``. @@ -44,27 +43,24 @@ def n_subplots(ax_im): def test_uint8(): ax_im = io.imshow(im8) - assert ax_im.cmap.name == 'gray' + assert ax_im.cmap.name == 'viridis' assert ax_im.get_clim() == (0, 255) - # check that no colorbar was created - assert n_subplots(ax_im) == 1 - assert ax_im.colorbar is None + assert n_subplots(ax_im) == 2 + assert ax_im.colorbar is not None def test_uint16(): ax_im = io.imshow(im16) - assert ax_im.cmap.name == 'gray' + assert ax_im.cmap.name == 'viridis' assert ax_im.get_clim() == (0, 65535) - assert n_subplots(ax_im) == 1 - assert ax_im.colorbar is None + assert ax_im.colorbar is not None def test_float(): ax_im = io.imshow(imf) - assert ax_im.cmap.name == 'gray' + assert ax_im.cmap.name == 'viridis' assert ax_im.get_clim() == (0, 1) - assert n_subplots(ax_im) == 1 - assert ax_im.colorbar is None + assert ax_im.colorbar is not None def test_low_dynamic_range(): @@ -72,7 +68,6 @@ def test_low_dynamic_range(): ax_im = io.imshow(im_lo) assert ax_im.get_clim() == (im_lo.min(), im_lo.max()) # check that a colorbar was created - assert n_subplots(ax_im) == 2 assert ax_im.colorbar is not None