
    iC                        S SK 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
Jr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JrJrJr  S S
KJrJ r   S SK!J"r"  S SK#J$r$J%r%J&r&J'r'  S SK(J)r)J*r*  S SK+J,r,J-r-  S\.\/   S\.\0\/\/4      4S jr1S \Rd                  S S.S\/S\/S\/S\*\\\/         4S jjr3S \Rd                  S S.S\/S\/S\/S\*\"   4S jjr4\Rj                   S5S\)S\/S-  S\/S-  S\6\/\74   4S jj5       r8\Rj                  SSSSSS.S j5       r9\Rj                  SSS.S\)S \S-  S!\:S-  S"\:S-  S\6\;\/4   4
S# jj5       r<\Rj                  SSSS$.S\)S!\:S-  S"\:S-  S%\:S\4
S& jj5       r=\Rj                  SSSS$.S\)S!\:S-  S"\:S-  S%\:S\4
S' jj5       r>\Rj                  SSSS(.S) j5       r?\Rj                  SS*.S\)S%\:S\4S+ jj5       r@S6SS*.S, jjrAS6SS*.S- jjrBS.S\R                  " \D5      \R                  " \E5      R                  \R                  5      -  S/.S0\E\   S1\\E\G      S2\S-  S3\*\   SS4
S4 jjrHg)7    N)
CollectionIterableSequence)Any)HealthCheckassumenotesettings
strategies)BackendCannotProceed)batched)ChoiceTypeTchoice_permitted)ConjectureData)COLLECTION_DEFAULT_MAX_SIZEHypothesisProviderPrimitiveProviderwith_register_backend)SMALLEST_SUBNORMALsign_aware_lte)IntervalSet)RuleBasedStateMachine
initializepreconditionrule)DrawFnSearchStrategy)OneCharStringStrategyTextStrategy	intervalsreturnc                 z    [        U 5      S-  (       a  U S S n U R                  5         [        [        U SSS95      $ )N   T)strict)lensortlistr   )r    s    r/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/internal/conjecture/provider_conformance.pybuild_intervalsr*   +   s7    
9~crN	NN	1T233    min_codepointmax_codepointmin_sizer-   r.   r/   c                     [         R                  " [         R                  " X5      SUS-  S9R                  [        5      R                  [
        5      $ )NTr#   )uniquer/   )stlistsintegersmapsortedr*   r,   s      r)   interval_listsr7   3   s@     	KK5\	

 
V	_	r+   c           	      H    [         R                  " [        [        XUS95      $ )Nr,   )r2   buildsr   r7   r,   s      r)   r    r    A   s%     99'x	
 r+   draw	min_value	max_valuec           	         U " [         R                  " [         R                  " XS9[         R                  " SS5      SSS95      n[	        [        UR                  5       5      S:g  5        U " [         R                  " SS5      5      nU[        UR                  5       5      -  nUR                  5        VVs0 s H
  u  pgXgU-  _M     nnn[	        S[        UR                  5       5      s=:*  =(       a    S:*  5        U$ s  5        U$ s  snnf )N)r;   r<   gMbP?      r/   max_sizer   g+?)r2   dictionariesr4   floatsr   sumvaluesitems)r:   r;   r<   weightstargetfactorkvs           r)   integer_weightsrL   L   s    
 
KK)AIIeQ		
G 3w~~ A%&"))E5)*Fc'..*++F)09qf*}G9
5C()22U23N 33N :s   6DF)use_min_valueuse_max_valueuse_shrink_towardsuse_weights
use_forcedc                   S nS nSnS n	Uc  U " [         R                  " 5       5      nUc  U " [         R                  " 5       5      nU " [         R                  " 5       5      nUc+  U(       a"  U(       a  U " [         R                  " 5       5      OSnU(       a  U " [         R                  " 5       5      nU(       a  U " [         R                  " 5       5      OS n
U(       ah  U(       d   eU(       d   eU " [         R                  " U
S95      nU
b  [        Xj5      OUnU " [         R                  " US95      nU " [	        Xg5      5      n	OU(       a  U " [         R                  " U
S95      nU(       aX  / nUb  UR                  U5        U
b  UR                  U
5        U(       a  [        U5      OS nU " [         R                  " US95      nU
b  [        X-
  R                  5       S:  5        UUUU	U
S.$ )Nr   F)r<   r;      )r;   r<   shrink_towardsrG   forced)r2   booleansr4   maxrL   appendr   
bit_length)r:   rM   rN   rO   rP   rQ   r;   r<   rU   rG   rV   min_valmin_valss                r)   integer_constraintsr]   d   s    IINGR[[]+R[[]+bkkm,$1mD% 	 bkkm,$.T"++- DF}}v67	,2,>#i(Iw78	y<=R[[6:;IH$	*!''/c(mTGR[[7;<I'335;< ( r+   )use_min_sizeuse_max_sizerV   r^   r_   c          
         Sn[         nSnUc  U " [        R                  " 5       5      nUc  U " [        R                  " 5       5      nU(       a5  U " [        R                  " SUb  [	        [        U5      U5      OU5      5      nU(       aC  U " [        R                  " Uc  UO[        U[        U5      5      S95      nUc  [	        XTS-   5      nXES.$ )Nr   2   rS   d   r@   )r   r2   rW   r4   minr&   rX   )r:   rV   r^   r_   r/   rA   caps          r)   _collection_constraintsre      s     H*H
CBKKM*BKKM*KKF4F3s6{C0CP
 KK&,n(#hF:T

 >8^4H 77r+   )r^   r_   rQ   rQ   c                    U " [        5       5      nU(       a  U " [        [        U5      5      5      OS nU " [        XQUS95      n[	        U5      S:X  a  SUS'   XES.UE$ )NrV   r^   r_   r   r/   )r    rV   )r    r   r   re   r&   )r:   r^   r_   rQ   interval_setrV   constraintss          r)   string_constraintsrj      sm     	$LCM\/=>?SW  <	
K <A"#J%G;GGr+   c                v    U(       a  U " [         R                  " 5       5      OS nU " [        XAUS95      nSU0UE$ )Nrg   rV   )r2   binaryre   )r:   r^   r_   rQ   rV   ri   s         r)   bytes_constraintsrm      sA     #-T"))+$F<	
K
 f,,,r+   )rM   rN   rQ   c          	         Uc  U " [         R                  " 5       5      nUc  U " [         R                  " 5       5      nU(       a  U " [         R                  " 5       5      OS nU(       a  [        R                  " U5      (       d  UOS n[        R
                  * n[        R
                  n[        nU(       a  [        R                  " U5      (       a  SOU " [         R                  " 5       5      n	U(       a  U " [         R                  " USS95      nU(       a5  Uc  Un
O[        Xe5      (       a  UOUn
U " [         R                  " U
SS95      n[        [        U5      [        U5      5      nUb  US:w  a  [        X5      nUS:  a&  U " [         R                  " S[        US5      SS95      n[        Xg5      (       d   eUUUU	US	.$ )
NTF)r<   	allow_nan)r;   ro   g        r   g      ?)r;   r<   exclude_min)r;   r<   rV   ro   smallest_nonzero_magnitude)r2   rW   rC   mathisnaninfr   r   rX   absrc   )r:   rM   rN   rQ   rV   pivotr;   r<   rq   ro   r[   largest_magnitudes               r)   float_constraintsrx      so    R[[]+R[[]+",T"))+$F!$**V*<*<F4E	II!3#

6(:(:bkkmATIUeDE	=G-i??eYGWFG	C	NC	N;Uc\ 19 1%)II /5 	&
" )////&@ r+   rQ   c          	          U(       a  U " [         R                  " 5       5      OS nU " [         R                  " SSUSL USL S95      nX2S.$ )Nr   r>   TF)rp   exclude_max)prV   )r2   rW   rC   )r:   rQ   rV   r|   s       r)   boolean_constraintsr}   2  s@    $.T"++- DFRYYq!4Vu_UVA%%r+   c                    [         [        [        [        [        S.U    nUc  0 nU" S0 UR                  U 0 5      DSU0D6$ )NbooleanintegerfloatbytesstringrQ    )r}   r]   rx   rm   rj   get)choice_typestrategy_constraintsrQ   strategys       r)   constraints_strategyr   ;  sQ    &&""$ H #!W*..{B?WJWWr+   c                P   ^ ^ / SQn[         R                  " U U4S jU 5       5      $ )Nr   c           
   3      >#    U  H9  n[         R                  " [         R                  " U5      [        UTTS 95      v   M;     g7f)ry   N)r2   tuplesjustr   ).0namer   rQ   s     r)   	<genexpr>+choice_types_constraints.<locals>.<genexpr>J  sB      
 D	 			GGDM ';
S	
 	
 s   AA)r2   one_of)r   rQ   optionss   `` r)   choice_types_constraintsr   H  s(    !SG99 
   r+   r   )context_manager_exceptionsr
   _realize_objectsProviderr   r
   r   c                  ^ ^^  " U 4S jS[         5      n[        SU5         [        U[        R                  /SS9 " U UU4S jS[
        5      5       nUR                  5       R                  5         SSS5        g! , (       d  f       g= f)a  
Test that the given ``Provider`` class conforms to the |PrimitiveProvider|
interface.

For instance, this tests that ``Provider`` does not return out of bounds
choices from any of the ``draw_*`` methods, or violate other invariants
which Hypothesis depends on.

This function is intended to be called at test-time, not at runtime. It is
provided by Hypothesis to make it easy for third-party backend authors to
test their provider. Backend authors wishing to test their provider should
include a test similar to the following in their test suite:

.. code-block:: python

    from hypothesis.internal.conjecture.provider_conformance import run_conformance_test

    def test_conformance():
        run_conformance_test(MyProvider)

If your provider can raise control flow exceptions inside one of the five
``draw_*`` methods that are handled by your provider's
``per_test_case_context_manager``, pass a list of these exceptions types to
``context_manager_exceptions``. Otherwise, ``run_conformance_test`` will
treat those exceptions as fatal errors.
c                   0   > \ rS rSr Y R                  rSrg)7run_conformance_test.<locals>.CopiesRealizationProvideriw  r   N)__name__
__module____qualname____firstlineno__avoid_realization__static_attributes__)r   s   r)   CopiesRealizationProviderr   w  s    $66r+   r   copies_realization)suppress_health_checkbackendc                      >^  \ rS rSrU 4S jr\" \R                  " 5       S9U4S j5       rU4S jr	\
" S 5      \" \" 5       S9S 5       5       r\
" S	 5      \" \" 5       S9S
 5       5       r\
" S 5      \" \" 5       S9S 5       5       r\
" S 5      \" \" 5       S9S 5       5       r\
" S 5      \" \" 5       S9S 5       5       r\
" S 5      \" \R,                  " 5       S9S 5       5       r\
" S 5      \" \R0                  " 5       S9S 5       5       r\
" S 5      \" 5       S 5       5       r\
" S 5      \"  YS9S 5       5       r\
" S 5      \" 5       S 5       5       r\
" S 5      \" \R:                  " SS /5      S!9S" 5       5       rS# rS$r U =r!$ )%5run_conformance_test.<locals>.ProviderConformanceTesti|  c                 "   > [         TU ]  5         g N)super__init__)self	__class__s    r)   r   >run_conformance_test.<locals>.ProviderConformanceTest.__init__  s     "r+   )randomc                    > TR                   S:X  a  [        UTS9nUR                  U l        OT" S 5      U l        U R                  R                  5       U l        U R                  R                  5         SU l        g )N	test_case)r   providerF)lifetimer   r   per_test_case_context_managercontext_manager	__enter__frozen)r   r   datar   s      r)   setup;run_conformance_test.<locals>.ProviderConformanceTest.setup  sa    $$3)(KD$(MMDM$,TNDM'+}}'R'R'T$$$..0#r+   c                   > US	 [        U R                  SU 35      n U" S	0 UD6n[        SU SU 35        [        [        [
        [        [        S.U   n[        XE5      (       d   e[        XB5      (       d   e U$ ! T ag  n[        S[        U5       SU 35         U R                  R                  [        U5      US 5         S nAW$ ! [         a    SU l          S nAg f = fS nAff = f)
NrV   draw_zdrew  )r   r   r   r   r   zcaught exception z  in context_manager_exceptions: Tr   )getattrr   r	   intr   r   strbool
isinstancer   typer   __exit__r   r   )r   r   ri   	draw_funcchoiceexpected_typeer   s          r)   _draw;run_conformance_test.<locals>.ProviderConformanceTest._draw  s
   )#DMMU;-3HI	$&55F5Qvh78#&!&!&"%#'% "%#M &f<<<<+F@@@@  2 $+DG94TUVTWX$,,55d1gq$GG
 	 0 $&*#$$s6   AA> >C+C&&CC#C&"C##C&&C+c                 $    U R                   (       + $ r   r   r   s    r)   <lambda>>run_conformance_test.<locals>.ProviderConformanceTest.<lambda>  
    4;;r+   )ri   c                 (    U R                  SU5        g )Nr   r   r   ri   s     r)   draw_integerBrun_conformance_test.<locals>.ProviderConformanceTest.draw_integer       

9k2r+   c                 $    U R                   (       + $ r   r   r   s    r)   r   r     r   r+   c                 (    U R                  SU5        g )Nr   r   r   s     r)   
draw_float@run_conformance_test.<locals>.ProviderConformanceTest.draw_float       

7K0r+   c                 $    U R                   (       + $ r   r   r   s    r)   r   r     r   r+   c                 (    U R                  SU5        g )Nr   r   r   s     r)   
draw_bytes@run_conformance_test.<locals>.ProviderConformanceTest.draw_bytes  r   r+   c                 $    U R                   (       + $ r   r   r   s    r)   r   r     r   r+   c                 (    U R                  SU5        g )Nr   r   r   s     r)   draw_stringArun_conformance_test.<locals>.ProviderConformanceTest.draw_string  s     

8[1r+   c                 $    U R                   (       + $ r   r   r   s    r)   r   r     r   r+   c                 (    U R                  SU5        g )Nr   r   r   s     r)   draw_booleanBrun_conformance_test.<locals>.ProviderConformanceTest.draw_boolean  r   r+   c                 $    U R                   (       + $ r   r   r   s    r)   r   r     r   r+   )labelc                 :    U R                   R                  U5        g r   )r   
span_start)r   r   s     r)   r   @run_conformance_test.<locals>.ProviderConformanceTest.span_start  s     ((/r+   c                 $    U R                   (       + $ r   r   r   s    r)   r   r     r   r+   )discardc                 :    U R                   R                  U5        g r   )r   span_end)r   r   s     r)   r   >run_conformance_test.<locals>.ProviderConformanceTest.span_end  s     &&w/r+   c                 $    U R                   (       + $ r   r   r   s    r)   r   r     r   r+   c                 L    SU l         U R                  R                  S S S 5        g )NTr   r   r   r   s    r)   freeze<run_conformance_test.<locals>.ProviderConformanceTest.freeze  s#     #$$--dD$?r+   c                     U R                   $ r   r   r   s    r)   r   r         t{{r+   )valuec                      [        X:H  5        U R                  R                  U5      U:X  d   eg ! [         a    [        S5         N9f = f)NF)r   	Exceptionr   realize)r   r   s     r)   r   =run_conformance_test.<locals>.ProviderConformanceTest.realize  sH    "5>* }},,U3u<<< ! "5M"s   1 A	A	c                     U R                   $ r   r   r   s    r)   r   r     r   r+   c                 f    U R                   R                  5       n[        U[        5      (       d   eg r   )r   observe_test_caser   dict)r   observationss     r)   r   Grun_conformance_test.<locals>.ProviderConformanceTest.observe_test_case  s)      $}}>>@!,5555r+   c                     U R                   $ r   r   r   s    r)   r   r     r   r+   test_functionr   r   c                 v    U R                   R                  US9nU H  n[        U[        5      (       a  M   e   g )Nr  )r   observe_information_messagesr   r  )r   r   r  observations       r)   r  Rrun_conformance_test.<locals>.ProviderConformanceTest.observe_information_messages  s@      $}}II%  J   $0K%k48888 $0r+   c                 b    U R                   (       d  U R                  R                  S S S 5        g g r   r   r   s    r)   teardown>run_conformance_test.<locals>.ProviderConformanceTest.teardown  s&    {{((11$dC #r+   )r   r   r   )"r   r   r   r   r   r   r2   randomsr   r   r   r   r]   r   rx   r   rm   r   rj   r   r}   r   r4   r   rW   r   r   r   r   sampled_fromr  r  r   __classcell__)r   r   r   r   s   @r)   ProviderConformanceTestr   |  s   # rzz|,	$ -	$8 671343 5 83 67/121 3 81 67/121 3 81 670232 4 82 671343 5 83 67&0 ' 80 67"++-(0 ) 80 67V@  8@
 23()	= * 4	= 23V6  46 232??O[+IJK9 L 49D Dr+   r  N)r   r   Settingsr   too_slowr   TestCaserunTest)r   r   r
   r   r   r  s   `` `  r)   run_conformance_testr  S  s    H7$6 7 
35N	O	#.#7#7"8(


t	D t	D&; t	D


t	Dl 	 ((*224{ 
P	O	Os   AA;;
B	)NNr   )Irr   syscollections.abcr   r   r   typingr   
hypothesisr   r   r	   r
   r  r   r2   hypothesis.errorsr   hypothesis.internal.compatr   %hypothesis.internal.conjecture.choicer   r   #hypothesis.internal.conjecture.datar   (hypothesis.internal.conjecture.providersr   r   r   r   hypothesis.internal.floatsr   r    hypothesis.internal.intervalsetsr   hypothesis.statefulr   r   r   r   hypothesis.strategiesr   r   'hypothesis.strategies._internal.stringsr   r   r(   r   tupler*   
maxunicoder7   r    	compositer  r   rL   r]   r   r   re   rj   rm   rx   r}   r   r   	from_typeobjectr   flatmapBaseExceptionr  r   r+   r)   <module>r,     s{    
 : :   3 . ?  J 8 U U 8 W4tCy 4T%S/-B 4 CNNTU.1NQHXc]+, CNNTU.1NQK  HL
 4Z;>:	#u* .  ? ?D 
 !% $ 8
 8 $J 8 +	 8
 + 8 
#s(^ 8  8F  !% $H
H +H +	H
 H 	H H0  !% $-
- +- +	-
 - 	- -"  8 8v <A &f &T &c & &
Xu 
Xe  CE $
Vr||D199",,GGd5$%d5 !+4+> ?d5 o	d5
 %S)d5 
d5r+   