summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Moore <ewm@redtetrahedron.org>2014-10-20 14:06:50 -0400
committerEric Moore <ewm@redtetrahedron.org>2014-10-20 16:57:50 -0400
commit270ae2c7cac71c91a52701c5b0eb7e5f6d388b14 (patch)
treef7946d6b2f5596639b69253901909ad395fc10c8
parentdf9db6ed5f9c9e315993f4efed5dba613e6cd84c (diff)
downloadnumpy-270ae2c7cac71c91a52701c5b0eb7e5f6d388b14.tar.gz
MAINT: Give a more helpful error for bad axis specifications.
This specifically addresses passing things like axis=[0,1] which gave an error message that an int was required. The real error was that if the axis isn't None or a tuple, it was simply wraped in a tuple, so the ufunc that is eventually called ended up with a list. The error message is matches that in core/src/multiarray/conversion_utils.c::PyArray_ConvertMultiAxis.
-rw-r--r--numpy/linalg/linalg.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index e8f7a8ab1..e35c9ac97 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -2074,6 +2074,10 @@ def norm(x, ord=None, axis=None, keepdims=False):
if axis is None:
axis = tuple(range(nd))
elif not isinstance(axis, tuple):
+ try:
+ axis = int(axis)
+ except:
+ raise TypeError("'axis' must be None, an integer or a tuple of integers")
axis = (axis,)
if len(axis) == 1: