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,
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)
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)