� ��g�;� ��dZddlmZddlmZddlmZddlmZdZ dZ dZ dd �Z d �Z d�Zd�Zd gd d fd�Zd�Zd d d d d d d d d d d gf d�Zd S)z+Tools for setting up interactive sessions. �)� GROUND_TYPES)� version_tuple)� init_printing)�ARCHz�from sympy import * x, y, z, t = symbols('x y z t') k, m, n = symbols('k m n', integer=True) f, g, h = symbols('f g h', cls=Function) init_printing() zjThese commands were executed: %(source)s Documentation can be found at https://docs.sympy.org/%(version)s z�Could not locate IPython. Having IPython installed is greatly recommended. See http://ipython.scipy.org for more details. If you use Debian/Ubuntu, just install the 'ipython' package and start isympy again. TFNc�:�ddlm}ddlm}ddl}ddl}|rdSd|jdd�z}|rd}nd }d t zg} |�d ��} | �-| ���d kr| � d ��|r| � d��|||td� | ��f} d| z} |�t}d} |� d��dd�D]}|s| dz } � | d|zdzz } �|}d|vrd}nd|z}| dt| |d�zzz } | S)z,Create a banner for an interactive session. r)� __version__)� SYMPY_DEBUGN�z%d.%d.%d��IPython�Pythonzground types: %s�SYMPY_USE_CACHE�noz cache: offz debugging: onz, z,%s console for SymPy %s (Python %s-%s) (%s) � �����z>>> �devz%s/)�source�version)�sympyrr �sys�os� version_infor�getenv�lower�appendr�join�preexec_source�split�verbose_message)�ipython�quietr� sympy_versionr rr�python_version� shell_name�info�cache�args�message�_source�line� doc_versions �i/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/interactive/session.py� _make_messager-s���2�2�2�2�2�2�!�!�!�!�!�!��J�J�J� �I�I�I� ���r��#�"2�2�A�2�"6�6�N���� � �� � �� -� .�D� �I�I�'� (� (�E� ��U�[�[�]�]�d�2�2� � � �L�!�!�!��%� � � �O�$�$�$� �}�n�d�D�I�I�d�O�O� K�D�=��D�G� �~����G�� � �T�"�"�3�B�3�'�,�,��� ,� �t�O�G�G� �v��}�t�+� +�G�G��K� � ���� � ��k�)� � �t�o�7�4?�)A�)A�A�A�A�G� �N�c�&�ddlm}m}m}m}m}ddlm}d�}g}|||��j��} | D]R\} } } } } | |kr-|| ��r"|� |df|df|| f|dfg���;|� | | f���S||��S)aw Wrap integer literals with Integer. This is based on the decistmt example from https://docs.python.org/3/library/tokenize.html. Only integer literals are converted. Float literals are left alone. Examples ======== >>> from sympy import Integer # noqa: F401 >>> from sympy.interactive.session import int_to_Integer >>> s = '1.2 + 1/2 - 0x12 + a1' >>> int_to_Integer(s) '1.2 +Integer (1 )/Integer (2 )-Integer (0x12 )+a1 ' >>> s = 'print (1/2)' >>> int_to_Integer(s) 'print (Integer (1 )/Integer (2 ))' >>> exec(s) 0.5 >>> exec(int_to_Integer(s)) 1/2 r)�generate_tokens� untokenize�NUMBER�NAME�OP)�StringIOc�j�d|vs,d|���vsd|���vrdSdS)z] Returns true if string value num (with token NUMBER) represents an integer. �.�j�eFT)r)�nums r,�_is_intzint_to_Integer.<locals>._is_intqs;�� �#�:�:��� � � � �+�+�s�c�i�i�k�k�/A�/A��5��tr.�Integer�(�)) �tokenizer0r1r2r3r4�ior5�readline�extendr) �sr0r1r2r3r4r5r;�result�g�toknum�tokval�_s r,�int_to_IntegerrIUs ��2G�F�F�F�F�F�F�F�F�F�F�F�F�F�����������F������ � �,�-�-�A�#$� ,� ,�����1�a� �V� � ������ � �M�M��y�!��S� ��� ��S� � � � � � � �M�M�6�6�*� +� +� +� +� �:�f� � �r.c�:���ddl�|j���fd�}||_dS)zM Allow IPython to automatically convert integer literals to Integer. rNc��� ��|��t|��}n#t$rYnwxYw�|g|�Ri|��S�N)�parserI� SyntaxError)�cellr'�kwargs�ast� old_run_cells ��r,� my_run_cellz7enable_automatic_int_sympification.<locals>.my_run_cell�sn��� (� �I�I�d�O�O�O�"�$�'�'�D�D��� � � � �D� �����|�D�2�4�2�2�2�6�2�2�2s �(� 5�5)rQ�run_cell)�shellrSrQrRs @@r,�"enable_automatic_int_sympificationrV�sA�����J�J�J��>�L� 3� 3� 3� 3� 3� 3�!�E�N�N�Nr.c�~��ddl}|�d���d�fd� }|�tf|��dS)z?Allow IPython to automatically create symbols (``isympy -a``). rNz8name '(?P<symbol>[A-Za-z_][A-Za-z0-9_]*)' is not definedc����|tu�r<|j�r4|jj�s'��t|����}|��|�dd|�d��izd��� |jdd}|�|d��� |�d|�d��zd���dS#ttf$rYnwxYw |�d|�d��zd���n2#|�d|�d��zd���wxYw|j � ||||� ��}|� |||��dS) zJHandle :exc:`NameError` exception and allow injection of missing symbols. Nz!%(symbol)s = Symbol('%(symbol)s')�symbolF)� store_history�Inrzdel %s)� tb_offset) � NameError�tb_next�match�strrT�group�user_ns�KeyError� IndexError� InteractiveTB�structured_traceback�_showtraceback) �self�etype�value�tbr\r_�code�stb� re_nameerrors �r,�_handlerz*enable_automatic_symbols.<locals>._handler�s���� �I� � �"�*� �R�Z�5G� � �&�&�s�5�z�z�2�2�E�� �� � �A�'����X�)>�)>�?�@�OT��V�V�V� 7��<��-�b�1�D��M�M�$�e�M�<�<�<���M�M�(�U�[�[��-B�-B�"B�05�"�7�7�7�7�7�� !�*�-�����D������ �M�M�(�U�[�[��-B�-B�"B�05�"�7�7�7�7��D�M�M�(�U�[�[��-B�-B�"B�05�"�7�7�7�7����� �5�5� �5�"� �6�3�3�� ���E�5�#�.�.�.�.�.s*�6C� D�C$�!D�#C$�$D�/ErL)�re�compile�set_custom_excr])rUrprorns @r,�enable_automatic_symbolsrs�se���N�I�I�I��:�:�B�D�D�L�/�/�/�/�/�/�2 ���)��x�0�0�0�0�0r.c��ddl}t|j��td��kr�|sit|j��td��krddlm}nddlm}|���}d|_|�|��|j }|rt|��|rt|��|Sddl m }||��S)zConstruct new IPython session. rN�0.11z1.0)�ipappF)� make_IPython)r rr�IPython.terminalrv�IPython.frontend.terminal�TerminalIPythonApp�display_banner� initializerUrsrV� IPython.Shellrw)rU�argv� auto_symbols�auto_int_to_Integerr rv�apprws r,�init_ipython_sessionr��s����N�N�N��W�(�)�)�]�6�-B�-B�B�B�� � �W�0�1�1�]�5�5I�5I�I�I�2�2�2�2�2�2�2�;�;�;�;�;�;��*�*�,�,�C�"'�C� � �N�N�4� � � ��I�E� � ,� $�U� +� +� +� � 6� .�u� 5� 5� 5�� �.�.�.�.�.�.��|�D�!�!�!r.c�D��ddlm�G�fd�d���}|��S)zConstruct new Python session. r��InteractiveConsolec���eZdZdZ�fd�ZdS)�)init_python_session.<locals>.SymPyConsolez.An interactive console with readline support. c����i}��||��� ddl}ddl}ddl}ddl}|�|�|��j��|�d��t|d��r^|j � d��} |� |��n#t$rYnwxYw|�|j|��dSdS#t $rYdSwxYw)N)�localsrz tab: complete�read_history_filez~/.sympy-history)�__init__� rlcompleterrAr�atexit� set_completer� Completer�complete�parse_and_bind�hasattr�path� expanduserr��OSError�register�write_history_file� ImportError)rh� ns_localsr�rArr��historyr�s �r,r�z2init_python_session.<locals>.SymPyConsole.__init__s>����I� � '� '��Y� '� ?� ?� ?� J�"�"�"�"������ � � �� � � ��&�&�{�'<�'<�Y�'G�'G�'P�Q�Q�Q��'�'��8�8�8��8�%8�9�9�J� �g�0�0�1C�D�D�G�� �2�2�7�;�;�;�;��"�����������O�O�H�$?��I�I�I�I�I�J�J��� � � ���� ���s#�C�B/�/ B<�;B<� C,�+C,N)�__name__� __module__� __qualname__�__doc__r�r�s�r,� SymPyConsoler� s;�������<�<� J� J� J� J� J� J� Jr.r�)rlr�)r�r�s @r,�init_python_sessionr� sb���'�'�'�'�'�'�J�J�J�J�J�J�J�)�J�J�J�8 �<�>�>�r.c ���ddl} d} |dura ddl} ddlm}|���n7#t$rd�Yn)wxYw#t$r|durt d���d�YnwxYwt ���} |�| }|durt ����j}ntt�| ||����t|j ��td��kr3d�fd � �_ �� d� ��n#t$rYnwxYw| s�j}|r6|r%t|j ��td��krt d ���|r6|r%t|j ��td��krt d ���t}�� |d ���t!||||�|| | ���t#|||��}| s0t%|��|��| �d��dSt%|��ddl}|�d���dS)u� Initialize an embedded IPython or Python session. The IPython session is initiated with the --pylab option, without the numpy imports, so that matplotlib plotting can be interactive. Parameters ========== pretty_print: boolean If True, use pretty_print to stringify; if False, use sstrrepr to stringify. order: string or None There are a few different settings for this parameter: lex (default), which is lexographic order; grlex, which is graded lexographic order; grevlex, which is reversed graded lexographic order; old, which is used for compatibility reasons and for long expressions; None, which sets it to lex. use_unicode: boolean or None If True, use unicode characters; if False, do not use unicode characters. use_latex: boolean or None If True, use latex rendering if IPython GUI's; if False, do not use latex rendering. quiet: boolean If True, init_session will not print messages regarding its status; if False, init_session will print messages regarding its status. auto_symbols: boolean If True, IPython will automatically create symbols for you. If False, it will not. The default is False. auto_int_to_Integer: boolean If True, IPython will automatically wrap int literals with Integer, so that things like 1/2 give Rational(1, 2). If False, it will not. The default is False. ipython: boolean or None If True, printing will initialize for an IPython console; if False, printing will initialize for a normal console; The default is None, which automatically determines whether we are in an ipython instance or not. str_printer: function, optional, default=None A custom string printer function. This should mimic sympy.printing.sstrrepr(). pretty_printer: function, optional, default=None A custom pretty printer. This should mimic sympy.printing.pretty(). latex_printer: function, optional, default=None A custom LaTeX printer. This should mimic sympy.printing.latex() This should mimic sympy.printing.latex(). argv: list of arguments for IPython See sympy.bin.isympy for options that can be used to initialize IPython. See Also ======== sympy.interactive.printing.init_printing: for examples and the rest of the parameters. Examples ======== >>> from sympy import init_session, Symbol, sin, sqrt >>> sin(x) #doctest: +SKIP NameError: name 'x' is not defined >>> init_session() #doctest: +SKIP >>> sin(x) #doctest: +SKIP sin(x) >>> sqrt(5) #doctest: +SKIP ___ \/ 5 >>> init_session(pretty_print=False) #doctest: +SKIP >>> sqrt(5) #doctest: +SKIP sqrt(5) >>> y + x + y**2 + x**2 #doctest: +SKIP x**2 + x + y**2 + y >>> init_session(order='grlex') #doctest: +SKIP >>> y + x + y**2 + x**2 #doctest: +SKIP x**2 + y**2 + x + y >>> init_session(order='grevlex') #doctest: +SKIP >>> y * x**2 + x * y**2 #doctest: +SKIP x**2*y + x*y**2 >>> init_session(order='old') #doctest: +SKIP >>> x**2 + y**2 + x + y #doctest: +SKIP x + y + x**2 + y**2 >>> theta = Symbol('theta') #doctest: +SKIP >>> theta #doctest: +SKIP theta >>> init_session(use_unicode=True) #doctest: +SKIP >>> theta # doctest: +SKIP θ rNF)� get_ipythonTz'IPython is not available on this system)r~rr�ru�execc�0����|d��S)NF)rT)�srcrY�ips �r,�<lambda>zinit_session.<locals>.<lambda>�s���b�k�k�#�u�6M�6M�r.)� import_allzKautomatic construction of symbols is possible only in IPython 0.11 or abovezQautomatic int to Integer transformation is possible only in IPython 0.11 or above)rY)� pretty_print�order� use_unicode� use_latexr�� str_printer�pretty_printer� latex_printerz Exiting ...c� �td��S)Nz Exiting ... )�print�r.r,r�zinit_session.<locals>.<lambda>�s���o� 6� 6�r.)r�)rr r�r�� RuntimeError�boolr��interactr�rr� runsource� enable_pylab� Exception�mainlooprrr-r��exitr�r�)r r�r�r�r�r!rr�r�r�r�r~r� in_ipythonr r�r��_preexec_sourcer(r�r�s @r,� init_sessionr�,s����~�J�J�J��J��e��� � �N�N�N�  �/�/�/�/�/�/� �[�]�]����� � � ����� ������ � � ��$���"�#L�M�M�M��B�B�B� �����"�X�X� � �?� �G��%��� � "� "���;��� !�"�4�l�6I�K�K�K�� ��,� -� -��v�1F�1F� F� F�N�M�M�M�M�B�L� ����5��1�1�1�1��� � � � ��  ���� � #��{�H��j�W�j� �g�6I�(J�(J�]�[a�Mb�Mb�(b�(b��h�i�i�i��p�G�p�}�W�=P�/Q�/Q�Ta�bh�Ti�Ti�/i�/i��n�o�o�o�$�O��L�L���L�0�0�0��|�5�)�Y�2�)�.� -�/�/�/�/� �G�U�O�<�<�G� �8� �g������ � � � ��������� �g����� � � ����6�6�7�7�7�7�7s-�5�#� 2�2�A�A� C"�" C/�.C/)TFN)r��sympy.external.gmpyr�sympy.external.importtoolsr�sympy.interactive.printingr�sympy.utilities.miscrrr� no_ipythonr-rIrVrsr�r�r�r�r.r,�<module>r�s"��1�1�,�,�,�,�,�,�4�4�4�4�4�4�4�4�4�4�4�4�%�%�%�%�%�%����� � �3�3�3�3�l1�1�1�h!�!�!�0D1�D1�D1�N $�"�5�V[�"�"�"�"�B � � �F�D��!�T��U�%*��T�#�"�c8�c8�c8�c8�c8�c8r.
Memory