Skip to content

Commit

Permalink
Merge pull request #343 from matthew-brett/fix-matrix-rank-test
Browse files Browse the repository at this point in the history
BF: restore and fix original matrix rank test
  • Loading branch information
bthirion committed Aug 25, 2015
2 parents 9000d34 + db917cf commit d31366b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nipy/algorithms/utils/tests/test_matrices.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
""" Test functions for utils.matrices """
from __future__ import print_function

import numpy as np

import scipy.linalg as spl

from ..matrices import (matrix_rank, full_rank, pos_recipr, recipr0)

from nose.tools import (assert_true, assert_equal, assert_false,
Expand All @@ -27,11 +31,11 @@ def test_matrix_rank():
rng = np.random.RandomState(20120613)
X = rng.normal(size=(40, 10))
X[:, 0] = X[:, 1] + X[:, 2]
S = np.linalg.svd(X, compute_uv=False)
S = spl.svd(X, compute_uv=False)
eps = np.finfo(X.dtype).eps
assert_equal(matrix_rank(X, tol=0), 10)
assert_equal(matrix_rank(X, tol=S.min() - eps), 10)
assert_equal(matrix_rank(X, tol=S.min() + eps), 10)
assert_equal(matrix_rank(X, tol=S.min() + eps), 9)


def test_full_rank():
Expand Down

0 comments on commit d31366b

Please sign in to comment.