summaryrefslogtreecommitdiff
path: root/numpy/linalg/tests
diff options
context:
space:
mode:
authorJim <jim.verheijde@hotmail.com>2020-03-12 19:05:22 +0100
committerGitHub <noreply@github.com>2020-03-12 14:05:22 -0400
commit33351f646e0b523139fbba4986eba54a3bfe55a7 (patch)
tree39631903f6f388c2b89e151594dab45eb1d22b77 /numpy/linalg/tests
parent32f382c86f384a02eeb87f67fea806e6b9961b5c (diff)
downloadnumpy-33351f646e0b523139fbba4986eba54a3bfe55a7.tar.gz
MAINT: Add better error handling in linalg.norm for vectors and clarify it in documentation (#15740)
* Clarify `fro` and `nuc` usage in linalg.norm documentation (see #15533). * Add improved error handling when getting Frobenius norm from a vector (see #15533). * Fix comment in linalg norm test. Closes gh-15533.
Diffstat (limited to 'numpy/linalg/tests')
-rw-r--r--numpy/linalg/tests/test_linalg.py3
-rw-r--r--numpy/linalg/tests/test_regression.py4
2 files changed, 4 insertions, 3 deletions
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py
index 04f5c3d19..dae4ef61e 100644
--- a/numpy/linalg/tests/test_linalg.py
+++ b/numpy/linalg/tests/test_linalg.py
@@ -1480,11 +1480,12 @@ class _TestNorm2D(_TestNormBase):
# Using `axis=<integer>` or passing in a 1-D array implies vector
# norms are being computed, so also using `ord='fro'`
- # or `ord='nuc'` raises a ValueError.
+ # or `ord='nuc'` or any other string raises a ValueError.
assert_raises(ValueError, norm, A, 'fro', 0)
assert_raises(ValueError, norm, A, 'nuc', 0)
assert_raises(ValueError, norm, [3, 4], 'fro', None)
assert_raises(ValueError, norm, [3, 4], 'nuc', None)
+ assert_raises(ValueError, norm, [3, 4], 'test', None)
# Similarly, norm should raise an exception when ord is any finite
# number other than 1, 2, -1 or -2 when computing matrix norms.
diff --git a/numpy/linalg/tests/test_regression.py b/numpy/linalg/tests/test_regression.py
index 1ae207b49..7ed932bc9 100644
--- a/numpy/linalg/tests/test_regression.py
+++ b/numpy/linalg/tests/test_regression.py
@@ -57,8 +57,8 @@ class TestRegression:
assert_array_almost_equal(b, np.zeros((2, 2)))
def test_norm_vector_badarg(self):
- # Regression for #786: Froebenius norm for vectors raises
- # TypeError.
+ # Regression for #786: Frobenius norm for vectors raises
+ # ValueError.
assert_raises(ValueError, linalg.norm, array([1., 2., 3.]), 'fro')
def test_lapack_endian(self):