
    i*              	       H   % 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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rS SKJrJr  S SKJrJrJr  \(       a  S S	KJr   " S
 S\5      rO\R                  r\
" 5       r\" \5      r\" \\05      r\\ \4   \!S'    " S S5      r"Sq#\S-  \!S'   \(       d  \(       d  S\S\ 4S jr$\$" \%" 5       5      r&OSr&S\SS4S jr'\(" 5       r)\(\   \!S'    SS\S\*\/ S4   \/ S4   4   4S jjr+\ RX                  SS\ S\S   4S jj5       r-g)    N)Callable	GeneratorHashable)count)Random)TYPE_CHECKINGAny)WeakValueDictionary)HypothesisWarningInvalidArgument)FREE_THREADED_CPYTHONGRAALPYPYPY)Protocolc                   V    \ rS rSrS\S\S\4S jrS\S\S\4S jrS\S\S\4S jrSrg	)

RandomLike   argskwargsreturnc                     g N selfr   r   s      Z/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/internal/entropy.pyseedRandomLike.seed    s    #    c                     g r   r   r   s      r   getstateRandomLike.getstate!       cr   c                     g r   r   r   s      r   setstateRandomLike.setstate"   r#   r   r   N)	__name__
__module____qualname____firstlineno__r	   r   r!   r%   __static_attributes__r   r   r   r   r      s8    =c=S=S=A#AAAA#AAAr   r   RANDOMS_TO_MANAGEc                       \ rS rSrSS jrSrg)NumpyRandomWrapper1   Nc                     S[         R                  ;   d   eSS KnUR                  R                  U l        UR                  R
                  U l        UR                  R                  U l        g )Nnumpyr   )	sysmodulesnumpy.randomrandomr   	get_stater!   	set_stater%   )r   r1   s     r   __init__NumpyRandomWrapper.__init__2   sL    #++%%% 	LL%%	....r   )r!   r   r%   r   N)r'   r(   r)   r*   r8   r+   r   r   r   r.   r.   1   s    /r   r.   	NP_RANDOMrr   c                 .    [         R                  " U 5      $ r   )r2   getrefcount)r<   s    r   _get_platform_base_refcountr?   B   s    q!!r   c                    [        U S5      (       a"  [        U S5      (       a  [        U S5      (       d  [        SU < S35      eU [        R                  R	                  5       R                  5        Vs/ s H  nU" 5       =nc  M  UPM     sn;   a  g[        (       d  [        (       d  [        R                  " 5         [        R                  " U 5      (       dR  [        R                  " U 5      [        ::  a  [        SU  S35      e[        (       d  [         R"                  " S	[$        S
S9  U [        ['        [(        5      '   gs  snf )a  Register (a weakref to) the given Random-like instance for management by
Hypothesis.

You can pass instances of structural subtypes of ``random.Random``
(i.e., objects with seed, getstate, and setstate methods) to
``register_random(r)`` to have their states seeded and restored in the same
way as the global PRNGs from the ``random`` and ``numpy.random`` modules.

All global PRNGs, from e.g. simulation or scheduling frameworks, should
be registered to prevent flaky tests. Hypothesis will ensure that the
PRNG state is consistent for all test runs, always seeding them to zero and
restoring the previous state after the test, or, reproducibly varied if you
choose to use the :func:`~hypothesis.strategies.random_module` strategy.

``register_random`` only makes `weakrefs
<https://docs.python.org/3/library/weakref.html#module-weakref>`_ to ``r``,
thus ``r`` will only be managed by Hypothesis as long as it has active
references elsewhere at runtime. The pattern ``register_random(MyRandom())``
will raise a ``ReferenceError`` to help protect users from this issue.
This check does not occur for the PyPy interpreter. See the following example for
an illustration of this issue

.. code-block:: python


   def my_BROKEN_hook():
       r = MyRandomLike()

       # `r` will be garbage collected after the hook resolved
       # and Hypothesis will 'forget' that it was registered
       register_random(r)  # Hypothesis will emit a warning


   rng = MyRandomLike()


   def my_WORKING_hook():
       register_random(rng)
r   r!   r%   zr=z' does not have all the required methodsNz `register_random` was passed `r=z` which will be garbage collected immediately after `register_random` creates a weakref to it. This will prevent Hypothesis from managing this PRNG. See the docs for `register_random` for more details.zIt looks like `register_random` was passed an object that could be garbage collected immediately after `register_random` creates a weakref to it. This will prevent Hypothesis from managing this PRNG. See the docs for `register_random` for more details.   )
stacklevel)hasattrr   r,   datacopyvaluesr   r   gccollectget_referrersr2   r>   _PLATFORM_REF_COUNTReferenceErrorr   warningswarnr   next_RKEY)r<   refr5   s      r   register_randomrR   M   s   P Av71j#9#9ga>T>T$KLMM$))..07799CeOF 	9 
 	DGG


""q!%88$6qc :   +* Q &  &'d5k"Es   3EE_known_random_state_hashesr   c                    ^ ^ [        T [        5      (       d   eST s=::  a  S:  d   e   e0 mS[        R                  ;   a'  [        c   [        5       =q[        [        [        5      '   SU U4S jjnSU4S jjnX4$ )a  Return a pair of functions which respectively seed all and restore
the state of all registered PRNGs.

This is used by the core engine via `deterministic_PRNG`, and by users
via `register_random`.  We support registration of additional random.Random
instances (or other objects with seed, getstate, and setstate methods)
to force determinism on simulation or scheduling frameworks which avoid
using the global random state.  See e.g. #1709.
r   l        r1   c                    > T(       a   e[         R                  R                  5       R                  5        H  u  pU" 5       nUc  M  UR	                  5       TU '   U [
        :X  aG  [        5       nUR                  T5        [        R                  [        UR	                  5       5      5        UR                  T5        M     g r   )r,   rE   rF   itemsr!   _global_random_rkeyr   r   rS   addhash)krQ   r<   dummy_randomr   statess       r   seed_all)get_seeder_and_restorer.<locals>.seed_all   s    z  (,,11399;FAAy

F1I''  &x!!$'*..tL4I4I4K/LM FF4L- <r   c                     > TR                  5        HX  u  p[        R                  U 5      nUc  M  U [        :X  a  [        R                  [        U5      5        UR                  U5        MZ     TR                  5         g r   )	rV   r,   getrW   rS   rX   rY   r%   clear)rZ   stater<   r\   s      r   restore_all,get_seeder_and_restorer.<locals>.restore_all   s_    HA!%%a(Ay''*..tE{;JJu ' 	r   r:   )	
isinstanceintr2   r3   r;   r.   r,   rO   rP   )r   r]   rc   r\   s   `  @r   get_seeder_and_restorerrg      sz     dC    u "F#++9K9MMI)$u+6' 'R
   r   )NNNc              #   V  #    [         R                  R                  R                  cT  [	        5       [         R                  R                  l        [        [         R                  R                  R                  5        [        U 5      u  pU" 5          Sv   U" 5         g! U" 5         f = f7f)a-  Context manager that handles random.seed without polluting global state.

See issue #1266 and PR #1295 for details and motivation - in short,
leaving the global pseudo-random number generator (PRNG) seeded is a very
bad idea in principle, and breaks all kinds of independence assumptions
in practice.
N)
hypothesiscorethreadlocal_hypothesis_global_randomr   rR   rg   )r   r]   rc   s      r   deterministic_PRNGrm      sm      	##==E@F
##=
33MMN3D9HJs   BB)B B)	B&&B))r   ).
contextlibrH   r5   r2   rM   collections.abcr   r   r   	itertoolsr   r   typingr   r	   weakrefr
   hypothesis.coreri   hypothesis.errorsr   r   hypothesis.internal.compatr   r   r   r   r   rP   rO   rW   r,   rf   __annotations__r.   r;   r?   objectrK   rR   setrS   tuplerg   contextmanagerrm   r   r   r   <module>r{      si    	  
  9 9   % '  @ K KBX B J5k  ;N&!; &sJ7 
	/ 	/  $	: # 	"s "s "
 6fh? M'z M'd M'j (+u CH , K!
K!
8BHxD112K!\ S 3C)D  r   