
    \h"                        S SK Jr  S SKJr  SSKJr  SSKJr  SSKJr  S SK	J
r
  S rSS	 jr " S
 S5      rS S0 4S jrS rSS jrSS jrg)    )annotations)Iterator   )Basic)orderedsympify)iterablec              #  b   #    U /nU H"  nUv   UR                  UR                  5        M$     g7f)a  Yield the args of a Basic object in a breadth-first traversal.
Depth-traversal stops if `arg.args` is either empty or is not
an iterable.

Examples
========

>>> from sympy import Integral, Function
>>> from sympy.abc import x
>>> f = Function('f')
>>> from sympy.core.traversal import iterargs
>>> list(iterargs(Integral(f(x), (f(x), 1))))
[Integral(f(x), (f(x), 1)), f(x), (f(x), 1), x, f(x), 1, x]

See Also
========
iterfreeargs, preorder_traversal
N)extendargs)exprr   is      L/var/www/auris/envauris/lib/python3.13/site-packages/sympy/core/traversal.pyiterargsr      s-     & 6DAFF s   -/c              #  8  #    U /nU H  nUv   U(       ad  [        US5      (       aS  UR                  R                  5       n[        UR	                  5       SS9 H  nUR
                  " U6 (       a  M  Uv   M     UR                  UR                  5        M     g7f)a  Yield the args of a Basic object in a breadth-first traversal.
Depth-traversal stops if `arg.args` is either empty or is not
an iterable. The bound objects of an expression will be returned
as canonical variables.

Examples
========

>>> from sympy import Integral, Function
>>> from sympy.abc import x
>>> f = Function('f')
>>> from sympy.core.traversal import iterfreeargs
>>> list(iterfreeargs(Integral(f(x), (f(x), 1))))
[Integral(f(x), (f(x), 1)), 1]

See Also
========
iterargs, preorder_traversal
bound_symbolsF)_firstN)hasattrcanonical_variablesvaluesiterfreeargsas_dummyhasr   r   )r   r   r   r   voids        r   r   r   %   s{     ( 6Dga11((//1D!!**,u=uud||G > 	AFF s   A,B2(Bc                  >    \ rS rSrSrS
S jrS rS rS rSS jr	S	r
g)preorder_traversalD   a  
Do a pre-order traversal of a tree.

This iterator recursively yields nodes that it has visited in a pre-order
fashion. That is, it yields the current node then descends through the
tree breadth-first to yield all of a node's children's pre-order
traversal.


For an expression, the order of the traversal depends on the order of
.args, which in many cases can be arbitrary.

Parameters
==========
node : SymPy expression
    The expression to traverse.
keys : (default None) sort key(s)
    The key(s) used to sort args of Basic objects. When None, args of Basic
    objects are processed in arbitrary order. If key is defined, it will
    be passed along to ordered() as the only key(s) to use to sort the
    arguments; if ``key`` is simply True then the default keys of ordered
    will be used.

Yields
======
subtree : SymPy expression
    All of the subtrees in the tree.

Examples
========

>>> from sympy import preorder_traversal, symbols
>>> x, y, z = symbols('x y z')

The nodes are returned in the order that they are encountered unless key
is given; simply passing key=True will guarantee that the traversal is
unique.

>>> list(preorder_traversal((x + y)*z, keys=None)) # doctest: +SKIP
[z*(x + y), z, x + y, y, x]
>>> list(preorder_traversal((x + y)*z, keys=True))
[z*(x + y), z, x + y, x, y]

Nc                >    SU l         U R                  X5      U l        g )NF)
_skip_flag_preorder_traversal_pt)selfnodekeyss      r   __init__preorder_traversal.__init__q   s    ++D7    c              #    #    Uv   U R                   (       a  SU l         g [        U[        5      (       aw  U(       d  [        US5      (       a  UR                  nOUR
                  nU(       a  US:w  a  [        X2SS9nO[        U5      nU H  nU R                  XB5       S h  vN   M     g [        U5      (       a#  U H  nU R                  XR5       S h  vN   M     g g  N= N7f)NF_argsetTdefault)	r    
isinstancer   r   r*   r   r   r!   r
   )r#   r$   r%   r   argitems         r   r!   &preorder_traversal._preorder_traversalu   s     
??#DOdE""GD)44 ||yy4<"4u=D"4=D33C>>> d^^33D???   ? @s$   B C$"C #2C$C"C$"C$c                    SU l         g)a7  
Skip yielding current node's (last yielded node's) subtrees.

Examples
========

>>> from sympy import preorder_traversal, symbols
>>> x, y, z = symbols('x y z')
>>> pt = preorder_traversal((x + y*z)*z)
>>> for i in pt:
...     print(i)
...     if i == x + y*z:
...             pt.skip()
z*(x + y*z)
z
x + y*z
TN)r    r#   s    r   skippreorder_traversal.skip   s    $ r(   c                ,    [        U R                  5      $ N)nextr"   r2   s    r   __next__preorder_traversal.__next__   s    DHH~r(   c                    U $ r6    r2   s    r   __iter__preorder_traversal.__iter__   s    r(   )r"   r    r6   )returnzIterator[Basic])__name__
__module____qualname____firstlineno____doc__r&   r!   r3   r8   r<   __static_attributes__r;   r(   r   r   r   D   s"    +X8@.(r(   r   r;   c                @   ^^^^ UUUU4S jmT" [        U 5      U5      $ )a  
Use ``func`` to transform ``expr`` at the given level.

Examples
========

>>> from sympy import use, expand
>>> from sympy.abc import x, y

>>> f = (x + y)**2*x + 1

>>> use(f, expand, level=2)
x*(x**2 + 2*x*y + y**2) + 1
>>> expand(f)
x**3 + 2*x**2*y + x*y**2 + 1

c                   > U(       d  T" U /TQ70 TD6$ U R                   (       a  U $ US-  nU R                   Vs/ s H  nT" X!5      PM     nnU R                  " U6 $ s  snf )Nr   )is_Atomr   	__class__)r   levelr.   _args_user   funckwargss       r   rK   use.<locals>._use   sb    .t.v..||
59YY?Ycc)Y?~~u-- @s   Ar   )r   rL   rI   r   rM   rK   s    ` ``@r   userO      s     $	. 	. u%%r(   c              '     #    [        X5      (       a,  U v   U R                   H  n[        U/UQ76  Sh  vN   M     gg N
7f)a  Iterate through the args that are the given types (target) and
return a list of the args that were traversed; arguments
that are not of the specified types are not traversed.

Examples
========

>>> from sympy.core.traversal import walk
>>> from sympy import Min, Max
>>> from sympy.abc import x, y, z
>>> list(walk(Min(x, Max(y, Min(1, z))), Min))
[Min(x, Max(y, Min(1, z)))]
>>> list(walk(Min(x, Max(y, Min(1, z))), Min, Max))
[Min(x, Max(y, Min(1, z))), Max(y, Min(1, z)), Min(1, z)]

See Also
========

bottom_up
N)r-   r   walk)etargetr   s      r   rQ   rQ      sB     * !AA''''   (s   3AA Ac                B   [        U SS5      nUbf  U(       aN  [        U Vs/ s H  n[        XQX#5      PM     sn5      nX@R                  :w  a  U R                  " U6 n U" U 5      n U $ U(       a  U" U 5      n U $ U(       a   U" U 5      n U $ U $ s  snf ! [
         a     U $ f = f)zApply ``F`` to all expressions in an expression tree from the
bottom up. If ``atoms`` is True, apply ``F`` even if there are no args;
if ``nonbasic`` is True, try to apply ``F`` to non-Basic objects.
r   N)getattrtuple	bottom_upr   rL   	TypeError)rvFatomsnonbasicr   as         r   rW   rW      s    
 2vt$DDIDq)A%:DIJDwwWWd^2B I 2B I rU I2I J  Is   B?B 
BBNc              #  6  #    [        U [        5      (       aL  U R                  nU(       a  US:w  a  [        X!SS9nO[        U5      nU H  n[	        X15       Sh  vN   M     O,[        U 5      (       a  U  H  n[	        XA5       Sh  vN   M     U v   g N: N7f)a  
Do a postorder traversal of a tree.

This generator recursively yields nodes that it has visited in a postorder
fashion. That is, it descends through the tree depth-first to yield all of
a node's children's postorder traversal before yielding the node itself.

Parameters
==========

node : SymPy expression
    The expression to traverse.
keys : (default None) sort key(s)
    The key(s) used to sort args of Basic objects. When None, args of Basic
    objects are processed in arbitrary order. If key is defined, it will
    be passed along to ordered() as the only key(s) to use to sort the
    arguments; if ``key`` is simply True then the default keys of
    ``ordered`` will be used (node count and default_sort_key).

Yields
======
subtree : SymPy expression
    All of the subtrees in the tree.

Examples
========

>>> from sympy import postorder_traversal
>>> from sympy.abc import w, x, y, z

The nodes are returned in the order that they are encountered unless key
is given; simply passing key=True will guarantee that the traversal is
unique.

>>> list(postorder_traversal(w + (x + y)*z)) # doctest: +SKIP
[z, y, x, x + y, z*(x + y), w, w + z*(x + y)]
>>> list(postorder_traversal(w + (x + y)*z, keys=True))
[w, z, x, y, x + y, z*(x + y), w + z*(x + y)]


TFr+   N)r-   r   r   r   postorder_traversalr
   )r$   r%   r   r.   r/   s        r   r_   r_      s     T $yyt|t59t}C*3555 	$D*4666 
J	 6 7s$   ABB,BBBB)T)FFr6   )
__future__r   typingr   basicr   sortingr   r	   sympy.utilities.iterablesr
   r   r   r   rO   rQ   rW   r_   r;   r(   r   <module>re      sL    "     .2>` `F "R &@(606r(   