X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=test%2Fmatrices_test.py;h=e755f31cf30140c8bb80c6f539ba4bb86deaf41c;hb=a098e91f815fbe4b90dbe965262d7ff66cd5f2f7;hp=ce57c7dc32a845b38af4dbad75e362c9e1da9b6f;hpb=f2d4185b8c1a263500848554d4283c7ec3201b1c;p=dunshire.git diff --git a/test/matrices_test.py b/test/matrices_test.py index ce57c7d..e755f31 100644 --- a/test/matrices_test.py +++ b/test/matrices_test.py @@ -2,7 +2,7 @@ Unit tests for the functions in the ``matrices`` module. """ -from copy import copy +from copy import deepcopy from unittest import TestCase from dunshire.matrices import (append_col, append_row, condition_number, @@ -61,16 +61,21 @@ class EigenvaluesTest(TestCase): Tests for the :func:`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 arguments. This test makes sure that our :func:`eigenvalues` function does not do the same. + + We use a ``deepcopy`` here in case the ``copy`` used in the + :func:`eigenvalues` 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()) symmat = mat + mat.trans() - symmat_copy = copy(symmat) + symmat_copy = deepcopy(symmat) dummy = eigenvalues(symmat) self.assertTrue(norm(symmat - symmat_copy) < ABS_TOL) @@ -107,9 +112,14 @@ class EigenvaluesRealPartTest(TestCase): 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. + + 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. """ mat = random_matrix(random_natural()) - mat_copy = copy(mat) + mat_copy = deepcopy(mat) dummy = eigenvalues_re(mat) self.assertTrue(norm(mat - mat_copy) < ABS_TOL)