
    i                         S r  " S S5      rg)zKThis module implements various useful common functions for shrinking tasks.c                       \ rS rSrSrSSSS.S jr\S\4S j5       rS\	4S	 jr
S
 rS rS rS\SS4S jr\S 5       rS rS rS rS rS rS rS rS rSrg)Shrinker   zA Shrinker object manages a single value and a predicate it should
satisfy, and attempts to improve it in some direction, making it smaller
and simpler.FN)fulldebugnamec                    U R                   " S0 UD6  U R                  U5      U l        U R                  U l        X0l        SU l        XPl        X l        U R                  U R                  5      1U l	        X@l
        g )N     )setupmake_immutablecurrentinitialr   changesr   _Shrinker__predicatemake_canonical_Shrinker__seendebugging_enabled)selfr   	predicater   r   r   kwargss          n/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/internal/conjecture/shrinking/common.py__init__Shrinker.__init__   sf     	

V**73||		$**4<<89!&    returnc                 ,    [        U R                  5      $ N)lenr   r   s    r   callsShrinker.calls(   s    4;;r   c                     SR                  [        U 5      R                  U R                  c  SOU R                  < S3U R                  U R
                  5      $ )Nz {}({}initial={!r}, current={!r}) z, )formattype__name__r   r   r   r   s    r   __repr__Shrinker.__repr__,   sI    188J))#BDII=);LLLL	
 	
r   c                     g)zuRuns initial setup code.

Convenience function for children that doesn't require messing
with the signature of init.
Nr
   )r   r   s     r   r   Shrinker.setup4       r   c                 \   ^ ^ T R                   " UU" T R                  5      UU 4S j40 UD6  g)zvDelegates shrinking to another shrinker class, by converting the
current value to and from it with provided functions.c                 2   > TR                  T" U 5      5      $ r   )consider)vconvert_fromr   s    r   <lambda>#Shrinker.delegate.<locals>.<lambda>A   s    dmmLO4r   N)call_shrinkerr   )r   other_class
convert_tor0   r   s   `  ` r   delegateShrinker.delegate;   s/     	t||$4	
 		
r   c                 (    UR                   " X#40 UD6$ )z|Calls another shrinker class, passing through the relevant context
variables.

Note we explicitly do not pass through full.
)shrink)r   r4   r   r   r   s        r   r3   Shrinker.call_shrinkerE   s     !!'???r   argsc                 B    U R                   (       a  [        SU /UQ76   g g )NDEBUG)r   print)r   r;   s     r   r   Shrinker.debugN   s    !!'4'$' "r   c                 L    U " X40 UD6nUR                  5         UR                  $ )zsShrink the value ``initial`` subject to the constraint that it
satisfies ``predicate``.

Returns the shrunk value.
)runr   )clsr   r   r   shrinkers        r   r9   Shrinker.shrinkR   s(     w4V4r   c                    U R                  5       (       a  gU R                  (       aA  SnU R                  U:w  a.  U R                  nU R                  5         U R                  U:w  a  M.  OU R                  5         U R	                  S5        g)zRun for an appropriate number of steps to improve the current value.

If self.full is True, will run until no further improvements can
be found.
NCOMPLETE)short_circuitr   r   run_stepr   )r   prevs     r   rA   Shrinker.run]   sf     99D,,$&|| ,,$& MMO

:r   c                 j   U R                  U5      nU R                  SU< 35        U R                  U5      nX R                  U R                  5      :X  a  gX R                  ;   a  gU R                  R                  U5        U R                  U5        U R                  XR                  5      (       d$  U R                  SU< SU R                  < 35        gU R                  U5      (       a1  U R                  SU< 35        U =R                  S-  sl	        Xl        gU R                  SU< S35        g)	zTry using ``value`` as a possible candidate improvement.

Return True if self.current is canonically equal to value after the call, either because
the value was incorporated as an improvement or because it had that value already.
zconsidering TFz	Rejected z  as no better than self.current=zshrinking to    z not satisfying predicate)
r   r   r   r   r   addcheck_invariantsleft_is_betterr   r   )r   value	canonicals      r   r.   Shrinker.considern   s    ##E*

\%+,''.	++DLL99#	"e$""5,,77JJ5)+Lt||oNOE""JJui01LLAL LJJ5)+DEFr   c                     U$ )a  Convert immutable value into a canonical and hashable, but not necessarily equal,
representation of itself.

This representation is used only for tracking already-seen values, not passed to the
shrinker.

Defaults to just returning the (immutable) input value.
r
   r   rQ   s     r   r   Shrinker.make_canonical   s	     r   c                     U$ )zConvert value into an immutable representation of itself.

It is these immutable versions that the shrinker will work on.

Defaults to just returning the value.
r
   rU   s     r   r   Shrinker.make_immutable   s	     r   c                     g)ztMake appropriate assertions about the value to ensure that it is
valid for this shrinker.

Does nothing by default.
Nr
   rU   s     r   rO   Shrinker.check_invariants   r+   r   c                     g)zPossibly attempt to do some shrinking.

If this returns True, the ``run`` method will terminate early
without doing any more work.
Fr
   r   s    r   rH   Shrinker.short_circuit   s     r   c                     [         e)zhReturns True if the left is strictly simpler than the right
according to the standards of this shrinker.NotImplementedError)r   leftrights      r   rP   Shrinker.left_is_better   
     "!r   c                     [         e)zSRun a single step of the main shrink loop, attempting to improve the
current value.r^   r   s    r   rI   Shrinker.run_step   rc   r   )__predicate__seenr   r   r   r   r   r   )r&   
__module____qualname____firstlineno____doc__r   propertyintr    strr'   r   r6   r3   objectr   classmethodr9   rA   r.   r   r   rO   rH   rP   rI   __static_attributes__r
   r   r   r   r      s     '*  s    
# 

@(6 (d (    "6	"
"r   r   N)rk   r   r
   r   r   <module>rr      s    Rf" f"r   