"""
-Unit tests for the functions in the ``matrices`` module.
+Unit tests for the functions in the :mod:`dunshire.matrices` module.
"""
from copy import deepcopy
class AppendRowTest(TestCase):
"""
- Tests for the :func:`append_row` function.
+ Tests for the :func:`dunshire.matrices.append_row` function.
"""
def test_new_dimensions(self):
class EigenvaluesTest(TestCase):
"""
- Tests for the :func:`eigenvalues` function.
+ Tests for the :func:`dunshire.matrices.eigenvalues` function.
"""
- def test_eigenvalues_input_untouched(self):
+ def test_eigenvalues_input_not_clobbered(self):
"""
The eigenvalue functions provided by CVXOPT/LAPACK like to
overwrite the matrices that you pass into them as
def test_eigenvalues_of_symmat_are_real(self):
"""
A real symmetric matrix has real eigenvalues, so if we start
- with a symmetric matrix, then the two functions :func:`eigenvalues`
- and :func:`eigenvalues_re` should agree on it.
+ with a symmetric matrix, then the two functions
+ :func:`dunshire.matrices.eigenvalues` and
+ :func:`dunshire.matrices.eigenvalues_re` should agree on it.
"""
mat = random_matrix(random_natural())
symmat = mat + mat.trans()
class EigenvaluesRealPartTest(TestCase):
"""
- Tests for the :func:`eigenvalues_re` function.
+ Tests for the :func:`dunshire.matrices.eigenvalues_re` function.
"""
def test_eigenvalues_re_input_not_clobbered(self):
"""
- The eigenvalue functions provided by CVXOPT/LAPACK like to
- overwrite the matrices that you pass into them as
- arguments. This test makes sure that our :func:`eigenvalues_re`
- function does not do the same.
+ The eigenvalue functions provided by CVXOPT/LAPACK like
+ to overwrite the matrices that you pass into them as
+ arguments. This test makes sure that our
+ :func:`dunshire.matrices.eigenvalues_re` function does not do
+ the same.
We use a ``deepcopy`` here in case the ``copy`` used in the
- :func:`eigenvalues_re` function is insufficient. If ``copy`` didn't
- work and this test used it too, then this test would pass when
- it shouldn't.
+ :func:`dunshire.matrices.eigenvalues_re` function is
+ insufficient. If ``copy`` didn't work and this test used it too,
+ then this test would pass when it shouldn't.
"""
mat = random_matrix(random_natural())
mat_copy = deepcopy(mat)
class InnerProductTest(TestCase):
"""
- Tests for the :func:`inner_product` function.
+ Tests for the :func:`dunshire.matrices.inner_product` function.
"""
def test_inner_product_with_self_is_norm_squared(self):
"""
- Ensure that the func:`inner_product` and :func:`norm` functions
- are compatible by checking that the square of the norm of a
- vector is its inner product with itself.
+ Ensure that the func:`dunshire.matrices.inner_product` and
+ :func:`dunshire.matrices.norm` functions are compatible by
+ checking that the square of the norm of a vector is its inner
+ product with itself.
"""
vec = random_matrix(random_natural(), 1)
actual = inner_product(vec, vec)
class NormTest(TestCase):
"""
- Tests for the :func:`norm` function.
+ Tests for the :func:`dunshire.matrices.norm` function.
"""
def test_norm_is_nonnegative(self):
class ConditionNumberTest(TestCase):
"""
- Tests for the :func:`condition_number` function.
+ Tests for the :func:`dunshire.matrices.condition_number` function.
"""
def test_condition_number_ge_one(self):