diff options
author | Aron Ahmadia <aron@ahmadia.net> | 2012-07-17 16:59:50 -0500 |
---|---|---|
committer | Aron Ahmadia <aron@ahmadia.net> | 2012-07-17 16:59:50 -0500 |
commit | a419a3036aa8202d00eb6e857c79d66adc56bed0 (patch) | |
tree | 4a73e6fff2ee13b35c154c43bd7b58bb6c2af633 /numpy/linalg/tests/test_linalg.py | |
parent | 7316499dd60baa7bb260875b79f7d22be491c986 (diff) | |
parent | 6c772fab57934d24b66638ea5001eb02d1662f5e (diff) | |
download | numpy-a419a3036aa8202d00eb6e857c79d66adc56bed0.tar.gz |
Merge branch 'master' of https://github.com/numpy/numpy into patch-2
Diffstat (limited to 'numpy/linalg/tests/test_linalg.py')
-rw-r--r-- | numpy/linalg/tests/test_linalg.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index 2a2ec3da5..623939863 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -3,7 +3,9 @@ import sys import numpy as np -from numpy.testing import * +from numpy.testing import (TestCase, assert_, assert_equal, assert_raises, + assert_array_equal, assert_almost_equal, + run_module_suite) from numpy import array, single, double, csingle, cdouble, dot, identity from numpy import multiply, atleast_2d, inf, asarray, matrix from numpy import linalg @@ -451,6 +453,19 @@ class TestMatrixRank(object): yield assert_equal, matrix_rank(1), 1 +def test_reduced_rank(): + # Test matrices with reduced rank + rng = np.random.RandomState(20120714) + for i in range(100): + # Make a rank deficient matrix + X = rng.normal(size=(40, 10)) + X[:, 0] = X[:, 1] + X[:, 2] + # Assert that matrix_rank detected deficiency + assert_equal(matrix_rank(X), 9) + X[:, 3] = X[:, 4] + X[:, 5] + assert_equal(matrix_rank(X), 8) + + class TestQR(TestCase): def test_qr_empty(self): a = np.zeros((0,2)) |