def test_is_identity(self):
     self.assertTrue(is_identity(FermionOperator(())))
     self.assertTrue(is_identity(2. * FermionOperator(())))
     self.assertTrue(is_identity(QubitOperator(())))
     self.assertTrue(is_identity(QubitOperator((), 2.)))
     self.assertFalse(is_identity(FermionOperator('1^')))
     self.assertFalse(is_identity(QubitOperator('X1')))
     self.assertFalse(is_identity(FermionOperator()))
     self.assertFalse(is_identity(QubitOperator()))
Example #2
0
 def test_not_is_identity_zero_qubitoperator(self):
     self.assertFalse(is_identity(QubitOperator()))
Example #3
0
 def test_is_identity_bad_type(self):
     with self.assertRaises(TypeError):
         is_identity('eleven')
Example #4
0
 def test_not_is_identity_single_term_qubitoperator(self):
     self.assertFalse(is_identity(QubitOperator('X1')))
Example #5
0
 def test_not_is_identity_zero_fermionoperator(self):
     self.assertFalse(is_identity(FermionOperator()))
Example #6
0
 def test_not_is_identity_single_term_fermionoperator(self):
     self.assertFalse(is_identity(FermionOperator('1^')))
Example #7
0
 def test_is_identity_double_of_unit_qubitoperator(self):
     self.assertTrue(is_identity(QubitOperator((), 2.)))
Example #8
0
 def test_is_identity_unit_qubitoperator(self):
     self.assertTrue(is_identity(QubitOperator(())))
Example #9
0
 def test_is_identity_double_of_unit_fermionoperator(self):
     self.assertTrue(is_identity(2. * FermionOperator(())))
Example #10
0
 def test_is_identity_unit_fermionoperator(self):
     self.assertTrue(is_identity(FermionOperator(())))