ó
    Š*£hR   ã                   óÜ   • S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	  S SK
Jr  S/r\SSS	.4\S
S044r\\\\	4rSS jr\4S jrSS jr\\SS4S jrS SS4S jrSrSSS.r\S SS\4S jrg)é    )ÚBasic)ÚExpr)ÚSymbol)ÚIntegerÚRationalÚFloat)ÚsreprÚdotprintÚblueÚellipse)ÚcolorÚshaper   Úblackc                 ó<  • Sn[        U [        5      (       d  [        U 5      nOnU R                  (       d  [	        U 5      nOQU R                  n[        [        [        U5      5      n[        U 5      R                  < SSR                  U5      < S3nU(       a  X24nU$ )aº  A string that follows ```obj = type(obj)(*obj.args)``` exactly.

Parameters
==========

with_args : boolean, optional
    If ``True``, there will be a second argument for the return
    value, which is a tuple containing ``purestr`` applied to each
    of the subnodes.

    If ``False``, there will not be a second argument for the
    return.

    Default is ``False``

Examples
========

>>> from sympy import Float, Symbol, MatrixSymbol
>>> from sympy import Integer # noqa: F401
>>> from sympy.core.symbol import Str # noqa: F401
>>> from sympy.printing.dot import purestr

Applying ``purestr`` for basic symbolic object:
>>> code = purestr(Symbol('x'))
>>> code
"Symbol('x')"
>>> eval(code) == Symbol('x')
True

For basic numeric object:
>>> purestr(Float(2))
"Float('2.0', precision=53)"

For matrix symbol:
>>> code = purestr(MatrixSymbol('x', 2, 2))
>>> code
"MatrixSymbol(Str('x'), Integer(2), Integer(2))"
>>> eval(code) == MatrixSymbol('x', 2, 2)
True

With ``with_args=True``:
>>> purestr(Float(2), with_args=True)
("Float('2.0', precision=53)", ())
>>> purestr(MatrixSymbol('x', 2, 2), with_args=True)
("MatrixSymbol(Str('x'), Integer(2), Integer(2))",
 ("Str('x')", 'Integer(2)', 'Integer(2)'))
© Ú(ú, Ú))Ú
isinstancer   ÚstrÚargsr	   ÚtupleÚmapÚpurestrÚtypeÚ__name__Újoin)ÚxÚ	with_argsÚsargsÚrvr   s        ÚO/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/printing/dot.pyr   r      sv   € ðb €EÜ�aœ×ÑÜ�‹V‰Ø�V�VÜ�1‹X‰à�v‰vˆÜ”cœ' 4Ó(Ó)ˆÜ˜A“w×'Ô'¨¯©°5Ö)9Ð:ˆÞØˆYˆØ€Ió    c                 óf   • 0 nU H(  u  p4[        X5      (       d  M  UR                  U5        M*     U$ )a©  Merge style dictionaries in order

Examples
========

>>> from sympy import Symbol, Basic, Expr, S
>>> from sympy.printing.dot import styleof
>>> styles = [(Basic, {'color': 'blue', 'shape': 'ellipse'}),
...           (Expr,  {'color': 'black'})]

>>> styleof(Basic(S(1)), styles)
{'color': 'blue', 'shape': 'ellipse'}

>>> x = Symbol('x')
>>> styleof(x + 1, styles)  # this is an Expr
{'color': 'black', 'shape': 'ellipse'}
)r   Úupdate)ÚexprÚstylesÚstyleÚtypÚstys        r"   Ústyleofr+   N   s3   € ð$ €EÛ‰ˆÜ�d× Ó Ø�L‰L˜Öñ ð €Lr#   c                 ó`   • UR                  S [        U R                  5       5       5       5      $ )zÀPrint a dictionary of attributes

Examples
========

>>> from sympy.printing.dot import attrprint
>>> print(attrprint({'color': 'blue', 'shape': 'ellipse'}))
"color"="blue", "shape"="ellipse"
c              3   ó,   #   • U  H
  nS U-  v •  M     g7f)z	"%s"="%s"Nr   )Ú.0Úitems     r"   Ú	<genexpr>Úattrprint.<locals>.<genexpr>q   s   é € ÐIÒ7H¨t˜+ dÖ*Ò7Hùs   ‚)r   ÚsortedÚitems)ÚdÚ	delimiters     r"   Ú	attrprintr6   g   s$   € ð �>‰>ÑI´v¸a¿g¹g»iÔ7HÓIÓIÐIr#   r   Tc                 ó*  • [        X5      n[        U [        5      (       a1  U R                  (       d   [	        U R
                  R                  5      nOU" U 5      nXeS'   [        U 5      nU(       a  US[	        U5      -  -  nSU< S[        U5      < S3$ )zÌString defining a node

Examples
========

>>> from sympy.printing.dot import dotnode
>>> from sympy.abc import x
>>> print(dotnode(x))
"Symbol('x')_()" ["color"="black", "label"="x", "shape"="ellipse"];
Úlabelú_%sÚ"z" [z];)	r+   r   r   Úis_Atomr   Ú	__class__r   r   r6   )r&   r'   Ú	labelfuncÚposÚrepeatr(   r8   Úexpr_strs           r"   ÚdotnoderA   t   su   € ô �DÓ!€Eä�$œ×Ñ t§|§|Ü�D—N‘N×+Ñ+Ó,‰á˜$“ˆØˆ'�NÜ�t‹}€HÞØ�EœC ›HÑ$Ñ$ˆøÛ#¤Y¨uÖ%5Ð6Ð6r#   c                 ó,   • [        U [        5      (       + $ ©N©r   r   ©r   s    r"   Ú<lambda>rF   Œ   s   € ¤j°´EÓ&:Õ":r#   c           
      ó  • U" U 5      (       a  / $ [        U SS9u  pEU(       aC  US[        U5      -  -  n[        U5       VVs/ s H  u  pgU< S[        X&4-   5      < 3PM     nnnU Vs/ s H  nSU< SU< S3PM     sn$ s  snnf s  snf )ag  List of strings for all expr->expr.arg pairs

See the docstring of dotprint for explanations of the options.

Examples
========

>>> from sympy.printing.dot import dotedges
>>> from sympy.abc import x
>>> for e in dotedges(x+2):
...     print(e)
"Add(Integer(2), Symbol('x'))_()" -> "Integer(2)_(0,)";
"Add(Integer(2), Symbol('x'))_()" -> "Symbol('x')_(1,)";
T)r   r9   Ú_r:   z" -> "z";)r   r   Ú	enumerate)r&   Úatomr>   r?   r@   Úarg_strsÚiÚas           r"   ÚdotedgesrN   Œ   s�   € ñ ˆD‡z�zØˆ	ä$ T°TÑ:ÑˆÞØ˜¤ C£Ñ(Ñ(ˆHä% hÔ/ô1Ú/‘D�Aó $%¤c¨#°©*¥oÓ6Ù/ð ñ 1á9AÓBº±A£8«QÓ/¹ÑBÐBùó1ùâBs   Á!BÁ*Bz|digraph{

# Graph style
%(graphstyle)s

#########
# Nodes #
#########

%(nodes)s

#########
# Edges #
#########

%(edges)s
}ÚTDÚout)ÚrankdirÚorderingc                 ó,   • [        U [        5      (       + $ rC   rD   rE   s    r"   rF   rF   »   s   € ¬j¸¼EÓ.BÕ*Br#   Nc           	      óú   ^^^^^^^	^
• [         R                  5       nUR                  U5        / m	/ mSUUUUU	UUU
4S jjm
T
" U S5        [        [	        USS9SR                  T	5      SR                  T5      S.-  $ )a°  DOT description of a SymPy expression tree

Parameters
==========

styles : list of lists composed of (Class, mapping), optional
    Styles for different classes.

    The default is

    .. code-block:: python

        (
            (Basic, {'color': 'blue', 'shape': 'ellipse'}),
            (Expr,  {'color': 'black'})
        )

atom : function, optional
    Function used to determine if an arg is an atom.

    A good choice is ``lambda x: not x.args``.

    The default is ``lambda x: not isinstance(x, Basic)``.

maxdepth : integer, optional
    The maximum depth.

    The default is ``None``, meaning no limit.

repeat : boolean, optional
    Whether to use different nodes for common subexpressions.

    The default is ``True``.

    For example, for ``x + x*y`` with ``repeat=True``, it will have
    two nodes for ``x``; with ``repeat=False``, it will have one
    node.

    .. warning::
        Even if a node appears twice in the same object like ``x`` in
        ``Pow(x, x)``, it will still only appear once.
        Hence, with ``repeat=False``, the number of arrows out of an
        object might not equal the number of args it has.

labelfunc : function, optional
    A function to create a label for a given leaf node.

    The default is ``str``.

    Another good option is ``srepr``.

    For example with ``str``, the leaf nodes of ``x + 1`` are labeled,
    ``x`` and ``1``.  With ``srepr``, they are labeled ``Symbol('x')``
    and ``Integer(1)``.

**kwargs : optional
    Additional keyword arguments are included as styles for the graph.

Examples
========

>>> from sympy import dotprint
>>> from sympy.abc import x
>>> print(dotprint(x+2)) # doctest: +NORMALIZE_WHITESPACE
digraph{
<BLANKLINE>
# Graph style
"ordering"="out"
"rankdir"="TD"
<BLANKLINE>
#########
# Nodes #
#########
<BLANKLINE>
"Add(Integer(2), Symbol('x'))_()" ["color"="black", "label"="Add", "shape"="ellipse"];
"Integer(2)_(0,)" ["color"="black", "label"="2", "shape"="ellipse"];
"Symbol('x')_(1,)" ["color"="black", "label"="x", "shape"="ellipse"];
<BLANKLINE>
#########
# Edges #
#########
<BLANKLINE>
"Add(Integer(2), Symbol('x'))_()" -> "Integer(2)_(0,)";
"Add(Integer(2), Symbol('x'))_()" -> "Symbol('x')_(1,)";
}

c           
      ó&  >• T	R                  [        U TTUT
S95        T(       a  UT:¼  a  g TR                  [        U TUT
S95        [	        U R
                  5       VVs/ s H#  u  p4T" U5      (       a  M  T" XAS-   X#4-   5      PM%       nng s  snnf )N)r=   r>   r?   )rJ   r>   r?   é   )ÚappendrA   ÚextendrN   rI   r   )ÚeÚdepthr>   rL   ÚargrJ   Úedgesr=   ÚmaxdepthÚnodesr?   r'   Útraverses        €€€€€€€€r"   r_   Údotprint.<locals>.traverse  s}   ø€ Ø�‰”W˜Q °)ÀÈVÑTÔUÞ˜ Ó)ØØ�‰”X˜a d°¸FÑCÔDÜ:CÀAÇFÁFÔ:KÔ]Ò:K±°ÑSWÐX[×S\Ó	+‰�#˜Q‘w  d¡
Ö	+Ñ:KÓ]ùÓ]s   ÁBÁ6Br   Ú
)r5   )Ú
graphstyler^   r\   )r   )Ú_graphstyleÚcopyr%   Útemplater6   r   )r&   r'   rJ   r]   r?   r=   Úkwargsrb   r\   r^   r_   s    `````  @@@r"   r
   r
   º   sw   ÿ€ ôz ×!Ñ!Ó#€JØ×Ñ�fÔà€EØ€E÷^ö ^ñ ˆT�1Ôä¤9¨ZÀ4Ñ#HØ"Ÿi™i¨Ó.Ø"Ÿi™i¨Ó.ñ0ñ 0ð 0r#   )F)r   )Úsympy.core.basicr   Úsympy.core.exprr   Úsympy.core.symbolr   Úsympy.core.numbersr   r   r   Úsympy.printing.reprr	   Ú__all__Údefault_stylesÚslotClassesr   r+   r6   r   rA   rN   re   rc   r
   r   r#   r"   Ú<module>ro      s±   ðÝ "Ý  Ý $ß 7Ñ 7Ý %àˆ,€ð �f yÑ1Ð2Ø	ˆW�gÐÐð€ð
 �w ¨%Ð0€ô<ð~ (ô ô2
Jð (°3¸BÀtô 7ñ0 ;ÀÈ4ô Cð4ð 	ð& ¨EÑ2€ð Ñ BØ˜$¨#õl0r#   