qml.import_operator

import_operator(qubit_observable, format='openfermion', wires=None, tol=10000000000.0)[source]

Convert an external operator to a PennyLane operator.

We currently support OpenFermion operators: the function accepts most types of OpenFermion qubit operators, such as those corresponding to Pauli words and sums of Pauli words.

Parameters
  • qubit_observable – external qubit operator that will be converted

  • format (str) – the format of the operator object to convert from

  • wires (Wires, list, tuple, dict) – Custom wire mapping used to convert the external qubit operator to a PennyLane operator. For types Wires/list/tuple, each item in the iterable represents a wire label for the corresponding qubit index. For type dict, only int-keyed dictionaries (for qubit-to-wire conversion) are accepted. If None, the identity map (e.g., 0->0, 1->1, ...) will be used.

  • tol (float) – Tolerance in machine epsilon for the imaginary part of the coefficients in qubit_observable. Coefficients with imaginary part less than \((2.22 \cdot 10^{-16}) \cdot \text{tol}\) are considered to be real.

Returns

PennyLane operator representing any operator expressed as linear combinations of Pauli words, e.g., \(\sum_{k=0}^{N-1} c_k O_k\)

Return type

(Operator)

Example

>>> h_pl = import_operator(h_of, format='openfermion')
>>> print(h_pl)
(-0.0548 * X(0 @ X(1) @ Y(2) @ Y(3))) + (0.14297 * Z(0 @ Z(1)))

Contents

Using PennyLane

Release news

Development

API

Internals