From c106b750cabd048517c8651d7c27b5c52a33dccc Mon Sep 17 00:00:00 2001 From: Jan-Philip Gehrcke Date: Fri, 21 Sep 2012 17:42:19 +0300 Subject: [PATCH 1/3] Update lib/mpl_toolkits/mplot3d/axes3d.py Axes3D.scatter: raise exception in case z.size neither being 1 nor equaling x.size and y.size (according to documentation). --- lib/mpl_toolkits/mplot3d/axes3d.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 29b2e6810d4c..74fe4ec47da9 100755 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1937,8 +1937,11 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c='b', *args, **kwargs): zs = np.ma.ravel(zs) if xs.size != ys.size: raise ValueError("x and y must be the same size") - if xs.size != zs.size and zs.size == 1: - zs = np.array(zs[0] * xs.size) + if xs.size != zs.size: + if zs.size == 1: + zs = np.array(zs[0] * xs.size) + else: + raise ValueError("z must be either of same size as x and y or of size 1") s = np.ma.ravel(s) # This doesn't have to match x, y in size. From a2fa253c57b1b4e93351b56ab49de64a8d50ebab Mon Sep 17 00:00:00 2001 From: Jan-Philip Gehrcke Date: Sun, 23 Sep 2012 21:07:44 +0300 Subject: [PATCH 2/3] Update lib/mpl_toolkits/mplot3d/axes3d.py Match argument names in error messages to argument names in documentation. --- lib/mpl_toolkits/mplot3d/axes3d.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 74fe4ec47da9..ea9e894b8d33 100755 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1936,12 +1936,13 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c='b', *args, **kwargs): ys = np.ma.ravel(ys) zs = np.ma.ravel(zs) if xs.size != ys.size: - raise ValueError("x and y must be the same size") + raise ValueError("Arguments 'xs' and 'ys' must be of same size.") if xs.size != zs.size: if zs.size == 1: zs = np.array(zs[0] * xs.size) else: - raise ValueError("z must be either of same size as x and y or of size 1") + raise ValueError(("Argument 'zs' must be of same size as 'xs' " + "and 'ys' or of size 1.")) s = np.ma.ravel(s) # This doesn't have to match x, y in size. From 29e556a63e700f019cdacc39a0363c80bdd4f674 Mon Sep 17 00:00:00 2001 From: Jan-Philip Gehrcke Date: Sun, 23 Sep 2012 21:14:40 +0300 Subject: [PATCH 3/3] Update lib/mpl_toolkits/mplot3d/axes3d.py Make Axes3D.scatter properly deal with `zs` being of size 1. --- lib/mpl_toolkits/mplot3d/axes3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index ea9e894b8d33..894e09717b2c 100755 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1939,7 +1939,7 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c='b', *args, **kwargs): raise ValueError("Arguments 'xs' and 'ys' must be of same size.") if xs.size != zs.size: if zs.size == 1: - zs = np.array(zs[0] * xs.size) + zs = np.tile(zs[0], xs.size) else: raise ValueError(("Argument 'zs' must be of same size as 'xs' " "and 'ys' or of size 1."))