
    z	ia                     P    S r SSKJr  SSKJr  SSKJr  \" 5       r " S S\5      rg)z4Wrap angles pass for respecting target angle bounds.    )TransformationPass)wrap_angles)WrapAngleRegistryc                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )
WrapAngles   a6	  Wrap angles outside the bound specified in the target.

This pass will check all the gates in the circuit and check if there are any gates outside the
bound specified in the target. If any gates outside the bound are identified, the callback in
the target will be called to substitute the gate outside the bound with an equivalent subcircuit.
This pass does not run on gates that are parameterized, even if the gate has unparameterized
parameters outside a specified bound. If there are parameterized gates in the circuit they will
be ignored by this pass as bound angles are necessary to transform the gate. For example the below
example demonstrates how the callback mechanism and registration works, but doesn't show a useful
transformation, but is simple to follow:

.. plot::
   :alt: Circuit digram of the output from running the WrapAngles pass
   :include-source:

   from qiskit.circuit import Gate, Parameter, Qubit, QuantumCircuit
   from qiskit.circuit.library import RZGate
   from qiskit.dagcircuit import DAGCircuit
   from qiskit.transpiler.passes import WrapAngles
   from qiskit.transpiler import Target, WrapAngleRegistry

   param = Parameter("a")
   circuit = QuantumCircuit(1)
   circuit.rz(6.8, 0)
   target = Target(num_qubits=1)
   target.add_instruction(RZGate(param), angle_bounds=[(0, 0.5)])

   def callback(angles, _qubits):
       angle = angles[0]
       if angle > 0:
           number_of_gates = angle / 0.5
       else:
           number_of_gates = (6.28 - angle) / 0.5
       dag = DAGCircuit()
       dag.add_qubits([Qubit()])
       for _ in range(int(number_of_gates)):
           dag.apply_operation_back(RZGate(0.5), [dag.qubits[0]])
       return dag

   registry = WrapAngleRegistry()
   registry.add_wrapper("rz", callback)
   wrap_pass = WrapAngles(target, registry)
   res = wrap_pass(circuit)
   res.draw("mpl")

Args:
    target (Target): The :class:`.Target` representing the target QPU.
    registry (WrapAngleRegistry): The registry of wrapping functions used
        by the pass to wrap the angles of a gate. If not specified the
        global :data:`.WRAP_ANGLE_REGISTRY` object will be used.

        Unless you are planning to run this pass standalone or are building a
        custom :class:`~.transpiler.PassManager` including this pass you will want
        to rely on :data:`.WRAP_ANGLE_REGISTRY`.
c                 `   > [         TU ]  5         Xl        U(       a  X l        g [        U l        g N)super__init__targetregistryWRAP_ANGLE_REGISTRY)selfr   r   	__class__s      d/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/passes/utils/wrap_angles.pyr   WrapAngles.__init__P   s"    $M/DM    c                 \    [         R                   " XR                  U R                  5        U$ r
   )r   r   r   )r   dags     r   runWrapAngles.runX   s    [[$--@
r   )r   r   r
   )	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classcell__)r   s   @r   r   r      s    6p0 r   r   N)	r   qiskit.transpiler.basepassesr   qiskit._accelerater   'qiskit._accelerate.angle_bound_registryr   r   r    r   r   <module>r$      s+    ; ; * E') C# Cr   