
    i8              	          % S SK r S SKrS SKrS SKrS SKrS SKJrJr  S SKJ	r	J
r
  S SKJr  S SKJr  S SKJrJr  S SKJr  S SKJr  S S	KJr  S S
KJr  \(       a  S SKJr  SrS\S\4S jrS\	S\4S jr S\!S\4S jr"S\#S\4S jr$S\S\4S jr%\" S5      r&\" S5      r'\" S5      r(S\(S\(4S jr)S\!\ RT                     \
\(   -  S\S\
\(   4S jr+\" S 5      S!\,\-S"4   S\.\,\\\-4      4S# j5       r/ " S$ S%5      r0S&r1\0" S'S(S)9r2 " S* S+5      r3\" S,5      =(       d    \Rh                  Rj                  r6\-\7S-'   \S.\-S/\\--  S\-4S0 j5       r8S1\-S/\\--  S\-4S2 jr9g)3    N)OrderedDictabc)CallableSequence)	lru_cache)FunctionType)TYPE_CHECKINGTypeVar)InvalidArgument)int_from_bytes)next_up)_function_key)ConjectureDatal    namereturnc                     [         R                  " U R                  5       5      R                  5       n[	        US S 5      $ )N   )hashlibsha384encodedigestr   )r   hasheds     c/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/internal/conjecture/utils.pycalc_label_from_namer   "   s0    ^^DKKM*113F&!*%%    fc                     [        U [        5      (       a  [        [        U SS95      $ [        U [        5      (       a  [        U 5      $  [        U 5      $ ! [         a    [        [	        U 5      5      s $ f = f)NT)ignore_name)
isinstancer   calc_label_from_hashr   typecalc_label_from_cls	Exception)r   s    r   calc_label_from_callabler$   '   sg    !\""#M!$FGG	At		"1%%	0'** 	0&tAw//	0s   

A A65A6clsc                 ,    [        U R                  5      $ N)r   __qualname__)r%   s    r   r"   r"   5   s     0 011r   objc                 <    [        [        [        U 5      5      5      $ r'   )r   strhash)r)   s    r   r    r    9   s    DI//r   labelsc                  <    SnU  H  nUS-  [         -  nX-  nM     U$ )Nr      )
LABEL_MASK)r-   labells      r   combine_labelsr3   =   s-    E!z)
  Lr   za sample() in Samplerzone more from many()Tvc                     U $ r'    )r5   s    r   identityr8   L   s    Hr   valuesstrategy_namec                    S[         R                  ;   ac  [        U [         R                  S   R                  5      (       a7  U R                  S:w  a&  [        SU R                   SU R                   S35      eOG[        U [        [        R                  [        R                  45      (       d  [        SU < SU S35      e[        U [        5      (       a  U $ [        U 5      $ )	Nnumpyr/   zPOnly one-dimensional arrays are supported for sampling, and the given value has z dimensions (shape z).  This array would give samples of array slices instead of elements!  Use np.ravel(values) to convert to a one-dimensional array, or tuple(values) if you want to sample slices.zCannot sample from z\ because it is not an ordered collection. Hypothesis goes to some length to ensure that the a   strategy has stable results between runs. To replay a saved example, the sampled values must have the same iteration order on every run - ruling out sets, dicts, etc due to hash randomization. Most cases can simply use `sorted(values)`, but mixed types or special values such as math.nan require careful handling - and note that when simplifying an example, Hypothesis treats earlier values as simpler.)sysmodulesr   ndarrayndimr   shaper   r   r   enumEnumMetarangetuple)r9   r:   s     r   check_samplerF   P   s     #++*VS[[5I5Q5Q"R"R;;!!++1;;-7J<<. !))   cllDMM JKK!& ,AAN P;;

 
	
 &%   =r   @   weights.c                    [        U 5      n[        U5       Vs/ s H  o"S S /PM	     nn[        U 5      n[        U5      nU" S5      nU" S5      n/ n/ n	U  V
s/ s H  oU-  PM	     nn
/ n[	        U5       HS  u  p-X-  nUR                  U5        US:X  a	  XcU   S'   M)  US:  a  UR                  U5        MB  U	R                  U5        MU     [        R                  " U5        [        R                  " U	5        U(       a  U	(       a  [        R                  " U5      n[        R                  " U	5      nUU:w  d   eUU   U:  d   eX?   S   b   eUX?   S'   X|U   -
  X?   S'   UU   X   -   U-
  UU'   UU   S:  a  [        R                  " UU5        O(UU   S:X  a  XcU   S'   O[        R                  " U	U5        U(       a	  U	(       a  M  U	(       a  XcU	R                  5          S'   U	(       a  M  U(       a  XcUR                  5          S'   U(       a  M  / nU H  u  nnn[        U[        5      (       d   e[        U[        5      (       d  Ub   eUc   eUc  UR                  UUU45        MV  UU:  a  UR                  UUX}-
  45        Mt  UR                  UUU45        M     UR                  5         U$ s  snf s  sn
f )Nr   r/      )lenrD   sumr!   	enumerateappendheapqheapifyheappopheappushpopr   intsort)rH   nitabletotalnum_typezeroonesmalllargewprobabilitiesscaled_probabilitiesalternate_chancescaledlohi	new_tablebase	alternates                       r   compute_sampler_tableri   p   s   GAFKAh,Oht_hE,OLEE{HA;D
1+CEE(/01YM0(*(7!%##F+Q;!HQKaZLLOLLO  8 
MM%	MM%
E]]5!]]5!Rxx#B'#---y|###	!"55	! $';'??$R   #a'NN5"%!"%*"IaLNN5"%% EE&  $eiik1 %
 $eiik1 % /1I-2)i)$$$$$)S))Y->>>+++dD*:;<is/EFGdI/?@A .3 NN{ -P 1s   J6J;c                   z    \ rS rSr% Sr\\\\\4      \	S'   SS.S\
\   S\4S jjrS	S
.SSS\S	-  S\4S jjrSrg	)Sampler   a  Sampler based on Vose's algorithm for the alias method. See
http://www.keithschwarz.com/darts-dice-coins/ for a good explanation.

The general idea is that we store a table of triples (base, alternate, p).
base. We then pick a triple uniformly at random, and choose its alternate
value with probability p and else choose its base value. The triples are
chosen so that the resulting mixture has the right distribution.

We maintain the following invariants to try to produce good shrinks:

1. The table is in lexicographic (base, alternate) order, so that choosing
   an earlier value in the list always lowers (or at least leaves
   unchanged) the value.
2. base[i] < alternate[i], so that shrinking the draw always results in
   shrinking the chosen element.
rX   TobserverH   rn   c                B    X l         [        [        U5      5      U l        g r'   )rn   ri   rE   rX   )selfrH   rn   s      r   __init__Sampler.__init__   s    *5>:
r   N)forceddatar   rs   r   c                  ^ U R                   (       a  UR                  [        5        Tc  S O[        U4S jU R                   5       5      nUR                  U R                  UU R                   S9u  pEnS nTb   TU:H  =(       a    US:  nTU:X  d	  U(       d   eUR                  UUU R                   S9nU R                   (       a  UR                  5         U(       a  Tb  UT:X  d	   TU45       eU$ Tb  UT:X  d	   TU45       eU$ )Nc              3   ^   >#    U  H"  u  pnTU:X  d  TU:X  d  M  US :  d  M  XU4v   M$     g7f)r   Nr7   ).0rg   rh   rb   rs   s       r   	<genexpr>!Sampler.sample.<locals>.<genexpr>   sB      ;E7T&6T>f	&9 4>NQR>R 4"23;Es   ---rs   rn   r   )rn   
start_spanSAMPLE_IN_SAMPLER_LABELnextrX   choicedraw_boolean	stop_span)	rp   rt   rs   forced_choicerg   rh   rb   forced_use_alternateuse_alternates	     `      r   sampleSampler.sample   s    <<OO34 ~  ;?::  	 -1KKJJ LL -8 -
))
  $ $*Y#6#O;Ka;O T>%999))'LL * 

 <<NN>Y&%8M69:MM8>TV^Cfd^C3Kr   )rn   rX   )__name__
__module__r(   __firstlineno____doc__listrE   rT   float__annotations__r   boolrq   r   __static_attributes__r7   r   r   rk   rk      sh    " c3o&''DH ; ;T ; "	** d
	*
 
* *r   rk   )r          rG      )g      @g       @      ?r   g      ?Frm   c                       \ rS rSrSrSSS.SSS\S	\\-  S
\\-  S\S-  S\SS4S jjrS r	S r
S\4S jrSS\S-  SS4S jjrSrg)many   a  Utility class for collections. Bundles up the logic we use for "should I
keep drawing more values?" and handles starting and stopping examples in
the right place.

Intended usage is something like:

elements = many(data, ...)
while elements.more():
    add_stuff_to_result()
NTrz   rt   r   min_sizemax_sizeaverage_sizers   rn   r   c                
   SUs=::  a  Us=::  a  U::  d   e   eUb  X%s=::  a  U::  d   e   eX l         X0l        Xl        XPl        [	        XB-
  X2-
  5      U l        SU l        SU l        SU l        SU l	        SU l
        X`l        g )Nr   F)r   r   rt   forced_size_calc_p_continue
p_continuecount
rejectionsdrawn
force_stoprejectedrn   )rp   rt   r   r   r   rs   rn   s          r   rq   many.__init__  s     H8888888~!?x!???!???  	!*<+BHDWX

r   c                 \    U R                   (       a  U R                  R                  5         g g r'   )rn   rt   r   )rp   s    r   r   many.stop_span   s    <<II! r   c                 ^    U R                   (       a  U R                  R                  U5        g g r'   )rn   rt   r{   )rp   r1   s     r   r{   many.start_span$  s     <<II  ' r   c                    U R                   (       a  U R                  5         SU l         SU l        U R                  [        5        U R
                  U R                  :X  a  U R                  U R
                  :  nOSnU R                  (       a,  U R                  b  U R                  U R                  :X  d   eSnO`U R                  U R
                  :  a  SnOCU R                  U R                  :  a  SnO&U R                  b  U R                  U R                  :  nU R                  R                  U R                  UU R                  S9nU(       a  U =R                  S-  sl        gU R                  5         g)z7Should I draw another element to add to the collection?TFNrz   r/   )r   r   r   r{   ONE_FROM_MANY_LABELr   r   r   r   r   rt   r   r   rn   )rp   should_continueforced_results      r   more	many.more(  s   ::NN
+,==DMM) #jj4==8O M ''/4::AQAQ3QQQ %dmm+ $t}}, %!!- $

T-=-= ="ii44$ 5 O JJ!OJNNr   whyc                 T   U R                   S:  d   eU =R                   S-  sl         U =R                  S-  sl        SU l        U R                  [        SSU R                   -  5      :  a>  U R                   U R                  :  a  U R
                  R                  U5        gSU l        gg)zReject the last example (i.e. don't count it towards our budget of
elements because it's not going to go in the final collection).r   r/   T   rJ   N)r   r   r   maxr   rt   mark_invalidr   )rp   r   s     r   rejectmany.rejectO  s     zzA~~

a
1 ??SA

N33zzDMM)		&&s+"&	 4r   )r   rt   r   r   r   r   r   rn   r   r   r   r'   )r   r   r(   r   r   rT   r   r   rq   r   r{   r   r+   r   r   r7   r   r   r   r      s    	$ "  +	
 Ek d
  
0"(%d %N'#* ' ' 'r   r   g        SMALLEST_POSITIVE_FLOATdesired_avgr   c                 d   X::  d   X45       eX:X  a  gSSSU -   -  -
  nUS:X  d  U[         R                  :X  a  SUs=::  a  S:  d   U5       e   U5       eU$ SUs=:  a  S:  d   U5       e   U5       e[        X!5      U :  a'  US-  nU[        :  a  [        nO[        X!5      U :  a  M'  SnU [        X!5      -
  S:  aF  SUs=:  a  U:  d
  O   X#45       eX#-   S-  n[        XA5      U ::  a  UnOUnU [        X!5      -
  S:  a  MF  SUs=:  a  S:  d   U5       e   U5       e[        X!5      U ::  d   eU$ )zCReturn the p_continue which will generate the desired average size.r   r/   r   g-C6?g{Gz?rJ   )mathinf_p_continue_to_avgr   )r   r   r   re   mids        r   r   r   b  sx    ";[$;;"SAO,,JQ(dhh.J"".J.".J."zA)z))z) Z
2[
@f

 //0J Z
2[
@ 
B
*:@
@4
G:""4Z$44"!#c,;JB *:@
@4
G zA)z))z)j3{BBBr   r   c                 8    U S:  a  U$ SSU -
  -  S-
  SX-  -
  -  $ )zBReturn the average_size generated by this p_continue and max_size.r/   r   r7   )r   r   s     r   r   r     s/    Q1z>"Q&1z/C+CDDr   ):rB   r   rO   r   r=   collectionsr   r   collections.abcr   r   	functoolsr   typesr   typingr	   r
   hypothesis.errorsr   hypothesis.internal.compatr   hypothesis.internal.floatsr   "hypothesis.internal.lambda_sourcesr   #hypothesis.internal.conjecture.datar   r0   r+   rT   r   r$   r!   r"   objectr    r3   r|   r   r4   r8   EnumrF   rE   r   r   ri   rk   	INT_SIZESINT_SIZES_SAMPLERr   
float_infominr   r   r   r   r7   r   r   <module>r      s       
 ( .   ) - 5 . <B 
&s &s &
0 0S 02T 2c 20f 0 0C C  //FG *+AB  CL a Ohqk):=a[@ 2?5#4 ?eCeO>T9U ? ?DB BJ !	5uE `' `'F ")!C1C1C  C #% #3; #5 # #LE5 EC%K EE Er   