def to_operator(self): """Test to_operator method.""" labels = ['XI', 'YZ', 'YY', 'ZZ'] coeffs = [-3, 4.4j, 0.2 - 0.1j, 66.12] spp_op = SparsePauliOp(PauliTable.from_labels(labels), coeffs) target = Operator(np.zeros((4, 4), dtype=complex)) for coeff, label in zip(coeffs, labels): target = target + Operator(coeff * pauli_mat(label)) self.assertEqual(spp_op.to_operator(), target)
def to_operator(self): """Test to_operator method.""" labels = ["XI", "YZ", "YY", "ZZ"] coeffs = [-3, 4.4j, 0.2 - 0.1j, 66.12] spp_op = SparsePauliOp(labels, coeffs) target = Operator(np.zeros((4, 4), dtype=complex)) for coeff, label in zip(coeffs, labels): target = target + Operator(coeff * pauli_mat(label)) self.assertEqual(spp_op.to_operator(), target)