# WeightedPauliOperator¶

class WeightedPauliOperator(paulis, basis=None, z2_symmetries=None, atol=1e-12, name=None)[source]

Bases: qiskit.aqua.operators.legacy.base_operator.LegacyBaseOperator

Weighted Pauli Operator

Parameters
• paulis (List[List[Union[complex, Pauli]]]) – the list of weighted Paulis, where a weighted pauli is composed of a length-2 list and the first item is the weight and the second item is the Pauli object.

• basis (Optional[List[Tuple[object, List[int]]]]) – the grouping basis, each element is a tuple composed of the basis and the indices to paulis which belong to that group. e.g., if tpb basis is used, the object will be a pauli. By default, the group is equal to non-grouping, each pauli is its own basis.

• z2_symmetries (Optional[Z2Symmetries]) – recording the z2 symmetries info

• atol (float) – the threshold used in truncating paulis

• name (Optional[str]) – the name of operator.

Methods

 add Perform self + other. anticommute_with Anti commutes with chop Eliminate the real and imagine part of weight in each pauli by threshold. commute_with Commutes with construct_evaluation_circuit Construct the circuits for evaluation, which calculating the expectation . copy Get a copy of self evaluate_with_result This method can be only used with the circuits generated by the construct_evaluation_circuit() method with the same circuit_name_prefix name since the circuit names are tied to some meanings. evaluate_with_statevector param quantum_state a quantum state. evaluation_instruction param statevector_mode will it be run on statevector simulator or not evolve Carry out the eoh evolution for the operator under supplied specifications. evolve_instruction Carry out the eoh evolution for the operator under supplied specifications. from_dict Load paulis from a dictionary to construct an Operator. from_file Load paulis in a file to construct an Operator. from_list Create a WeightedPauliOperator via a pair of list. is_empty Check Operator is empty or not. multiply Perform self * other, and the phases are tracked. print_details Print out the operator in details. reorder_paulis Reorder the paulis based on the basis and return the reordered paulis. rounding Rounding the weight. simplify Merge the paulis whose bases are identical and the pauli with zero coefficient would be removed. sub Perform self - other. to_dict Save operator to a dict in pauli representation. to_file Save operator to a file in pauli representation. to_opflow to op flow

Attributes

atol

get atol

basis

returns basis

name

returns name

num_qubits

Number of qubits required for the operator.

Returns

number of qubits

Return type

int

paulis

get paulis

z2_symmetries

returns z2 symmetries