summaryrefslogtreecommitdiff
path: root/numpy/linalg/linalg.py
diff options
context:
space:
mode:
authorRittaNarita <narittan@gmail.com>2015-03-29 01:28:59 +0900
committerRittaNarita <narittan@gmail.com>2015-03-30 01:04:14 +0900
commitfa372af5e82637cccd494f044517b6e48b9ca456 (patch)
tree5a25117c74b89a6bf5bb6ea8afd1cb3e01263d39 /numpy/linalg/linalg.py
parent4679ff2380c01f18ea8cfd2d89838ba53f6381de (diff)
downloadnumpy-fa372af5e82637cccd494f044517b6e48b9ca456.tar.gz
BUG: Fix linalg matrix norms when given negative axes.
Diffstat (limited to 'numpy/linalg/linalg.py')
-rw-r--r--numpy/linalg/linalg.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index 23b493447..30180f24a 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -2146,10 +2146,14 @@ def norm(x, ord=None, axis=None, keepdims=False):
return add.reduce(absx, axis=axis, keepdims=keepdims) ** (1.0 / ord)
elif len(axis) == 2:
row_axis, col_axis = axis
- if not (-nd <= row_axis < nd and -nd <= col_axis < nd):
+ if row_axis < 0:
+ row_axis += nd
+ if col_axis < 0:
+ col_axis += nd
+ if not (0 <= row_axis < nd and 0 <= col_axis < nd):
raise ValueError('Invalid axis %r for an array with shape %r' %
(axis, x.shape))
- if row_axis % nd == col_axis % nd:
+ if row_axis == col_axis:
raise ValueError('Duplicate axes given.')
if ord == 2:
ret = _multi_svd_norm(x, row_axis, col_axis, amax)