
    i:              
          % 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
JrJrJr  S SKJrJrJrJr  S SKJr  S SKJrJrJrJrJrJrJrJrJ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*  \
(       a  S SK+J,r,  \-\\SS4   \.\   \/\   4   r0\\1S'    " S S\5      r2Sr3\4" 5       r5\4\6   \1S'   \" SSS9 " S S5      5       r7S\S\S\S\8S\94
S jr:\" SSS9 " S S5      5       r;\" SSS9 " S S 5      5       r<S!r=\\6   \1S"'   S#\6S$\6S%\6S\64S& jr>S\S\S\64S' jr?S(\@S)\@S\\@SS4   4S* jrAS\S\S\\SS4   4S+ jrB\" SSS9 " S, S-5      5       rC " S. S/5      rD " S0 S1\"5      rEg)2    N)	GeneratorSet)	dataclassfield)Random)TYPE_CHECKINGFinal	TypeAliascast)FlakyReplayFlakyStrategyDefinitionHypothesisExceptionStopTest)floats)	BooleanConstraintsBytesConstraintsChoiceConstraintsTChoiceTChoiceTypeTFloatConstraintsIntegerConstraintsStringConstraintschoice_from_index)ConjectureDataDataObserverStatus)InterestingOrigin)count_between_floatsfloat_to_intint_to_floatsign_aware_lte)RepresentationPrinterChildrenCacheValueTc                       \ rS rSrSrg)PreviouslyUnseenBehaviour4    N)__name__
__module____qualname____firstlineno____static_attributes__r'       f/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/internal/conjecture/datatree.pyr%   r%   4   s    r-   r%   zInconsistent data generation! Data generation behaved differently between different runs. Is your data generation depending on external state?EMPTYT)slotsfrozenc                   :    \ rS rSr% SrS\S'   SSS\SS	4S
 jrSrg	)KilledB   zRepresents a transition to part of the tree which has been marked as
"killed", meaning we want to treat it as not worth exploring, so it will
be treated as if it were completely explored for the purposes of
exhaustion.TreeNode	next_nodepr"   cyclereturnNc                 4    USL d   eUR                  S5        g )NFr3   )textselfr7   r8   s      r.   _repr_pretty_Killed._repr_pretty_K   s    ~~	xr-   r'   )	r(   r)   r*   r+   __doc____annotations__boolr>   r,   r'   r-   r.   r3   r3   B   s*    
 6 t  r-   r3   choice_typevalueconstraintsforcedr9   c                2    U(       a  SOSnU  SU< U SU 3$ )Nz	 [forced]  r'   )rC   rD   rE   rF   forced_markers        r.   _node_prettyrK   P   s(     $*KrM]!E9]O1[MBBr-   Fc                   |    \ rS rSr% Sr\\S'   \\S'   \" SS9r	\
\S4   \S'   \S	\4S
 j5       rSSS\S	S4S jrSrg)Branch[   zORepresents a transition where multiple choices can be made as to what
to drawn.rE   rC   F)reprr5   childrenr9   c                 V    [        U R                  U R                  5      nUS:  d   eU$ )Nr   )compute_max_childrenrC   rE   )r=   max_childrens     r.   rS   Branch.max_childrend   s.    +D,<,<d>N>NOar-   r7   r"   r8   Nc           
         USL d   e[        U R                  R                  5       5       H  u  nu  pEUS:  a  UR                  5         UR	                  [        U R                  X@R                  SS95        UR                  S5         UR                  5         UR                  U5        S S S 5        M     g ! , (       d  f       M  = f)NFr   rF      )
	enumeraterP   itemsbreak_r;   rK   rC   rE   indentpretty)r=   r7   r8   irD   childs         r.   r>   Branch._repr_pretty_j   s    ~~!*4==+>+>+@!AA~1u
FFT--u6F6FuU !
  "B s   "B77
C	r'   )r(   r)   r*   r+   r@   r   rA   r   r   rP   dictr   propertyintrS   rB   r>   r,   r'   r-   r.   rM   rM   [   sb     $#*/U*;Hd7J&';c  

 6 
 t 
  
 r-   rM   c                   J    \ rS rSr% Sr\\S'   \S-  \S'   SSS\S	S4S
 jr	Sr
g)
Conclusionw   z,Represents a transition to a finished state.statusNinteresting_originr7   r"   r8   r9   c                     USL d   eU R                   nUc  SO2SUR                  R                   SUR                   SUR                   3nUR                  SU R                  < U S35        g )NFrH   z, z at :zConclusion ())rg   exc_typer(   filenamelinenor;   rf   )r=   r7   r8   oorigins        r.   r>   Conclusion._repr_pretty_~   sn    ~~## )B2ajj&9&9%:$qzzl!AHH:!V 	 	
dkk_VHA67r-   r'   )r(   r)   r*   r+   r@   r   rA   r   rB   r>   r,   r'   r-   r.   rd   rd   w   s0    6N)D0086 8t 8 8r-   rd   i !MAX_CHILDREN_EFFECTIVELY_INFINITEalphabet_sizemin_sizemax_sizec                    ^  T S:X  a  gT S:X  a  X!-
  S-   $ U[         R                  " T 5      -  nU[         R                  " [        5      :  a  [        $ U 4S jnU" U5      U" US-
  5      -
  U" S5      -  $ )Nr      c                    > TU S-   -  S-
  $ Nrv   r'   )nrr   s    r.   S"_count_distinct_strings.<locals>.S   s    Q'!++r-   )mathlogrq   )rr   rs   rt   log_max_sized_childrenrz   s   `    r.   _count_distinct_stringsr      s{     	!	"Q&& "*DHH],C!C!DHH-N$OO44, hK!HqL/)ad22r-   c                 r   U S:X  aF  [        [        U5      nUS   nUS   nUc  Uc  SS-  S-
  $ Ub
  Ub  X2-
  S-   $ US L US L :w  d   eSS-  $ U S:X  a#  [        [        U5      nUS	   nUS
::  d  US:  a  ggU S:X  a!  [        [        U5      n[	        SUS   US   S9$ U S:X  a2  [        [
        U5      nUS   nUS   nUS   n[	        [        U5      XVS9$ U S:X  a  [        [        U5      nUS   nUS   n	US   n
[        X5      n[        U[        R                  " U
5      * 5      n[        U	[        R                  " U
5      5      nX:  a  U$ U[        X5      -  n[        US5      (       a  [        SU	5      (       a  US-  n[        US5      (       a  [        SU	5      (       a  US-  nU$ [        SU  35      e)Ninteger	min_value	max_valuerW      rv      booleanr7   g      ;g      ?bytes   rs   rt   )rr   rs   rt   string	intervalsfloatsmallest_nonzero_magnitude               zunhandled choice_type )r   r   r   r   r   r   lenr   r   maxflt	next_downminr!   NotImplementedError)rC   rE   r   r   r7   rs   rt   r   min_value_fmax_value_fr   count	min_point	max_points                 r.   rR   rR      s    i-{;,	,	!2c6A: Y%:(1,, T!yD'8999#v			!-{;
?aN3		+[9& , ,
 	

 
	 ,k:z*z*,	&i.8
 	
 
	+[9!+.!+.%01M%N"$[> cmm4N&O%OP	S]]3M%NO	 L%i;;+t,,k1R1RQJE+s++sK0P0PQJE
 6{mD
EEr-   abc              #   v   #    [        [        U 5      [        U5      S-   5       H  n[        U5      v   M     g 7frx   )ranger   r    )r   r   ry   s      r.   _floats_betweenr      s-     <?LOa$781o 9s   79c              #     #    U S:w  a*  [        [        X5      5       H  n[        X U5      v   M     g [        [        U5      nUS   nUS   nUS   n[        US5      (       a  [        SU5      (       a  Sv   [        US5      (       a  [        SU5      (       a  Sv   [        R                  " U5      (       ad  [        R                  " U5      (       a   [        XE* 5      n[        Xc5       S h  vN   g [        U* U5       S h  vN   [        XT5       S h  vN   g [        X55      n[        Xt5       S h  vN   g  NM N9 N( N7f)Nr   r   r   r   r   r   )r   rR   r   r   r   r!   r   is_negativer   r   r   )rC   rE   indexr   r   r   r   r   s           r.   all_childrenr   %  s/     g/IJE#EDD K +[9  ,	,	%01M%N" )T**~dI/N/NJ)S))nS).L.LI??9%%y))	+FG	 +9@@@ +,F+F	RRR*+EQQQ IBI&y<<< A SQ =sH   C,E.D</ED>EE E6E7E>E EEc                   0   \ rS rSr% Sr\" \S9r\\   \	S'   \" \S9r
\\   \	S'   \" \S9r\\   \	S'   \" SSS	9r\\   S-  \	S
'   SrS\-  \-  \-  \	S'   \" SSS	9r\\	S'   \S\\   4S j5       rS\SS4S jrS\SS4S jrS\4S jrSSS\SS4S jrSrg)r5   iP  u  
A node, or collection of directly descended nodes, in a DataTree.

We store the DataTree as a radix tree (https://en.wikipedia.org/wiki/Radix_tree),
which means that nodes that are the only child of their parent are collapsed
into their parent to save space.

Conceptually, you can unfold a single TreeNode storing n values in its lists
into a sequence of n nodes, each a child of the last. In other words,
(constraints[i], values[i], choice_types[i]) corresponds to the single node at index
i.

Note that if a TreeNode represents a choice (i.e. the nodes cannot be compacted
via the radix tree definition), then its lists will be empty and it will
store a `Branch` representing that choce in its `transition`.

Examples
--------

Consider sequentially drawing a boolean, then an integer.

        data.draw_boolean()
        data.draw_integer(1, 3)

If we draw True and then 2, the tree may conceptually look like this.

                  ┌──────┐
                  │ root │
                  └──┬───┘
                  ┌──┴───┐
                  │ True │
                  └──┬───┘
                  ┌──┴───┐
                  │  2   │
                  └──────┘

But since 2 is the only child of True, we will compact these nodes and store
them as a single TreeNode.

                  ┌──────┐
                  │ root │
                  └──┬───┘
                ┌────┴──────┐
                │ [True, 2] │
                └───────────┘

If we then draw True and then 3, True will have multiple children and we
can no longer store this compacted representation. We would call split_at(0)
on the [True, 2] node to indicate that we need to add a choice at 0-index
node (True).

                  ┌──────┐
                  │ root │
                  └──┬───┘
                  ┌──┴───┐
                ┌─┤ True ├─┐
                │ └──────┘ │
              ┌─┴─┐      ┌─┴─┐
              │ 2 │      │ 3 │
              └───┘      └───┘
)default_factoryrE   valueschoice_typesNF)defaultinit_TreeNode__forced
transitionis_exhaustedr9   c                 H    U R                   (       d  [        $ U R                   $ N)r   r/   r=   s    r.   rF   TreeNode.forced  s    }}L}}r-   r]   c                     SUs=::  a  [        U R                  5      :  d   e   eU R                  c  [        5       U l        U R                  R	                  U5        g)z*
Note that the draw at node i was forced.
r   N)r   r   r   setadd)r=   r]   s     r.   mark_forcedTreeNode.mark_forced  sK     A(DKK((((((== EDM!r-   c                 `   XR                   ;   a  [        [        5      eU R                  (       a   eU R                  U   n[        U R                  US-   S U R                  US-   S U R                  US-   S U R                  S9n[        U R                  U   U R                  U   X#0S9U l        U R                  bW  U R                   Vs1 s H  oDU:  d  M
  XA-
  S-
  iM     snUl
        U R                   Vs1 s H  oDU:  d  M
  UiM     snU l
        UR                  5         U R                  US2	 U R                  US2	 U R                  US2	 [        U R                  5      [        U R                  5      s=:X  a!  [        U R                  5      s=:X  a  U:X  d   e   egs  snf s  snf )z
Splits the tree so that it can incorporate a decision at the draw call
corresponding to the node at position i.

Raises FlakyStrategyDefinition if node i was forced.
rv   N)r   rE   r   r   )rE   rC   rP   )rF   r   _FLAKY_STRAT_MSGr   r   r5   r   rE   r   rM   r   check_exhaustedr   )r=   r]   keyr^   js        r.   split_atTreeNode.split_at  s    )*:;;$$$$kk!n**1q573((Q1;;q1uw'	
 !((+))!,\

 ==$15HAa%iaeaiHEN(,?1QQ?DMab!KKOQR 4;;3t'7'7#8WC@Q@Q<RWVWWWWWW I?s   	F&F&;	F+F+c                    U R                   (       d  U R                  b  [        U R                  5      [        U R                  5      :X  a  [        U R                  [        [        45      (       a  SU l         U R                   $ [        U R                  R                  5      U R                  R                  :X  a9  [        S U R                  R                  R	                  5        5       5      U l         U R                   $ )a   
Recalculates is_exhausted if necessary, and then returns it.

A node is exhausted if:
- Its transition is Conclusion or Killed
- It has the maximum number of children (i.e. we have found all of its
  possible children), and all its children are exhausted

Therefore, we only need to compute this for a node when:
- We first create it in split_at
- We set its transition to either Conclusion or Killed
  (TreeRecordingObserver.conclude_test or TreeRecordingObserver.kill_branch)
- We exhaust any of its children
Tc              3   8   #    U  H  oR                   v   M     g 7fr   r   .0vs     r.   	<genexpr>+TreeNode.check_exhausted.<locals>.<genexpr>  s      (,MqNN,Ms   )r   r   r   rF   r   
isinstancerd   r3   rP   rS   allr   s    r.   r   TreeNode.check_exhausted  s    $ !! + DKK C$44$//J+?@@$(!
    	 T__--.$//2N2NN$' (,0OO,D,D,K,K,M( %!    r-   r7   r"   r8   c                    USL d   eSn[        [        U R                  U R                  U R                  SS95       Hd  u  nu  pVnUR                  U5         US:  a  UR                  5         UR                  [        XWXdU R                  ;   S95        S S S 5        US-  nMf     UR                  U5         [        U R                  5      S:  a  UR                  5         U R                  b  UR                  U R                  5        OUR                  S5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NFr   TstrictrV   rW   unknown)rX   zipr   rE   r   r[   rZ   r;   rK   rF   r   r   r\   )r=   r7   r8   r[   r]   rC   rE   rD   s           r.   r>   TreeNode._repr_pretty_  s   ~~4=!!4#3#3T[[N5
0A0% &!q5HHJ #KT[[@P " aKF5
 XXf4;;!#
*)y!  "! s   =D#6A$D4#
D1	4
E)__forcedr   r   )r(   r)   r*   r+   r@   r   listrE   r   rA   r   r   r   r   r   r   rb   r   rM   rd   r3   r   rB   ra   r   rF   r   r   r   r>   r,   r'   r-   r.   r5   r5   P  s    <@ -2$,GK()G!$7FDM7&+D&AL${#A !&d ?Hc#ho? 7;Jv
*V3: u59L$9C  
S T !X# !X$ !XF*! *!X"6 "t " "r-   r5   c            
           \ rS rSrSrSS jr\S\4S j5       rS\	S\
\S4   4S	 jrS
 rS\SS4S jrS rS\S\S\	S\4S jrS\S\S\S\4S jrS\S\S\S\	S\4
S jrS\S\S\S\SS4
S jrSSS\SS4S jrSrg)DataTreei%  u  
A DataTree tracks the structured history of draws in some test function,
across multiple ConjectureData objects.

This information is used by ConjectureRunner to generate novel prefixes of
this tree (see generate_novel_prefix). A novel prefix is a sequence of draws
which the tree has not seen before, and therefore the ConjectureRunner has
not generated as an input to the test function before.

DataTree tracks the following:

- Drawn choices in the choice sequence
  - ConjectureData.draw_integer()
  - ConjectureData.draw_float()
  - ConjectureData.draw_string()
  - ConjectureData.draw_boolean()
  - ConjectureData.draw_bytes()
- Test conclusions (with some Status, e.g. Status.VALID)
  - ConjectureData.conclude_test()

A DataTree is — surprise — a *tree*. A node in this tree is either a choice draw
with some value, a test conclusion with some Status, or a special `Killed` value,
which denotes that further draws may exist beyond this node but should not be
considered worth exploring when generating novel prefixes. A node is a leaf
iff it is a conclusion or Killed.

A branch from node A to node B indicates that we have previously seen some
sequence (a, b) of draws, where a and b are the values in nodes A and B.
Similar intuition holds for conclusion and Killed nodes.

Examples
--------

To see how a DataTree gets built through successive sets of draws, consider
the following code that calls through to some ConjecutreData object `data`.
The first call can be either True or False, and the second call can be any
integer in the range [1, 3].

    data.draw_boolean()
    data.draw_integer(1, 3)

To start, the corresponding DataTree object is completely empty.

                  ┌──────┐
                  │ root │
                  └──────┘

We happen to draw True and then 2 in the above code. The tree tracks this.
(2 also connects to a child Conclusion node with Status.VALID since it's the
final draw in the code. I'll omit Conclusion nodes in diagrams for brevity.)

                  ┌──────┐
                  │ root │
                  └──┬───┘
                  ┌──┴───┐
                  │ True │
                  └──┬───┘
                  ┌──┴───┐
                  │  2   │
                  └──────┘

This is a very boring tree so far! But now we happen to draw False and
then 1. This causes a split in the tree. Remember, DataTree tracks history
over all invocations of a function, not just one. The end goal is to know
what invocations haven't been tried yet, after all.

                  ┌──────┐
              ┌───┤ root ├───┐
              │   └──────┘   │
           ┌──┴───┐        ┌─┴─────┐
           │ True │        │ False │
           └──┬───┘        └──┬────┘
            ┌─┴─┐           ┌─┴─┐
            │ 2 │           │ 1 │
            └───┘           └───┘

If we were to ask DataTree for a novel prefix at this point, it might
generate any of (True, 1), (True, 3), (False, 2), or (False, 3).

Note that the novel prefix stops as soon as it generates a novel node. For
instance, if we had generated a novel prefix back when the tree was only
root -> True -> 2, we could have gotten any of (True, 1), (True, 3), or
(False). But we could *not* have gotten (False, n), because both False and
n were novel at that point, and we stop at the first novel node — False.

I won't belabor this example. Here's what the tree looks like when fully
explored:

                  ┌──────┐
           ┌──────┤ root ├──────┐
           │      └──────┘      │
        ┌──┴───┐              ┌─┴─────┐
     ┌──┤ True ├──┐       ┌───┤ False ├──┐
     │  └──┬───┘  │       │   └──┬────┘  │
   ┌─┴─┐ ┌─┴─┐  ┌─┴─┐   ┌─┴─┐  ┌─┴─┐   ┌─┴─┐
   │ 1 │ │ 2 │  │ 3 │   │ 1 │  │ 2 │   │ 3 │
   └───┘ └───┘  └───┘   └───┘  └───┘   └───┘

You could imagine much more complicated trees than this arising in practice,
and indeed they do. In particular, the tree need not be balanced or 'nice'
like the tree above. For instance,

    b = data.draw_boolean()
    if b:
        data.draw_integer(1, 3)

results in a tree with the entire right part lopped off, and False leading
straight to a conclusion node with Status.VALID. As another example,

    n = data.draw_integers()
    assume(n >= 3)
    data.draw_string()

results in a tree with the 0, 1, and 2 nodes leading straight to a
conclusion node with Status.INVALID, and the rest branching off into all
the possibilities of draw_string.

Notes
-----

The above examples are slightly simplified and are intended to convey
intuition. In practice, there are some implementation details to be aware
of.

- In draw nodes, we store the constraints used in addition to the value drawn.
  E.g. the node corresponding to data.draw_float(min_value=1.0, max_value=1.5)
  would store {"min_value": 1.0, "max_value": 1.5, ...} (default values for
  other constraints omitted).

  The constraints parameters have the potential to change both the range of
  possible outputs of a node, and the probability distribution within that
  range, so we need to use these when drawing in DataTree as well. We draw
  values using these constraints when (1) generating a novel value for a node
  and (2) choosing a random child when traversing the tree.

- For space efficiency, rather than tracking the full tree structure, we
  store DataTree as a radix tree. This is conceptually equivalent (radix
  trees can always be "unfolded" to the full tree) but it means the internal
  representation may differ in practice.

  See TreeNode for more information.
r9   Nc                 0    [        5       U l        0 U l        g r   )r5   root_children_cacher   s    r.   __init__DataTree.__init__  s    &j	CEr-   c                 .    U R                   R                  $ )zZ
Returns True if every node is exhausted, and therefore the tree has
been fully explored.
)r   r   r   s    r.   r   DataTree.is_exhausted  s     yy%%%r-   random.c           	        ^ U R                   (       a   e/ mS[        S[        SS4U4S jjnU R                  n UR                   (       a   e[	        [        UR                  UR                  UR                  SS95       H  u  nu  pVnXCR                  ;   a
  U" XW5        M"  Sn US	::  a   U R                  XVUS
9n	OU R                  UU[        U5      US9n	X:w  a	  U" XY5        O"US-  nU R                  UUU	[        U5      S9  Mc  [        T5      s  $    [!        UR"                  [$        [&        45      (       a   eUR"                  c  [        T5      $ UR"                  n
[!        U
[(        5      (       d   eSn US	::  a'   U R                  U
R*                  U
R                  US
9n	O/U R                  U
R*                  U
R                  [        U
5      US9n	 U
R,                  U	   nUR                   (       d  U" U
R*                  U	5        UnOUS-  nU R                  U
R*                  U
R                  U	[        U
5      S9  US:w  dT  [1        U
R,                  5      U
R2                  :  d1  [5        S U
R,                  R                  5        5       5      (       d   eGM$  GMi  ! [         a
    US-  n GM  f = f! [         a
    US-  n GMR  f = f! [.         a!    U" U
R*                  U	5        [        T5      s $ f = f)a  Generate a short random string that (after rewriting) is not
a prefix of any choice sequence previously added to the tree.

The resulting prefix is essentially arbitrary - it would be nice
for it to be uniform at random, but previous attempts to do that
have proven too expensive.
rC   choicer9   Nc                 x   > U S:X  a"  [        U[        5      (       d   e[        U5      nTR                  U5        g )Nr   )r   rb   r    append)rC   r   prefixs     r.   append_choice5DataTree.generate_novel_prefix.<locals>.append_choice  s4    g%!&#....%f-MM&!r-   Tr   r   
   r   rv   )r   r   )r^   r   i  c              3   B   #    U  H  oR                   (       + v   M     g 7fr   r   r   s     r.   r   1DataTree.generate_novel_prefix.<locals>.<genexpr>1  s     P7O!~~--7Os   )r   r   r   r   rX   r   r   rE   r   rF   _drawr   _draw_from_cacheid_reject_childtupler   r   rd   r3   rM   rC   rP   KeyErrorr   rS   any)r=   r   r   current_noder]   rC   rE   rD   attempts
node_valuebranchr^   r   s               @r.   generate_novel_prefixDataTree.generate_novel_prefix  s8    $$$$	"{ 	"G 	" 	" yy#00008A -- ,, ''	944Ke +++!+5 H#r>	)-1ZZ$/V .8 ."
 *.)>)> + +$&|$4'-	 *? *J &.)+B! A**''", "< 0	 + 1 @ !=(Y9\ ","9"9J;OPPPP&&.V}$!,,Fff----Hr>!%)ZZ"..0B0B6 &0 &
 "&!6!6****vJ%	 "7 "J)"OOJ7E ))!&"4"4jA#(LA""&&&&$6
	 #  $6??+f.A.AAPv7M7M7OPPPQK o ( $, ) !)A ()R $ ! A !   )!&"4"4jA =()s6   ,J#%J: K #J76J7:KK(K<;K<c                     [         R                  " U5      n U R                  U5        UR                  UR                  4$ ! [
         a    US4s $ f = f)zUse previously seen ConjectureData objects to return a tuple of
the rewritten choice sequence and the status we would get from running
that with the test function. If the status cannot be predicted
from the existing values it will be None.N)r   for_choicessimulate_test_functionchoicesrf   r%   )r=   r   datas      r.   rewriteDataTree.rewrite4  sS    
 ))'2	#''-LL$++..( 	#T?"	#s   (A AAr   c           	        ^ U R                   nSSS.U4S jjn  [        [        UR                  UR                  UR
                  SS95       H-  u  nu  pVnU" UUXBR                  ;   a  UOSS9nX:w  d  M)  [        e   [        UR                  [        5      (       a3  UR                  n	TR                  U	R                  U	R                  5        OUR                  c  [        e[        UR                  [        5      (       aL  U" UR                  R                  UR                  R                  5      n UR                  R                   U   nOQ[        UR                  [$        5      (       d   eTR&                  R)                  5         UR                  R*                  nGM  ! ["         a  n
[        U
eSn
A
ff = f! [,         a     gf = f)zRun a simulated version of the test function recorded by
this tree. Note that this does not currently call ``stop_span``
or ``start_span`` as these are not currently recorded in the
tree. This will likely change in future.NT)rF   convert_forcedc                   > U S:X  a  Ub  U(       a  [        U5      n[        TSU  35      nU" S0 UDSU0D6nU S:X  a  [        U5      nU$ )Nr   draw_rF   r'   )r    getattrr   )rC   rE   rF   r   	draw_funcrD   r   s         r.   draw-DataTree.simulate_test_function.<locals>.drawG  sX    g%&*<%f-k]&;<I;;F;Eg%$U+Lr-   r   rV   )r   rX   r   r   rE   r   rF   r%   r   r   rd   conclude_testrf   rg   rM   rC   rP   r   r3   observerkill_branchr6   r   )r=   r   noder   r]   rC   rE   previousr   terrs    `         r.   r   DataTree.simulate_test_function@  s   
 yy59$ 		 			?H))4+;+;T[[QUV@;A;( ##+,+;xA
 }77@ dooz::A&&qxx1E1EF__,3388T__88$//:U:UVAA#77: &doov>>>>MM--/??44D3 ( $ A7S@A  		s>   AF< 7B=F< 5F# AF< #
F9-F44F99F< <
G	G	c                     [        U 5      $ r   )TreeRecordingObserverr   s    r.   new_observerDataTree.new_observerp  s    $T**r-   rC   rE   c                p    SSK Jn  U" XUS9nUS:X  a"  [        U[        5      (       d   e[	        U5      nU$ )Nr   )draw_choicer   r   )#hypothesis.internal.conjecture.datar  r   r   r   )r=   rC   rE   r   r  rD   s         r.   r   DataTree._draws  s@     	DKVD '!eU++++ 'Er-   r   c                    X0R                   ;  a(  [        X5      n/ n[        5       nXEU4U R                   U'   U R                   U   $ r   )r   r   r   )r=   rC   rE   r   	generatorrP   rejecteds          r.   _get_children_cacheDataTree._get_children_cache  sL     ***$[>I&(H%(UH)2h(GD  %##C((r-   c                   U R                  XUS9u  pVn[        U5      S:  aZ  U HT  nUS:X  a"  [        U[        5      (       d   e[	        U5      nX;   a  M2  UR                  U5        [        U5      S:  d  MT    O   UR                  U5      $ )Nr   d   r   )r  r   r   r   r   r   r   )	r=   rC   rE   r   r   r  rP   r  r   s	            r.   r   DataTree._draw_from_cache  s     +/*B*B# +C +
'h x=3')%a////$QA="x=C'  }}X&&r-   r^   c                z    U R                  XUS9u  pVnUR                  U5        X6;   a  UR                  U5        g g )Nr  )r  r   remove)r=   rC   rE   r^   r   
_generatorrP   r  s           r.   r   DataTree._reject_child  sK     ,0+C+C# ,D ,
(x 	U" OOE" r-   r7   r"   r8   c                 H    USL d   eUR                  U R                  5        g )NF)r\   r   r<   s      r.   r>   DataTree._repr_pretty_  s    ~~	r-   )r   r   r9   N)r(   r)   r*   r+   r@   r   ra   rB   r   r   r   r   r   r   r   r   r
  r   r   r   r#   r  r   r   r>   r,   r'   r-   r.   r   r   %  s=   M^F &d & &qF quWc\7J qf
#.> .d .`+  (
  
.)&)5G)QX)	)(' ' ('
 ' ' 
'<# # (#
 # # 
#>6 t  r-   r   c            
           \ rS rSrS\4S jrS\S\S\SS4S	 jr	S\
S\S\SS4S
 jrS\S\S\SS4S jrS\S\S\SS4S jrS\S\S\SS4S jrS\S\S\S\SS4
S jrSS jrS\S\S-  SS4S jrSS jrSrg)r	  i  treec                     UR                   U l        UR                   U l        SU l        U R                  /U l        SU l        g )Nr   F)r   _root_current_node_index_in_current_node_trailkilled)r=   r!  s     r.   r   TreeRecordingObserver.__init__  s:     YY
'+yy+,#'+'9'9&:!r-   rD   
was_forcedrE   r9   Nc                &    U R                  SXUS9  g )Nr   r)  rE   
draw_valuer=   rD   r)  rE   s       r.   draw_integer"TreeRecordingObserver.draw_integer       	u 	 	
r-   c                &    U R                  SXUS9  g )Nr   r+  r,  r.  s       r.   
draw_float TreeRecordingObserver.draw_float       	;Wr-   c                &    U R                  SXUS9  g )Nr   r+  r,  r.  s       r.   draw_string!TreeRecordingObserver.draw_string  s     	%KXr-   c                &    U R                  SXUS9  g )Nr   r+  r,  r.  s       r.   
draw_bytes TreeRecordingObserver.draw_bytes  r5  r-   c                &    U R                  SXUS9  g )Nr   r+  r,  r.  s       r.   draw_boolean"TreeRecordingObserver.draw_boolean  r1  r-   rC   c                J   U R                   nU =R                   S-  sl         U R                  n[        U[        5      (       a  [	        U5      n[        UR                  5      [        UR                  5      s=:X  a  [        UR                  5      :X  d   e   eU[        UR                  5      :  a  XR                  U   :w  d  XFR                  U   :w  a  [        [        5      eU(       a  XVR                  ;  a  [        [        5      eX&R                  U   :w  a|  UR                  U5        U[        UR                  5      :X  d   e[        5       n[        UR                  [        5      (       d   eXvR                  R                   U'   Xpl        SU l         GOUR                  nUc  UR                  R#                  U5        UR                  R#                  U5        UR                  R#                  U5        U(       a  UR%                  U5        ['        X5      S:X  a^  U(       dW  UR                  U5        [        UR                  [        5      (       d   eUR                  R                   U   U l        SU l         O[        U[(        5      (       a/  UR*                  [,        R.                  :w  d   e[        [        5      e[        U[        5      (       d   U5       eXR0                  :w  d  XHR                  :w  a  [        [        5      e UR                   U   U l        SU l         U R6                  S   U R                  La&  U R6                  R#                  U R                  5        g g ! [2         a,    UR                   R5                  U[        5       5      U l         Nf = f)Nrv   r   )r%  r$  r   r   r   r   rE   r   r   r   r   rF   r   r5   r   rM   rP   r   r   rR   rd   rf   r   OVERRUNrC   r   
setdefaultr&  )	r=   rC   rD   r)  rE   r]   r  new_nodetranss	            r.   r-   TreeRecordingObserver.draw_value  s    ''##q(#!!eU## 'E4##$DKK(8RC@Q@Q<RRRRRRs4;;0033"2"21"55-.>?? a{{2-.>??A&a C,,,,#:!$//6::::2:((/%-"./+OOE}!!((5  ''4""5)$$Q'$ )BaG&MM!$%doov>>>>)-)A)A%)HD&23D/E:..||v~~555 ..>??!%007%70"3"33{FWFW7W12BCCV).)>D& /0+;;r?$"4"44KKt112 5   V).)B)B5(*)UD&Vs   M, ,3N"!N"c                 b   U R                   (       a  gSU l         U R                  [        U R                  R                  5      :  d@  U R                  R
                  b8  [        U R                  R
                  [        5      (       d  [        [        5      eU R                  R
                  c2  [        [        5       5      U R                  l        U R                  5         U R                  R
                  R                  U l        SU l        U R                  R                  U R                  5        g)z5Mark this part of the tree as not worth re-exploring.NTr   )r'  r%  r   r$  r   r   r   r3   r   r   r5   (_TreeRecordingObserver__update_exhaustedr6   r&  r   r   s    r.   r  !TreeRecordingObserver.kill_branch_  s    ;;&&T-?-?-F-F)GG))5t11<<fEE)*:;;((0,28:,>D)##%!//::DD&'#4--.r-   rf   rg   c           
         U[         R                  :X  a  gU R                  nU R                  nU[	        UR
                  5      :  d  [        UR                  [        5      (       a  [        [        5      e[        X5      nUR                  b  UR                  U:w  a  [        UR                  [        5      (       a  UR                  R                  [         R                  :w  d  UR                  [         R                  :w  am  UR                  R                  nUR                  n[!        SUR                  R                  R"                   SU SUR                  R"                   SU 3Xg45      eOXTl        X@R$                  S   L d   eUR'                  5         [	        UR
                  5      S:  d  UR'                  5       (       d   eU R(                  (       d  U R+                  5         gg)znSays that ``status`` occurred at node ``node``. This updates the
node if necessary and checks for consistency.Nz9Inconsistent results from replaying a test case!
  last: z from z	
  this: r@  r   )r   rA  r%  r$  r   r   r   r   rM   r   r   rd   rf   INTERESTINGVALIDrg   r   namer&  r   r'  rG  )r=   rf   rg   r]   r  new_transition
old_origin
new_origins           r.   r   #TreeRecordingObserver.conclude_testt  s   
 V^^#''!!s4;;:doov#F#F)*:;;#F???&4??n+L $//:66&&&*<*<<!((FLL8!__??
+>>
!#55::;6* N-4499:&N  ,	  -O{{2&&&4;;!#t';';'='==={{##% r-   c                 j    [        U R                  5       H  nUR                  5       (       a  M    g    g r   )reversedr&  r   )r=   r  s     r.   __update_exhausted(TreeRecordingObserver.__update_exhausted  s)    $++&A
 $$&& 'r-   )r$  r%  r#  r&  r'  r  )r(   r)   r*   r+   r   r   rb   rB   r   r/  r   r   r3  strr   r7  r   r   r:  r   r=  r   r   r   r-  r  r   r   r   rG  r,   r'   r-   r.   r	  r	    s?   "X "

)-
<N
	
XX+/X>NX	X
YY)-Y<MY	Y
XX+/X>NX	X


*.
=O
	
U3 U3 U3
 U3 (U3 
U3n/*'&'&2Cd2J'&	'&Rr-   r	  )Fr|   collections.abcr   r   dataclassesr   r   r   r   typingr   r	   r
   r   hypothesis.errorsr   r   r   r   hypothesis.internalr   r   %hypothesis.internal.conjecture.choicer   r   r   r   r   r   r   r   r   r  r   r   r   hypothesis.internal.escalationr   hypothesis.internal.floatsr   r   r    r!   hypothesis.vendor.prettyr"   r   r   r   r#   rA   r%   r   	frozensetr/   rb   r3   rB   rU  rK   rM   rd   rq   r   rR   r   r   r   r5   r   r	  r'   r-   r.   <module>r`     s1    * (  8 8  .
 
 
 U T <  >!&gtT!"DM3w<?" Y 
	 3 	
  "y~ # d#
 
 $
CCC $C
 C 	C e$    % 6 d#8 8 $8L 1; !5: :%3c %3S %3C %3TW %3PLFLF+=LFLFnu  9UD$5F+G 
(=(=+=(=wd"#(=V e$Q" Q" %Q"hx xvDL Dr-   