From 8e6d4c12b04bb13289fb7ad0045bf323628aa071 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 13 Jan 2017 22:33:16 -0800 Subject: [PATCH] Remove invalid dimension checking in axes_rgb. Just let `dstack` error out if dimensions don't match. --- lib/mpl_toolkits/axes_grid1/axes_rgb.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/mpl_toolkits/axes_grid1/axes_rgb.py b/lib/mpl_toolkits/axes_grid1/axes_rgb.py index b4a76ebddb14..e62d4f061544 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_rgb.py +++ b/lib/mpl_toolkits/axes_grid1/axes_rgb.py @@ -202,23 +202,20 @@ def imshow_rgb(self, r, g, b, **kwargs): g : matplotlib.image.AxesImage b : matplotlib.image.AxesImage """ - ny, nx = r.shape - if not ((nx, ny) == g.shape == b.shape): + if not (r.shape == g.shape == b.shape): raise ValueError('Input shapes do not match.' - '\nr.shape = {0}' - '\ng.shape = {1}' - '\nb.shape = {2}' - ''.format(r.shape, g.shape, b.shape)) - - R = np.zeros([ny, nx, 3], dtype="d") + '\nr.shape = {}' + '\ng.shape = {}' + '\nb.shape = {}' + .format(r.shape, g.shape, b.shape)) + RGB = np.dstack([r, g, b]) + R = np.zeros_like(RGB) R[:,:,0] = r - G = np.zeros_like(R) + G = np.zeros_like(RGB) G[:,:,1] = g - B = np.zeros_like(R) + B = np.zeros_like(RGB) B[:,:,2] = b - RGB = R + G + B - im_rgb = self.RGB.imshow(RGB, **kwargs) im_r = self.R.imshow(R, **kwargs) im_g = self.G.imshow(G, **kwargs)