
    i}                         S SK Jr  S SKJrJrJr  S SKJr  S SKJ	r	  S\\
   S\\
\
/\\
   4   4S jrS\S\\
\
/\\
   4   4S	 jr " S
 S5      r " S S5      r " S S5      r\" 5       rS \l         " S S\5      rg)    )defaultdict)CallableIterableSequence)Random)LazySequenceCopyprefixreturnc                 J   ^  S[         S[         S[        [            4U 4S jjnU$ )zdSelect choices starting from ``prefix```,
preferring to move left then wrapping around
to the right.depthnr
   c              3      >#    U [        T5      :  a=  TU    nX!:  a  US-
  n[        USS5       S h  vN   [        US-
  US5       S h  vN   g [        US-
  SS5       S h  vN   g  N6 N  N	7f)N   )lenrange)r   r   ir	   s      r/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/internal/conjecture/shrinking/choicetree.pyselection_order/prefix_selection_order.<locals>.selection_order   sr     3v;uAvEQB'''QUAr***QUB+++ (*+s3   /A/A)A/
A+A/#A-$A/+A/-A/intr   )r	   r   s   ` r   prefix_selection_orderr      s)    ,s ,s ,x} ,     randomc                 J   ^  S[         S[         S[        [            4U 4S jjnU$ )z#Select choices uniformly at random.r   r   r
   c              3      >#    [        [        U5      5      nU(       a8  TR                  S[        U5      5      nUR	                  U5      v   U(       a  M7  g g 7fNr   )r   r   	randranger   pop)r   r   pendingr   r   s       r   r   /random_selection_order.<locals>.selection_order)   sB     "58,  CL1A++a.  gs   AAAr   )r   r   s   ` r   random_selection_orderr#   &   s)    !s !s !x} ! r   c                       \ rS rSrSrSSS\\\/\\   4   4S jrS 4S\	\   S	\\/\
4   S
\4S jjrS
\	\   4S jrSrg)Chooser2   z4A source of nondeterminism for use in shrink passes.tree
ChoiceTreer   c                 P    X l         UR                  /U l        / U l        SU l        g )NF)_Chooser__selection_orderroot_Chooser__node_trail_Chooser__choices_Chooser__finished)selfr'   r   s      r   __init__Chooser.__init__5   s&    
 "1!YYK$&r   c                     g)NT )xs    r   <lambda>Chooser.<lambda>B   s    Tr   values	conditionr
   c                    U R                   (       a   eU R                  S   nUR                  c   [        U5      Ul        [        U5      Ul        UR                  S:  d  [        U5      S:X  d   eU R                  [        U R                  5      [        U5      5       H  nUR                  S:X  a    OUR                  U   R                  (       a  M5  X   nU" U5      (       aG  U R                  R                  U5        U R                  R                  UR                  U   5        Us  $ [        UR                  U'   U=R                  S-  sl        M     UR                  S:X  d   e[        e)zReturn some element of values satisfying the condition
that will not lead to an exhausted branch, or raise DeadBranch
if no such element exist".
r   r   r   )r.   r,   live_child_countr   r   r*   r-   children	exhaustedappendDeadNode
DeadBranch)r/   r7   r8   noder   vs         r   chooseChooser.choose?   s-    ??""  $  ($'KD![DF$$q(CK1,<<<''DNN(;S[IA$$)==#---IQ<<NN))!,%%,,T]]1-=>H'/DMM!$))Q.) J $$)))r   c                    SU l         [        U R                  5      [        U R                  5      S-   :X  d   e[	        U R                  5      nSU R                  S   l        [        U R                  5      S:  a  U R                  S   R                  (       a  U R                  R                  5         [        U R                  5      [        U R                  5      :X  d   eU R                  R                  5       nU R                  S   n[        UR                  U'   UR
                  c   eU=R
                  S-  sl        [        U R                  5      S:  a   U R                  S   R                  (       a  M  U$ )zvRecord the decisions made in the underlying tree and return
a prefix that can be used for the next Chooser to be used.Tr   r   r   )
r.   r   r,   r-   tupler:   r<   r    r>   r;   )r/   resultr   targets       r   finishChooser.finish_   s2    4$$%T^^)<q)@@@@t~~&12".$##$q(T->->r-B-L-L!!#t(()S-@@@@""$A&&r*F!)FOOA**666##q(# $##$q(T->->r-B-L-L-L r   )	__choices
__finished__node_trail__selection_orderN)__name__
__module____qualname____firstlineno____doc__r   r   r   r0   r   boolrB   rH   __static_attributes__r3   r   r   r%   r%   2   st    >   "3*hsm";<  ,: SE4K( 
	@ r   r%   c                   v    \ rS rSrSrSS jr\S\4S j5       rS\	\
\
/\\
   4   S\	\/S4   S\\
   4S	 jrS
rg)r(   t   zRecords sequences of choices made during shrinking so that we
can track what parts of a pass has run. Used to create Chooser
objects that are the main interface that a pass uses to make
decisions about what to do.
r
   Nc                 "    [        5       U l        g N)TreeNoder+   r/   s    r   r0   ChoiceTree.__init__{   s    J	r   c                 .    U R                   R                  $ rX   )r+   r<   rZ   s    r   r<   ChoiceTree.exhausted~   s    yy"""r   r   fc                     U R                   (       a   e[        X5      n U" U5        UR                  5       $ ! [         a     UR                  5       $ f = frX   )r<   r%   r?   rH   )r/   r   r^   choosers       r   stepChoiceTree.step   sW    
 >>!!$0	gJ ~~  	~~	s   8 
AA)r+   r
   N)rN   rO   rP   rQ   rR   r0   propertyrS   r<   r   r   r   r%   r   ra   rT   r3   r   r   r(   r(   t   si     #4 # # !3*hsm";<  WItO$  
#	 r   r(   c                   6    \ rS rSrSS jr\S\4S j5       rSrg)rY      r
   Nc                 H    [        [        5      U l        S U l        S U l        g rX   )r   rY   r;   r:   r   rZ   s    r   r0   TreeNode.__init__   s    -8-B,0!r   c                      U R                   S:H  $ r   )r:   rZ   s    r   r<   TreeNode.exhausted   s    $$))r   )r;   r:   r   rc   )	rN   rO   rP   rQ   r0   rd   rS   r<   rT   r3   r   r   rY   rY      s"    "
 *4 * *r   rY   c                       \ rS rSrSrg)r?      r3   N)rN   rO   rP   rQ   rT   r3   r   r   r?   r?      s    r   r?   N)collectionsr   collections.abcr   r   r   r   r   )hypothesis.internal.conjecture.junkdrawerr   r   r   r#   r%   r(   rY   r>   r:   	Exceptionr?   r3   r   r   <module>rq      s    $ 8 8  FSMsCj(3-'((	6 	hSz8C=7P.Q 	? ?D   :* * : 	 	r   