EquivalenceLibrary#

class qiskit.circuit.EquivalenceLibrary(*, base=None)[source]#

Bases: object

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

Create a new equivalence library.

প্যারামিটার:

base (Optional[EquivalenceLibrary]) -- Base equivalence library to be referenced if an entry is not found in this library.

Attributes

graph#

Return graph representing the equivalence library data.

This property should be treated as read-only as it provides a reference to the internal state of the EquivalenceLibrary object. If the graph returned by this property is mutated it could corrupt the the contents of the object. If you need to modify the output PyDiGraph be sure to make a copy prior to any modification.

রিটার্নস:

A graph object with equivalence data in each node.

রিটার্ন টাইপ:

PyDiGraph

Methods

add_equivalence(gate, equivalent_circuit)[source]#

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.

প্যারামিটার:
  • gate (Gate) -- A Gate instance.

  • equivalent_circuit (QuantumCircuit) -- A circuit equivalently implementing the given Gate.

draw(filename=None)[source]#

Draws the equivalence relations available in the library.

প্যারামিটার:

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

রিটার্নস:

Drawn equivalence library as an

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

রিটার্ন টাইপ:

PIL.Image or IPython.display.SVG

রেইজেস:

InvalidFileError -- if filename is not valid.

get_entry(gate)[source]#

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.

প্যারামিটার:

gate (Gate) -- A Gate instance.

রিটার্নস:

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.

রিটার্ন টাইপ:

List[QuantumCircuit]

has_entry(gate)[source]#

Check if a library contains any decompositions for gate.

প্যারামিটার:

gate (Gate) -- A Gate instance.

রিটার্নস:

True if gate has a known decomposition in the library.

False otherwise.

রিটার্ন টাইপ:

Bool

keys()[source]#

Return list of keys to key to node index map.

রিটার্নস:

Keys to the key to node index map.

রিটার্ন টাইপ:

List

node_index(key)[source]#

Return node index for a given key.

প্যারামিটার:

key (Key) -- Key to an equivalence.

রিটার্নস:

Index to the node in the graph for the given key.

রিটার্ন টাইপ:

Int

set_entry(gate, entry)[source]#

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.

প্যারামিটার:
  • gate (Gate) -- A Gate instance.

  • entry (List['QuantumCircuit']) -- A list of QuantumCircuits, each equivalently implementing the given Gate.