
    z	iO                        S r SSKJr  SSKrSSKJrJrJr  SSKJ	r	  SSK
JrJr  SSKJrJr  SS	KJr  \R$                  " \5      r " S
 S\5      r " S S\5      r " S S\5      rg)zBuilt-in pass flow controllers.    )annotationsN)CallableIterable	Generator)Any   )BaseControllerTask)PassManagerStatePropertySet)PassManagerErrorc                  b   ^  \ rS rSrSr S	SS.   S
U 4S jjjjr\SS j5       rSS jrSr	U =r
$ )FlowControllerLinear   z?A standard flow controller that runs tasks one after the other.Noptionsc               t   > [         TU ]  U5        [        U[        5      (       d  U/n[	        U5      U l        g N)super__init__
isinstancer   tupletasks)selfr   r   	__class__s      ]/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/passmanager/flow_controllers.pyr   FlowControllerLinear.__init__   s1     	!%**GE"',
    c                ,    [        U R                  5      $ z*Alias of tasks for backward compatibility.listr   r   s    r   passesFlowControllerLinear.passes*        DJJr   c              #  :   #    U R                    H  nUv nM	     g 7fr   r   r   statetasks      r   
iter_tasksFlowControllerLinear.iter_tasks/   s     JJDJE s   r(   ) )r   Task | Iterable[Task]r   dict[str, Any] | Nonereturnz
list[Task]r*   r   r2   z'Generator[Task, PassManagerState, None]__name__
__module____qualname____firstlineno____doc__r   propertyr$   r,   __static_attributes____classcell__r   s   @r   r   r      sO    I (*
/ *.	
/$
/ '	
/ 
/     r   r   c                  h   ^  \ rS rSrSr  S	SS.     S
U 4S jjjjr\SS j5       rSS jrSr	U =r
$ )DoWhileController4   a   Run the given tasks in a loop until the ``do_while`` condition on the property set becomes
``False``.

The given tasks will always run at least once, and on iteration of the loop, all the
tasks will be run (with the exception of a failure state being set).Nr   c                  > [         TU ]  U5        [        U[        5      (       d  U/n[	        U5      U l        X l        g r   )r   r   r   r   r   r   do_while)r   r   rB   r   r   s       r   r   DoWhileController.__init__;   s6     	!%**GE"',
 r   c                ,    [        U R                  5      $ r    r!   r#   s    r   r$   DoWhileController.passesI   r&   r   c              #  R  #    U R                   R                  SS5      n[        U5       Hk  nU R                   H  nUv nM	     U R	                  UR
                  5      (       d    g UR                  R                  R                  U R                  5        Mm     [        SU 35      e7f)Nmax_iterationi  z)Maximum iteration reached. max_iteration=)
_optionsgetranger   rB   property_setworkflow_statuscompleted_passesdifference_updater   )r   r*   rG   _r+   s        r   r,   DoWhileController.iter_tasksN   s     ))/4@}%A

"
 #==!3!344!!22DDTZZP & !J=/Z[[s   B%B')rB   r   r.   N)r   r/   rB   Callable[[PropertySet], bool]r   r0   r1   r3   r4   r=   s   @r   r?   r?   4   sa    L (*26!
 *.!$! 0!
 '! !    	\ 	\r   r?   c                  h   ^  \ rS rSrSr  S	SS.     S
U 4S jjjjr\SS j5       rSS jrSr	U =r
$ )ConditionalControllerZ   zmA flow controller runs the pipeline once if the condition is true, or does nothing if the
condition is false.Nr   c                  > [         TU ]  U5        [        U[        5      (       d  U/n[	        U5      U l        X l        g r   )r   r   r   r   r   r   	condition)r   r   rW   r   r   s       r   r   ConditionalController.__init__^   s6     	!%**GE"',
"r   c                ,    [        U R                  5      $ r    r!   r#   s    r   r$   ConditionalController.passesl   r&   r   c              #  |   #    U R                  UR                  5      (       a  U R                   H  nUv nM	     g g 7fr   )rW   rK   r   r)   s      r   r,    ConditionalController.iter_tasksq   s4     >>%,,--

"
 # .s   :<)rW   r   rQ   )r   r/   rW   rR   r   r0   r1   r3   r4   r=   s   @r   rT   rT   Z   s^    
 (*37#
 *.#$# 1#
 '# #    # #r   rT   )r9   
__future__r   loggingcollections.abcr   r   r   typingr   
base_tasksr	   r
   compilation_statusr   r   
exceptionsr   	getLoggerr5   loggerr   r?   rT   r.   r   r   <module>rf      sY    & "  9 9  , = (			8	$> 2#\ #\L#N #r   