� ��gR ����ddlmZddlmZddlmZddlmZmZm Z ddl m Z dgZ eddd �fed d iffZ eeee fZdd �Ze fd�Zdd�Ze eddfd�Zd�ddfd�ZdZddd�Ze d�ddefd�ZdS)�)�Basic)�Expr)�Symbol)�Integer�Rational�Float)�srepr�dotprint�blue�ellipse)�color�shaper �blackFc�:�d}t|t��st|��}nm|jst |��}nV|j}t t t|����}t|��j �dd� |���d�}|r||f}|S)aNA 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�rvrs �b/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/printing/dot.pyrrs���b �E� �a�� � �;� ��V�V��� �V�;� �1�X�X����v���c�'�4�(�(�)�)���A�w�w�'�'�'����5�)9�)9�)9�)9� :���� ��Y�� �I�c�d�i}|D]*\}}t||��r|�|���+|S)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+NsF��$ �E������S� �d�C� � � � �L�L�� � � �� �Lr#rc�~�|�d�t|�����D����S)z� Print a dictionary of attributes Examples ======== >>> from sympy.printing.dot import attrprint >>> print(attrprint({'color': 'blue', 'shape': 'ellipse'})) "color"="blue", "shape"="ellipse" c3� K�|] }d|zV�� dS)z "%s"="%s"Nr)�.0�items r"� <genexpr>zattrprint.<locals>.<genexpr>qs'����I�I�t�+�d�*�I�I�I�I�I�Ir#)r�sorted�items)�d� delimiters r"� attrprintr5gs5�� �>�>�I�I�v�a�g�g�i�i�7H�7H�I�I�I� I� I�Ir#rTc�&�t||��}t|t��r!|jst |jj��}n ||��}||d<t|��}|r|dt |��zz }d|�dt|���d�S)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+rr�is_Atomr� __class__rrr5)r&r'� labelfunc�pos�repeatr(r7�expr_strs r"�dotnoder@ts��� �D�&� !� !�E��$���� �t�|� ��D�N�+�,�,���� �$�����E�'�N��t�}�}�H� �%��E�C��H�H�$�$���#�8�8�Y�u�%5�%5�%5�%5� 6�6r#c�.�t|t�� S�N�rr�rs r"�<lambda>rE�s��j��E�&:�&:�":�r#c�����||��rgSt|d���\�}|r0�dt���zz ��fd�t|��D��}�fd�|D��S)a� 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)rr8c�F��g|]\}}|�dt�|fz������S)�_)r)r.�i�ar=s �r"� <listcomp>zdotedges.<locals>.<listcomp>�sD���1�1�1��A�q�$%�1�1�c�#���*�o�o�o�6�1�1�1r#c�"��g|] }d��d|�d��� S)r9z" -> "z";r)r.rJr?s �r"rKzdotedges.<locals>.<listcomp>�s(���B�B�B�A�A�8�8�8�Q�Q�Q�/�B�B�Br#)rr� enumerate)r&�atomr=r>�arg_strsr?s ` @r"�dotedgesrP�s����� �t�D�z�z�C�� �$�T�T�:�:�:���(� � 1� ���C���(� (�H�1�1�1�1�%�h�/�/�1�1�1�H�B�B�B�B��B�B�B�Br#z|digraph{ # Graph style %(graphstyle)s ######### # Nodes # ######### %(nodes)s ######### # Edges # ######### %(edges)s }�TD�out)�rankdir�orderingc�.�t|t�� SrBrCrDs r"rErE�s��j��E�.B�.B�*B�r#Nc �.������� � �t���}|�|��g� g�d����� ��� fd� � � |d��tt |d���d�� ��d����d�zS)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,)"; } rc �������t|� ���������r��krdS��t|������������ fd�t |j��D��dS)N)r<r=r>)rNr=r>c�T��g|]$\}}�|����|�dz�|fz����%S)�r)r.rI�argrN�depthr=�traverses ����r"rKz.dotprint.<locals>.traverse.<locals>.<listcomp>!sG���]�]�]���3�SW�SW�X[�S\�S\�]���#�u�Q�w��q�d� � +� +�]�]�]r#)�appendr@�extendrPrMr) �er[r=rN�edgesr<�maxdepth�nodesr>r'r\s ``��������r"r\zdotprint.<locals>.traverses������ � � �W�Q��)��V�T�T�T�U�U�U� � ���)�)� �F� � � �X�a�d��F�C�C�C�D�D�D�]�]�]�]�]�]�]�)�A�F�:K�:K�]�]�]�]�]�]r#r� )r4)� graphstylerbr`)r)� _graphstyle�copyr%�templater5r) r&r'rNrar>r<�kwargsrdr`rbr\s ````` @@@r"r r �s�����������z�!�!�#�#�J����f���� �E� �E�^�^�^�^�^�^�^�^�^�^�^�^�^�  �H�T�1���� �9�Z�4�#H�#H�#H�"�i�i��.�.�"�i�i��.�.�0�0� 0�0r#)F)r)�sympy.core.basicr�sympy.core.exprr�sympy.core.symbolr�sympy.core.numbersrrr�sympy.printing.reprr �__all__�default_styles� slotClassesrr+r5rr@rPrgrer rr#r"�<module>rqs���"�"�"�"�"�"� � � � � � �$�$�$�$�$�$�7�7�7�7�7�7�7�7�7�7�%�%�%�%�%�%� �,�� �f�y� 1� 1�2� �W�g� ���� �w��%�0� �<�<�<�<�~(�����2 J� J� J� J�(�3�B�t�7�7�7�7�0;�:��4�C�C�C�C�4� �&�E�2�2� � � B� B� �$�#�l0�l0�l0�l0�l0�l0r#
Memory