Example #1
0
 def test_normalize_inplace_dop(self):
     a = qu.qu([1, -1j], 'dop')
     b = qu.nmlz(a, inplace=True)
     assert_almost_equal(qu.trace(a), 1.0)
     assert_almost_equal(qu.trace(b), 1.0)
Example #2
0
 def test_normalize_inplace_ket(self):
     a = qu.qu([1, -1j], 'ket')
     a.nmlz(inplace=True)
     assert_almost_equal(qu.trace(a.H @ a), 1.0)
Example #3
0
 def test_normalize_inplace_bra(self):
     a = qu.qu([1, -1j], 'bra')
     a.nmlz(inplace=True)
     assert_almost_equal(qu.trace(a @ a.H), 1.0)
Example #4
0
 def test_normalize_bra(self):
     a = qu.qu([1, -1j], 'bra')
     b = qu.nmlz(a, inplace=False)
     assert_almost_equal(qu.trace(b @ b.H), 1.0)
Example #5
0
 def test_normalize_ket(self):
     a = qu.qu([1, -1j], 'ket')
     b = qu.nmlz(a, inplace=False)
     assert_almost_equal(qu.trace(b.H @ b), 1.0)
     assert_almost_equal(qu.trace(a.H @ a), 2.0)
Example #6
0
 def test_simple(self, inpt, outpt, sparse, func):
     a = qu.qu(inpt, sparse=sparse)
     assert (qu.trace(a) == outpt)
Example #7
0
 def test_simple(self, inpt, outpt, sparse, func):
     a = qu.qu(inpt, sparse=sparse)
     assert(qu.trace(a) == outpt)
     assert(a.tr.__code__.co_code == func.__code__.co_code)
Example #8
0
 def test_normalize_dop(self):
     a = qu([1, -1j], 'dop')
     b = nmlz(a, inplace=False)
     assert_almost_equal(trace(b), 1.0)