From: Michael Orlitzky Date: Tue, 1 Nov 2016 22:01:51 +0000 (-0400) Subject: Improve the two no-clobber tests with deepcopy(). X-Git-Tag: 0.1.0~89 X-Git-Url: https://gitweb.michael.orlitzky.com/?p=dunshire.git;a=commitdiff_plain;h=d988995ea403db9d6f63a7101d31b8d624fc379e Improve the two no-clobber tests with deepcopy(). --- diff --git a/test/matrices_test.py b/test/matrices_test.py index ce57c7d..49d8be9 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, @@ -67,10 +67,15 @@ class EigenvaluesTest(TestCase): 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)