German
Sprachen
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

qiskit.dagcircuit.DAGCircuit.replace_block_with_op

DAGCircuit.replace_block_with_op(node_block, op, wire_pos_map, cycle_check=True)[Quellcode]

Replace a block of nodes with a single node.

This is used to consolidate a block of DAGOpNodes into a single operation. A typical example is a block of gates being consolidated into a single UnitaryGate representing the unitary matrix of the block.

Parameter
  • node_block (List[DAGNode]) – A list of dag nodes that represents the node block to be replaced

  • op (qiskit.circuit.Operation) – The operation to replace the block with

  • wire_pos_map (Dict[Qubit, int]) – The dictionary mapping the qarg to the position. This is necessary to reconstruct the qarg order over multiple gates in the combined single op node.

  • cycle_check (bool) – When set to True this method will check that replacing the provided node_block with a single node would introduce a cycle (which would invalidate the DAGCircuit) and will raise a DAGCircuitError if a cycle would be introduced. This checking comes with a run time penalty. If you can guarantee that your input node_block is a contiguous block and won’t introduce a cycle when it’s contracted to a single node, this can be set to False to improve the runtime performance of this method.

Verursacht

DAGCircuitError – if cycle_check is set to True and replacing the specified block introduces a cycle or if node_block is empty.

Rückgabe

The op node that replaces the block.

Rückgabetyp

DAGOpNode