コード例 #1
0
 def test_copy(self):
     """Test Operator copy method"""
     mat = np.eye(2)
     orig = Operator(mat)
     cpy = orig.copy()
     cpy._data[0, 0] = 0.0
     self.assertFalse(cpy == orig)
コード例 #2
0
ファイル: test_operator.py プロジェクト: Cryoris/qiskit-terra
 def test_copy(self):
     """Test Operator copy method"""
     mat = np.eye(2)
     with self.subTest("Deep copy"):
         orig = Operator(mat)
         cpy = orig.copy()
         cpy._data[0, 0] = 0.0
         self.assertFalse(cpy == orig)
     with self.subTest("Shallow copy"):
         orig = Operator(mat)
         clone = copy.copy(orig)
         clone._data[0, 0] = 0.0
         self.assertTrue(clone == orig)