summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-03-26 10:23:53 +0100
committerEric Wieser <wieser.eric@gmail.com>2017-03-28 20:44:38 +0100
commit09d4d35bb979dd0d5d0781946f59f362765eca66 (patch)
treec3ad3b91881d7bdd86ea28c0473e2252a8a71238 /numpy/core/numeric.py
parent4feb97e66000b17baa15b8486a7c1f9608865e78 (diff)
downloadnumpy-09d4d35bb979dd0d5d0781946f59f362765eca66.tar.gz
MAINT: Use normalize_axis_index in cross
Previously we did not, as this wouldn't say which axis argument was the cause of the problem.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index eabf7962a..e1352ee6c 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -1752,11 +1752,9 @@ def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None):
a = asarray(a)
b = asarray(b)
# Check axisa and axisb are within bounds
- axis_msg = "'axis{0}' out of bounds"
- if axisa < -a.ndim or axisa >= a.ndim:
- raise ValueError(axis_msg.format('a'))
- if axisb < -b.ndim or axisb >= b.ndim:
- raise ValueError(axis_msg.format('b'))
+ axisa = normalize_axis_index(axisa, a.ndim, msg_prefix='axisa')
+ axisb = normalize_axis_index(axisb, b.ndim, msg_prefix='axisb')
+
# Move working axis to the end of the shape
a = rollaxis(a, axisa, a.ndim)
b = rollaxis(b, axisb, b.ndim)
@@ -1770,8 +1768,7 @@ def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None):
if a.shape[-1] == 3 or b.shape[-1] == 3:
shape += (3,)
# Check axisc is within bounds
- if axisc < -len(shape) or axisc >= len(shape):
- raise ValueError(axis_msg.format('c'))
+ axisc = normalize_axis_index(axisc, len(shape), msg_prefix='axisc')
dtype = promote_types(a.dtype, b.dtype)
cp = empty(shape, dtype)