Skip to main contentIBM Quantum Documentation
This page is from the dev version of Qiskit SDK. Go to the stable version

EquivalenceLibrary

class qiskit.circuit.EquivalenceLibrary

GitHub

Bases: BaseEquivalenceLibrary

A library providing a one-way mapping of Gates to their equivalent implementations as QuantumCircuits.


Attributes

graph


Methods

add_equivalence

add_equivalence(gate, equivalent_circuit)

Add a new equivalence to the library. Future queries for the Gate will include the given circuit, in addition to all existing equivalences (including those from base).

Parameterized Gates (those including qiskit.circuit.Parameters in their Gate.params) can be marked equivalent to parameterized circuits, provided the parameters match.

Parameters

  • gate (Gate) – A Gate instance.
  • equivalent_circuit (QuantumCircuit) – A circuit equivalently implementing the given Gate.

draw

draw(filename=None)

GitHub

Draws the equivalence relations available in the library.

Parameters

filename (str) – An optional path to write the output image to if specified this method will return None.

Returns

Drawn equivalence library as an

IPython SVG if in a jupyter notebook, or as a PIL.Image otherwise.

Return type

PIL.Image or IPython.display.SVG

Raises

InvalidFileError – if filename is not valid.

get_entry

get_entry(gate)

Gets the set of QuantumCircuits circuits from the library which equivalently implement the given Gate.

Parameterized circuits will have their parameters replaced with the corresponding entries from Gate.params.

Parameters

gate (Gate) – A Gate instance.

Returns

A list of equivalent QuantumCircuits. If empty,

library contains no known decompositions of Gate.

Returned circuits will be ordered according to their insertion in the library, from earliest to latest, from top to base. The ordering of the StandardEquivalenceLibrary will not generally be consistent across Qiskit versions.

Return type

List[QuantumCircuit]

has_entry

has_entry(gate)

Check if a library contains any decompositions for gate.

Parameters

gate (Gate) – A Gate instance.

Returns

True if gate has a known decomposition in the library.

False otherwise.

Return type

Bool

keys

keys()

node_index

node_index(key)

set_entry

set_entry(gate, entry)

Set the equivalence record for a Gate. Future queries for the Gate will return only the circuits provided.

Parameterized Gates (those including qiskit.circuit.Parameters in their Gate.params) can be marked equivalent to parameterized circuits, provided the parameters match.

Parameters

  • gate (Gate) – A Gate instance.
  • entry (List['QuantumCircuit']) – A list of QuantumCircuits, each equivalently implementing the given Gate.
Was this page helpful?
Report a bug or request content on GitHub.