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()))
def test_not_is_identity_zero_qubitoperator(self): self.assertFalse(is_identity(QubitOperator()))
def test_is_identity_bad_type(self): with self.assertRaises(TypeError): is_identity('eleven')
def test_not_is_identity_single_term_qubitoperator(self): self.assertFalse(is_identity(QubitOperator('X1')))
def test_not_is_identity_zero_fermionoperator(self): self.assertFalse(is_identity(FermionOperator()))
def test_not_is_identity_single_term_fermionoperator(self): self.assertFalse(is_identity(FermionOperator('1^')))
def test_is_identity_double_of_unit_qubitoperator(self): self.assertTrue(is_identity(QubitOperator((), 2.)))
def test_is_identity_unit_qubitoperator(self): self.assertTrue(is_identity(QubitOperator(())))
def test_is_identity_double_of_unit_fermionoperator(self): self.assertTrue(is_identity(2. * FermionOperator(())))
def test_is_identity_unit_fermionoperator(self): self.assertTrue(is_identity(FermionOperator(())))