
    z	i ,                        S r SSKJr  SSKJrJr  SSKrSSKJ	r	  SSK
JrJr  SSKJr  SSKJrJr  SS	KJr   " S
 S\\5      rg)zBlueprint circuit object.    )annotations)ABCabstractmethodN)CircuitData)QuantumRegisterClassicalRegister)ParameterView)QuantumCircuit_copy_metadata)deprecate_funcc                    ^  \ rS rSrSr\" SSSS9SS.S)U 4S	 jjj5       r\S*S+S jj5       r\S,S j5       r	S,S jr
\U 4S j5       r\R                  S 5       r\U 4S j5       rS-U 4S jjrU 4S jr\S.U 4S jj5       r\S/U 4S jj5       rS0SS.U 4S jjjr     S1S
SSS.U 4S jjjrS2S3U 4S jjjrS rS rU 4S jrS0U 4S jjrS0U 4S jjrU 4S  jrU 4S! jrU 4S" jrS2U 4S# jjr S4S$S%.     S5S& jjjrS4S6S' jjr S(r!U =r"$ )7BlueprintCircuit   a  Blueprint circuit object.

In many applications it is necessary to pass around the structure a circuit will have without
explicitly knowing e.g. its number of qubits, or other missing information. This can be solved
by having a circuit that knows how to construct itself, once all information is available.

This class provides an interface for such circuits. Before internal data of the circuit is
accessed, the ``_build`` method is called. There the configuration of the circuit is checked.
z2.1zCThere is no direct replacement other than the QuantumCircuit class.zin Qiskit 3.0)sinceadditional_msgremoval_timelineN)namec               l   > SU l         [        TU ]  " USU06  / U l        / U l        SU l        SU l         g)zCreate a new blueprint circuit.Fr   TN)_is_initializedsuper__init___qregs_cregs	_is_built)selfr   regs	__class__s      a/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/blueprintcircuit.pyr   BlueprintCircuit.__init__%   s<      %$*T*-//1#    Tc                    [         e)aj  Check if the current configuration allows the circuit to be built.

Args:
    raise_on_failure: If True, raise if the configuration is invalid. If False, return
        False if the configuration is invalid.

Returns:
    True, if the configuration is valid. Otherwise, depending on the value of
    ``raise_on_failure`` an error is raised or False is returned.
)NotImplementedError)r   raise_on_failures     r   _check_configuration%BlueprintCircuit._check_configuration3   s
     "!r    c                V    U R                   (       a  gU R                  5         SU l         g)zBuild the circuit.NT)r   r$   r   s    r   _buildBlueprintCircuit._buildA   s#     >> 	!!#r    c                z   U R                   R                  nU R                   R                  n[        U R                   R                  U R                   R
                  5      U l         U H  nU R                   R                  U5        M      U H  nU R                   R                  U5        M      SU l        SU l	        g)z%Invalidate the current circuit build.r   FN)
_dataqregscregsr   qubitsclbitsadd_qregadd_cregglobal_phaser   )r   r,   r-   qregcregs        r   _invalidateBlueprintCircuit._invalidateK   s     

  

   !2!2DJJ4E4EF
DJJ% DJJ% r    c                R   > U R                   (       d  U R                  $ [        TU ]  $ )z<A list of the quantum registers associated with the circuit.)r   r   r   r,   r   r   s    r   r,   BlueprintCircuit.qregsY   s"     ##;;w}r    c                    U R                   (       d  g/ U l        / U l        [        U R                  R
                  S9U l        SU l        SU l        U R                  " U6   g)z6Set the quantum registers associated with the circuit.N)r/   r   F)	r   r   	_ancillasr   r+   r/   r2   r   add_register)r   r,   s     r   r,   r9   `   sS     ##  

(9(9:
5!r    c                Z   > U R                   (       d  U R                  5         [        TU ]  $ )zThe circuit data (instructions and context).

Returns:
    QuantumCircuitData: a list-like object containing the :class:`.CircuitInstruction`\ s
    for each instruction.
)r   r(   r   datar8   s    r   r>   BlueprintCircuit.datao   s     ~~KKMw|r    c                d   > U R                   (       d  U R                  5         [        TU ]  X5      $ N)r   r(   r   	decompose)r   gates_to_decomposerepsr   s      r   rB   BlueprintCircuit.decompose{   s$    ~~KKMw !3::r    c                f   > U R                   (       d  U R                  5         [        TU ]  " U0 UD6$ rA   )r   r(   r   drawr   argskwargsr   s      r   rG   BlueprintCircuit.draw   '    ~~KKMw|T,V,,r    c                Z   > U R                   (       d  U R                  5         [        TU ]  $ )z/The number of parameter objects in the circuit.)r   r(   r   num_parametersr8   s    r   rN   BlueprintCircuit.num_parameters   s      ~~KKMw%%r    c                Z   > U R                   (       d  U R                  5         [        TU ]  $ )u  The parameters defined in the circuit.

This attribute returns the :class:`.Parameter` objects in the circuit sorted
alphabetically. Note that parameters instantiated with a :class:`.ParameterVector`
are still sorted numerically.

Examples:

    The snippet below shows that insertion order of parameters does not matter.

    .. code-block:: python

        >>> from qiskit.circuit import QuantumCircuit, Parameter
        >>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
        >>> circuit = QuantumCircuit(1)
        >>> circuit.rx(b, 0)
        >>> circuit.rz(elephant, 0)
        >>> circuit.ry(a, 0)
        >>> circuit.parameters  # sorted alphabetically!
        ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])

    Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers.
    The literal "10" comes before "2" in strict alphabetical sorting.

    .. code-block:: python

        >>> from qiskit.circuit import QuantumCircuit, Parameter
        >>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
        >>> circuit = QuantumCircuit(1)
        >>> circuit.u(*angles, 0)
        >>> circuit.draw()
           ┌─────────────────────────────┐
        q: ┤ U(angle_1,angle_2,angle_10) ├
           └─────────────────────────────┘
        >>> circuit.parameters
        ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])

    To respect numerical sorting, a :class:`.ParameterVector` can be used.

    .. code-block:: python

        >>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
        >>> x = ParameterVector("x", 12)
        >>> circuit = QuantumCircuit(1)
        >>> for x_i in x:
        ...     circuit.rx(x_i, 0)
        >>> circuit.parameters
        ParameterView([
            ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
            ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
            ..., ParameterVectorElement(x[11])
        ])


Returns:
    The sorted :class:`.Parameter` objects in the circuit.
)r   r(   r   
parametersr8   s    r   rQ   BlueprintCircuit.parameters   s!    v ~~KKMw!!r    F_standard_gatec               b   > U R                   (       d  U R                  5         [        TU ]  XX4S9$ )NrS   )r   r(   r   _append)r   instruction_qargs_cargsrT   r   s        r   rV   BlueprintCircuit._append   s&    ~~KKMw{FZZr    copy	var_remapinline_capturesc               p   > U R                   (       d  U R                  5         [        T
U ]  UUUUUUUUSS9	$ )NFr[   )r   r(   r   compose)r   otherr.   r/   frontinplacewrapr\   r]   r^   r   s             r   r`   BlueprintCircuit.compose   sF     ~~KKMw!  

 
	
r    c                `   > U R                   (       d  U R                  5         [        TU ]  US9$ )N)	annotated)r   r(   r   inverse)r   rg   r   s     r   rh   BlueprintCircuit.inverse   s$    ~~KKMw33r    c                ,    [        U R                  5      $ rA   )lenr>   r'   s    r   __len__BlueprintCircuit.__len__   s    499~r    c                     U R                   U   $ rA   )r>   )r   items     r   __getitem__BlueprintCircuit.__getitem__   s    yyr    c                f   > U R                   (       d  U R                  5         [        TU ]  " U0 UD6$ rA   )r   r(   r   sizerH   s      r   rs   BlueprintCircuit.size   rL   r    c                `   > U R                   (       d  U R                  5         [        TU ]  XS9$ N)label)r   r(   r   to_instructionr   parameter_maprw   r   s      r   rx   BlueprintCircuit.to_instruction   s&    ~~KKMw%m%AAr    c                `   > U R                   (       d  U R                  5         [        TU ]  XS9$ rv   )r   r(   r   to_gatery   s      r   r}   BlueprintCircuit.to_gate   s$    ~~KKMw}::r    c                f   > U R                   (       d  U R                  5         [        TU ]  " U0 UD6$ rA   )r   r(   r   depthrH   s      r   r   BlueprintCircuit.depth  s'    ~~KKMw}d-f--r    c                b   > U R                   (       d  U R                  5         [        TU ]  5       $ rA   )r   r(   r   	count_opsr8   s    r   r   BlueprintCircuit.count_ops
  s!    ~~KKMw ""r    c                b   > U R                   (       d  U R                  5         [        TU ]  5       $ rA   )r   r(   r   num_nonlocal_gatesr8   s    r   r   #BlueprintCircuit.num_nonlocal_gates  s!    ~~KKMw)++r    c                `   > U R                   (       d  U R                  5         [        TU ]  US9$ )N)unitary_only)r   r(   r   num_connected_components)r   r   r   s     r   r   )BlueprintCircuit.num_connected_components  s&    ~~KKMw/\/JJr    alike	vars_modec                   [        / U R                  QU R                  Q7XR                  S.6n[	        X5        U R
                  R                  US9Ul        U$ )a  Return an empty :class:`.QuantumCircuit` of same size and metadata.

See also :meth:`.QuantumCircuit.copy_empty_like` for more details on copied metadata.

Args:
    name: Name for the copied circuit. If None, then the name stays the same.
    vars_mode: The mode to handle realtime variables in.

Returns:
    An empty circuit of same dimensions. Note that the result is no longer a
    :class:`.BlueprintCircuit`.
)r   r2   r   )r
   r,   r-   r2   r   r+   copy_empty_like)r   r   r   cpys       r   r    BlueprintCircuit.copy_empty_like  sO      adjja4::aDO`O`at!JJ...C	
r    c                    U R                   (       d  U R                  5         [        R                  " U 5      n[	        X5        U R                   Ul         U R
                  R                  5       Ul        Ub  Xl        U$ )zCopy the blueprint circuit.

Args:
    name: Name to be given to the copied circuit. If None, then the name stays the same.

Returns:
    A deepcopy of the current blueprint circuit, with the specified name.
)r   r(   _copyr\   r   r+   r   )r   r   r   s      r   r\   BlueprintCircuit.copy.  sW     ~~KKMjjt!JJOO%	H
r    )r;   r   r+   r   r   r   r2   )r   
str | NonereturnNone)T)r#   boolr   r   )r   r   )N   )r   int)r   r	   )NN)NNFFF)F)rg   r   rA   )r   r   r   strr   r
   )r   r   r   r   )#__name__
__module____qualname____firstlineno____doc__r   r   r   r$   r(   r5   propertyr,   setterr>   rB   rG   rN   rQ   rV   r`   rh   rl   rp   rs   rx   r}   r   r   r   r   r   r\   __static_attributes____classcell__)r   s   @r   r   r      s    \(
 26 $ $
$ " "     \\" " 	 	;
-
 & & <" <"|[u [ [ 
 
 
64 4
-
B
;
.
#
,
K "&;B58	* r    r   )r   
__future__r   abcr   r   r\   r   qiskit._accelerate.circuitr   qiskit.circuitr   r   qiskit.circuit.parametertabler	   qiskit.circuit.quantumcircuitr
   r   qiskit.utils.deprecationr   r    r    r   <module>r      s2      " #  2 = 7 H 3i~s ir    