qiskit-documentation/docs/api/qiskit/0.24/qiskit.aqua.operators.legac...

635 lines
43 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: TPBGroupedWeightedPauliOperator
description: API reference for qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator
---
<span id="qiskit-aqua-operators-legacy-tpbgroupedweightedpaulioperator" />
# qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator
<Class id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.8/qiskit/aqua/operators/legacy/tpb_grouped_weighted_pauli_operator.py" signature="TPBGroupedWeightedPauliOperator(paulis, basis, z2_symmetries=None, atol=1e-12, name=None, grouping_func=None, kwargs=None)" modifiers="class">
TPB Grouped Weighted Pauli Operator
**Parameters**
* **paulis** (*list\[\[complex,* [*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.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** (*list\[tuple(object, \[int])], optional*) the grouping basis, each element is a tuple composed of the basis and the indices to paulis which are belonged 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** ([*Z2Symmetries*](qiskit.aqua.operators.legacy.Z2Symmetries "qiskit.aqua.operators.legacy.Z2Symmetries")) recording the z2 symmetries info
* **atol** (*float, optional*) the threshold used in truncating paulis
* **name** (*str, optional*) the name of operator.
* **grouping\_func** (*Callable, optional*) Function to group paulis
* **kwargs** (*dict*) Optional parameters for grouping function call
### \_\_init\_\_
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.__init__" signature="__init__(paulis, basis, z2_symmetries=None, atol=1e-12, name=None, grouping_func=None, kwargs=None)">
**Parameters**
* **paulis** (*list\[\[complex,* [*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.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** (*list\[tuple(object, \[int])], optional*) the grouping basis, each element is a tuple composed of the basis and the indices to paulis which are belonged 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** ([*Z2Symmetries*](qiskit.aqua.operators.legacy.Z2Symmetries "qiskit.aqua.operators.legacy.Z2Symmetries")) recording the z2 symmetries info
* **atol** (*float, optional*) the threshold used in truncating paulis
* **name** (*str, optional*) the name of operator.
* **grouping\_func** (*Callable, optional*) Function to group paulis
* **kwargs** (*dict*) Optional parameters for grouping function call
</Function>
## Methods
| | |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`__init__`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.__init__ "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.__init__")(paulis, basis\[, z2\_symmetries, …]) | **param paulis**the list of weighted Paulis, where a weighted pauli is |
| [`add`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.add "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.add")(other\[, copy]) | Perform self + other. |
| [`anticommute_with`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.anticommute_with "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.anticommute_with")(other) | Anti commutes with |
| [`chop`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.chop "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.chop")(\[threshold, copy]) | Eliminate the real and imagine part of weight in each pauli by threshold. |
| [`commute_with`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.commute_with "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.commute_with")(other) | Commutes with |
| [`construct_evaluation_circuit`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.construct_evaluation_circuit "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.construct_evaluation_circuit")(wave\_function, …) | Construct the circuits for evaluation, which calculating the expectation \<psi\|H\|psi>. |
| [`copy`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.copy "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.copy")() | Get a copy of self |
| [`evaluate_with_result`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluate_with_result "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluate_with_result")(result, statevector\_mode) | This method can be only used with the circuits generated by the [`construct_evaluation_circuit()`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.construct_evaluation_circuit "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.construct_evaluation_circuit") method with the same circuit\_name\_prefix name since the circuit names are tied to some meanings. |
| [`evaluate_with_statevector`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluate_with_statevector "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluate_with_statevector")(quantum\_state) | **param quantum\_state**a quantum state. |
| [`evaluation_instruction`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluation_instruction "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluation_instruction")(statevector\_mode\[, …]) | **param statevector\_mode**will it be run on statevector simulator or not |
| [`evolve`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evolve "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evolve")(\[state\_in, evo\_time, …]) | Carry out the eoh evolution for the operator under supplied specifications. |
| [`evolve_instruction`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evolve_instruction "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evolve_instruction")(\[evo\_time, …]) | Carry out the eoh evolution for the operator under supplied specifications. |
| [`from_dict`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_dict "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_dict")(dictionary\[, before\_04]) | Load paulis from a dictionary to construct an Operator. |
| [`from_file`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_file "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_file")(file\_name\[, before\_04]) | Load paulis in a file to construct an Operator. |
| [`from_list`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_list "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_list")(paulis\[, weights, name]) | Create a WeightedPauliOperator via a pair of list. |
| [`is_empty`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.is_empty "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.is_empty")() | Check Operator is empty or not. |
| [`multiply`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.multiply "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.multiply")(other) | Perform self \* other. |
| [`print_details`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.print_details "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.print_details")() | Print out the operator in details. |
| [`reorder_paulis`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.reorder_paulis "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.reorder_paulis")() | Reorder the paulis based on the basis and return the reordered paulis. |
| [`rounding`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.rounding "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.rounding")(decimals\[, copy]) | Rounding the weight. |
| [`simplify`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.simplify "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.simplify")(\[copy]) | Merge the paulis whose bases are identical and the pauli with zero coefficient would be removed. |
| [`sorted_grouping`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.sorted_grouping "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.sorted_grouping")(weighted\_pauli\_operator\[, …]) | Largest-Degree First Coloring for grouping paulis. |
| [`sub`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.sub "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.sub")(other\[, copy]) | Perform self - other. |
| [`to_dict`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_dict "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_dict")() | Save operator to a dict in pauli representation. |
| [`to_file`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_file "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_file")(file\_name) | Save operator to a file in pauli representation. |
| [`to_opflow`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_opflow "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_opflow")(\[reverse\_endianness]) | to op flow |
| [`unsorted_grouping`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.unsorted_grouping "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.unsorted_grouping")(weighted\_pauli\_operator) | Greedy and unsorted grouping paulis. |
## Attributes
| | |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| [`atol`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.atol "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.atol") | get atol |
| [`basis`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.basis "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.basis") | returns basis |
| [`grouping_func`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.grouping_func "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.grouping_func") | returns grouping function |
| [`kwargs`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.kwargs "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.kwargs") | returns kwargs |
| [`name`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.name "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.name") | returns name |
| [`num_groups`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.num_groups "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.num_groups") | returns number of groups |
| [`num_qubits`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.num_qubits "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.num_qubits") | Number of qubits required for the operator. |
| [`paulis`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.paulis "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.paulis") | get paulis |
| [`z2_symmetries`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.z2_symmetries "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.z2_symmetries") | returns z2 symmetries |
### add
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.add" signature="add(other, copy=False)">
Perform self + other.
**Parameters**
* **other** ([*WeightedPauliOperator*](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")) to-be-combined operator
* **copy** (*bool*) working on a copy or self, if False, the results are written back to self.
**Returns**
operator
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
</Function>
### anticommute\_with
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.anticommute_with" signature="anticommute_with(other)">
Anti commutes with
</Function>
### atol
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.atol">
get atol
</Attribute>
### basis
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.basis">
returns basis
</Attribute>
### chop
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.chop" signature="chop(threshold=None, copy=False)">
Eliminate the real and imagine part of weight in each pauli by threshold. If paulis weight is less then threshold in both real and imaginary parts, the pauli is removed.
<Admonition title="Note" type="note">
If weight is real-only, the imaginary part is skipped.
</Admonition>
**Parameters**
* **threshold** (*float*) the threshold is used to remove the paulis
* **copy** (*bool*) chop on a copy or self
**Returns**
**if copy is True, the original operator is unchanged; otherwise,**
the operator is mutated.
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
</Function>
### commute\_with
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.commute_with" signature="commute_with(other)">
Commutes with
</Function>
### construct\_evaluation\_circuit
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.construct_evaluation_circuit" signature="construct_evaluation_circuit(wave_function, statevector_mode, qr=None, cr=None, use_simulator_snapshot_mode=False, circuit_name_prefix='')">
Construct the circuits for evaluation, which calculating the expectation \<psi|H|psi>.
At statevector mode: to simplify the computation, we do not build the whole circuit for \<psi|H|psi>, instead of that we construct an individual circuit \<psi|, and a bundle circuit for H|psi>
**Parameters**
* **wave\_function** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) the quantum circuit.
* **statevector\_mode** (*bool*) indicate which type of simulator are going to use.
* **qr** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*, optional*) the quantum register associated with the input\_circuit
* **cr** ([*ClassicalRegister*](qiskit.circuit.ClassicalRegister "qiskit.circuit.ClassicalRegister")*, optional*) the classical register associated with the input\_circuit
* **use\_simulator\_snapshot\_mode** (*bool, optional*) if aer\_provider is used, we can do faster evaluation for pauli mode on statevector simulation
* **circuit\_name\_prefix** (*str, optional*) a prefix of circuit name
**Returns**
**a list of quantum circuits and each circuit with a unique name:**
circuit\_name\_prefix + Pauli string
**Return type**
list\[[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")]
**Raises**
* [**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") if Operator is empty
* [**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") if quantum register is not provided explicitly and cannot find quantum register with q as the name
* [**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") The provided qr is not in the wave\_function
</Function>
### copy
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.copy" signature="copy()">
Get a copy of self
</Function>
### evaluate\_with\_result
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluate_with_result" signature="evaluate_with_result(result, statevector_mode, use_simulator_snapshot_mode=False, circuit_name_prefix='')">
This method can be only used with the circuits generated by the [`construct_evaluation_circuit()`](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.construct_evaluation_circuit "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.construct_evaluation_circuit") method with the same circuit\_name\_prefix name since the circuit names are tied to some meanings.
Calculate the evaluated value with the measurement results.
**Parameters**
* **result** (*qiskit.Result*) the result from the backend.
* **statevector\_mode** (*bool*) indicate which type of simulator are used.
* **use\_simulator\_snapshot\_mode** (*bool*) if aer\_provider is used, we can do faster evaluation for pauli mode on statevector simulation
* **circuit\_name\_prefix** (*str*) a prefix of circuit name
**Returns**
the mean value float: the standard deviation
**Return type**
float
**Raises**
[**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") if Operator is empty
</Function>
### evaluate\_with\_statevector
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluate_with_statevector" signature="evaluate_with_statevector(quantum_state)">
**Parameters**
**quantum\_state** (*numpy.ndarray*) a quantum state.
**Returns**
the mean value float: the standard deviation
**Return type**
float
**Raises**
[**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") if Operator is empty
</Function>
### evaluation\_instruction
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evaluation_instruction" signature="evaluation_instruction(statevector_mode, use_simulator_snapshot_mode=False)">
**Parameters**
* **statevector\_mode** (*bool*) will it be run on statevector simulator or not
* **use\_simulator\_snapshot\_mode** (*bool*) will it use qiskit aer simulator operator mode
**Returns**
Pauli-instruction pair.
**Return type**
dict
**Raises**
* [**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") if Operator is empty
* [**MissingOptionalLibraryError**](qiskit.aqua.MissingOptionalLibraryError "qiskit.aqua.MissingOptionalLibraryError") qiskit-aer not installed
</Function>
### evolve
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evolve" signature="evolve(state_in=None, evo_time=0, num_time_slices=1, quantum_registers=None, expansion_mode='trotter', expansion_order=1)">
Carry out the eoh evolution for the operator under supplied specifications.
**Parameters**
* **state\_in** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) a circuit describes the input state
* **evo\_time** (*Union(complex, float,* [*Parameter*](qiskit.circuit.Parameter "qiskit.circuit.Parameter")*,* [*ParameterExpression*](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression")*)*) The evolution time
* **num\_time\_slices** (*int*) The number of time slices for the expansion
* **quantum\_registers** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")) The QuantumRegister to build the QuantumCircuit off of
* **expansion\_mode** (*str*) The mode under which the expansion is to be done. Currently support trotter, which follows the expansion as discussed in [http://science.sciencemag.org/content/273/5278/1073](http://science.sciencemag.org/content/273/5278/1073), and suzuki, which corresponds to the discussion in [https://arxiv.org/pdf/quant-ph/0508139.pdf](https://arxiv.org/pdf/quant-ph/0508139.pdf)
* **expansion\_order** (*int*) The order for suzuki expansion
**Returns**
The constructed circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
* [**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") quantum\_registers must be in the provided state\_in circuit
* [**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") if operator is empty
</Function>
### evolve\_instruction
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.evolve_instruction" signature="evolve_instruction(evo_time=0, num_time_slices=1, expansion_mode='trotter', expansion_order=1)">
Carry out the eoh evolution for the operator under supplied specifications.
**Parameters**
* **evo\_time** (*Union(complex, float,* [*Parameter*](qiskit.circuit.Parameter "qiskit.circuit.Parameter")*,* [*ParameterExpression*](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression")*)*) The evolution time
* **num\_time\_slices** (*int*) The number of time slices for the expansion
* **expansion\_mode** (*str*) The mode under which the expansion is to be done. Currently support trotter, which follows the expansion as discussed in [http://science.sciencemag.org/content/273/5278/1073](http://science.sciencemag.org/content/273/5278/1073), and suzuki, which corresponds to the discussion in [https://arxiv.org/pdf/quant-ph/0508139.pdf](https://arxiv.org/pdf/quant-ph/0508139.pdf)
* **expansion\_order** (*int*) The order for suzuki expansion
**Returns**
The constructed QuantumCircuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
* **ValueError** Number of time slices should be a non-negative integer
* **NotImplementedError** expansion mode not supported
* [**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") if operator is empty
</Function>
### from\_dict
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_dict" signature="from_dict(dictionary, before_04=False)" modifiers="classmethod">
Load paulis from a dictionary to construct an Operator. The dictionary must comprise the key paulis having a value which is an array of pauli dicts. Each dict in this array must be represented by label and coeff (real and imag) such as in the following example:
```python
{'paulis':
[
{'label': 'IIII',
'coeff': {'real': -0.33562957575267038, 'imag': 0.0}},
{'label': 'ZIII',
'coeff': {'real': 0.28220597164664896, 'imag': 0.0}},
...
]
}
```
**Parameters**
* **dictionary** (*dict*) dictionary, which contains a list of Paulis and coefficients.
* **before\_04** (*bool*) support the format before Aqua 0.4.
**Returns**
the operator created from the input dictionary.
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
**Raises**
[**AquaError**](qiskit.aqua.AquaError "qiskit.aqua.AquaError") Invalid dictionary
</Function>
### from\_file
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_file" signature="from_file(file_name, before_04=False)" modifiers="classmethod">
Load paulis in a file to construct an Operator.
**Parameters**
* **file\_name** (*str*) path to the file, which contains a list of Paulis and coefficients.
* **before\_04** (*bool*) support the format before Aqua 0.4.
**Returns**
the loaded operator.
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
</Function>
### from\_list
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.from_list" signature="from_list(paulis, weights=None, name=None)" modifiers="classmethod">
Create a WeightedPauliOperator via a pair of list.
**Parameters**
* **paulis** (*list\[*[*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli")*]*) the list of Paulis
* **weights** (*list\[complex], optional*) the list of weights, if it is None, all weights are 1.
* **name** (*str, optional*) name of the operator.
**Returns**
operator
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
**Raises**
**ValueError** The length of weights and paulis must be the same
</Function>
### grouping\_func
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.grouping_func">
returns grouping function
</Attribute>
### is\_empty
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.is_empty" signature="is_empty()">
Check Operator is empty or not.
**Returns**
True if empty, False otherwise
**Return type**
bool
</Function>
### kwargs
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.kwargs">
returns kwargs
</Attribute>
### multiply
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.multiply" signature="multiply(other)">
Perform self \* other.
Note: Grouping of the new operator, will be as per selfs grouping.
**Parameters**
**other** ([*TPBGroupedWeightedPauliOperator*](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator")) an operator
**Returns**
the multiplied operator
**Return type**
[TPBGroupedWeightedPauliOperator](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator")
</Function>
### name
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.name">
returns name
</Attribute>
### num\_groups
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.num_groups">
returns number of groups
</Attribute>
### num\_qubits
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.num_qubits">
Number of qubits required for the operator.
**Returns**
number of qubits
**Return type**
int
</Attribute>
### paulis
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.paulis">
get paulis
</Attribute>
### print\_details
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.print_details" signature="print_details()">
Print out the operator in details.
**Returns**
a formatted string describes the operator.
**Return type**
str
</Function>
### reorder\_paulis
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.reorder_paulis" signature="reorder_paulis()">
Reorder the paulis based on the basis and return the reordered paulis.
**Return type**
`List`\[`List`\[`Union`\[`complex`, `Pauli`]]]
**Returns**
the ordered paulis based on the basis.
</Function>
### rounding
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.rounding" signature="rounding(decimals, copy=False)">
Rounding the weight.
**Parameters**
* **decimals** (*int*) rounding the weight to the decimals.
* **copy** (*bool*) chop on a copy or self
**Returns**
operator
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
</Function>
### simplify
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.simplify" signature="simplify(copy=False)">
Merge the paulis whose bases are identical and the pauli with zero coefficient would be removed.
<Admonition title="Note" type="note">
This behavior of this method is slightly changed, it will remove the paulis whose weights are zero.
</Admonition>
**Parameters**
**copy** (*bool*) simplify on a copy or self
**Returns**
the simplified operator
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
</Function>
### sorted\_grouping
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.sorted_grouping" signature="sorted_grouping(weighted_pauli_operator, method='largest-degree')" modifiers="classmethod">
Largest-Degree First Coloring for grouping paulis.
**Parameters**
* **weighted\_pauli\_operator** ([*WeightedPauliOperator*](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")) the to-be-grouped weighted pauli operator.
* **method** (*str*) only largest-degree is available now.
**Returns**
operator
**Return type**
[TPBGroupedWeightedPauliOperator](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator")
</Function>
### sub
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.sub" signature="sub(other, copy=False)">
Perform self - other.
**Parameters**
* **other** ([*WeightedPauliOperator*](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")) to-be-combined operator
* **copy** (*bool*) working on a copy or self, if False, the results are written back to self.
**Returns**
operator
**Return type**
[WeightedPauliOperator](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")
</Function>
### to\_dict
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_dict" signature="to_dict()">
Save operator to a dict in pauli representation.
**Returns**
a dictionary contains an operator with pauli representation.
**Return type**
dict
</Function>
### to\_file
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_file" signature="to_file(file_name)">
Save operator to a file in pauli representation.
**Parameters**
**file\_name** (*str*) path to the file
</Function>
### to\_opflow
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.to_opflow" signature="to_opflow(reverse_endianness=False)">
to op flow
</Function>
### unsorted\_grouping
<Function id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.unsorted_grouping" signature="unsorted_grouping(weighted_pauli_operator)" modifiers="classmethod">
Greedy and unsorted grouping paulis.
**Parameters**
**weighted\_pauli\_operator** ([*WeightedPauliOperator*](qiskit.aqua.operators.legacy.WeightedPauliOperator "qiskit.aqua.operators.legacy.WeightedPauliOperator")) the to-be-grouped weighted pauli operator.
**Returns**
operator
**Return type**
[TPBGroupedWeightedPauliOperator](#qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator "qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator")
</Function>
### z2\_symmetries
<Attribute id="qiskit.aqua.operators.legacy.TPBGroupedWeightedPauliOperator.z2_symmetries">
returns z2 symmetries
</Attribute>
</Class>