� ��g�/���ddlmZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZd �Zdd�Zd�Zdd�Zd�Zd�Zd�ZdS)���Tuple)�Basic)�Expr)� AppliedUndef)� Relational)�Dummy)�sympify)�BooleanFunction)�ImageSet)� FiniteSet)�Indexedc�F�t|tttf��s|g}t d�|D����rt��St��jd�|D���}|jd�|D���}|pt��jd�|D���S)aReturns the free symbols of a symbolic expression. If the expression contains any of these elements, assume that they are the "free symbols" of the expression: * indexed objects * applied undefined function (useful for sympy.physics.mechanics module) c3�4K�|]}t|��V��dS�N��callable��.0�es �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/plotting/utils.py� <genexpr>z$_get_free_symbols.<locals>.<genexpr>s(���� &� &�1�8�A�;�;� &� &� &� &� &� &�c�B�g|]}|�t����S�)�atomsrrs r� <listcomp>z%_get_free_symbols.<locals>.<listcomp>s$��9�9�9�a�����)�)�9�9�9rc�B�g|]}|�t����Sr)rrrs rrz%_get_free_symbols.<locals>.<listcomp>s$��=�=�=�!���� �-�-�=�=�=rc��g|] }|j�� Sr�� free_symbolsrs rrz%_get_free_symbols.<locals>.<listcomp>s�� ?� ?� ?�A��� ?� ?� ?r)� isinstance�list�tuple�set�all�union)�exprs�frees r�_get_free_symbolsr*s��� �e�d�E�3�/� 0� 0����� � &� &�� &� &� &�&�&���u�u� � �3�5�5�;�9�9�5�9�9�9� :�D� �4�:�=�=�u�=�=�=� >�D� � @�;�3�5�5�;� ?� ?�� ?� ?� ?�@�@r� c����|�t��}|D]J}t|���t�fd�t d|��D���}|�||��}�K|S)a�Extract numerical solutions from a set solution (computed by solveset, linsolve, nonlinsolve). Often, it is not trivial do get something useful out of them. Parameters ========== n : int, optional In order to replace ImageSet with FiniteSet, an iterator is created for each ImageSet contained in `set_sol`, starting from 0 up to `n`. Default value: 10. c�.��g|]}t�����Sr)�next)r�n�its �rrz$extract_solution.<locals>.<listcomp>1s���6�6�6�Q��R���6�6�6rr)�findr �iterr �range�subs)�set_solr/�images�im�sr0s @r�extract_solutionr9!sq����\�\�(� #� #�F��&�&�� �"�X�X�� �6�6�6�6�%��1�+�+�6�6�6� 7���,�,�r�1�%�%��� �Nrc��t|t��r|St|��}t|��D]�\}}t|ttf��rt t |��ddi�||<�>t|ttf��sFt|��s7|j j dkrt|t��rt|��||<��|S)aThis function recursively loop over the arguments passed to the plot functions: the sympify function will be applied to all arguments except those of type string/dict. Generally, users can provide the following arguments to a plot function: expr, range1 [tuple, opt], ..., label [str, opt], rendering_kw [dict, opt] `expr, range1, ...` can be sympified, whereas `label, rendering_kw` can't. In particular, whenever a special character like $, {, }, ... is used in the `label`, sympify will raise an error. r F�Vector)r"rr#� enumerater$r� _plot_sympify�str�dictr� __class__�__name__rr )�args�i�as rr=r=6s����$������ � ��:�:�D��$��� !� !���1� �a�$��� '� '� !��]�1�-�-�=�u�=�=�D��G�G��Q��d� �,�,� !��� � � !� ��%��1�1�:�a��;O�;O�1��a�j�j�D��G�� �Kr�Nc���d�}t|��}|�'|�|�����}t|��|krIt dd�|��zd�t|��|��z���t|��|kr"t dt|���d|�����t ���d�|D����}t|��t|��krt d ���t|��|kr�|�|��}|t ��kr#|D] } |�|| �����!t|t|��z ��D],} |�|t�������-t|��|kr�t ���d �|D����}t|�|����d kr;t d d �|��zd�|��z���|S)aThis function does two things: 1. Check if the number of free symbols is in agreement with the type of plot chosen. For example, plot() requires 1 free symbol; plot3d() requires 2 free symbols. 2. Sometime users create plots without providing ranges for the variables. Here we create the necessary ranges. Parameters ========== exprs : iterable The expressions from which to extract the free symbols ranges : iterable The limiting ranges provided by the user npar : int The number of free symbols required by the plot functions. For example, npar=1 for plot, npar=2 for plot3d, ... params : dict A dictionary mapping symbols to parameters for interactive plot. c�$�t|dd��S)Ni����r+r)�symbols r�<lambda>z _create_ranges.<locals>.<lambda>ls��u�V�S�"�'=�'=�rNzToo many free symbols. zExpected {} free symbols. zReceived {}: {}zToo many ranges. Received z , expected c��g|] }|d�� S�rr�r�rs rrz"_create_ranges.<locals>.<listcomp>~s��,�,�,��q��t�,�,�,rz$Multiple ranges with the same symbolc��g|] }|d�� SrKrrLs rrz"_create_ranges.<locals>.<listcomp>�s��0�0�0�A�1�Q�4�0�0�0rrz>Incompatible free symbols of the expressions with the ranges. z$Free symbols in the expressions: {} zFree symbols in the ranges: {}) r*� difference�keys�len� ValueError�formatr%r'�appendr3r ) r(�ranges�npar�label�params�get_default_ranger!�rfs�symbolsr8rCs r�_create_rangesr\Usu��.>�=��$�U�+�+�L� ��#�.�.�v�{�{�}�}�=�=� � �<���4���� &�+�2�2�4�8�8� 9��&�&�s�<�'8�'8�,�G�G� H� � � �  �6�{�{�T����j�;>�v�;�;�;�;��� M�O�O� O� �%�%�+�+�,�,�V�,�,�,� -� -�C� �3�x�x�3�v�;�;����?�@�@�@� �6�{�{�T����)�)�#�.�.�� �c�e�e� � �� 4� 4��� � �/�/��2�2�3�3�3�3��t�c�&�k�k�)�*�*� 6� 6�A� �M�M�+�+�E�G�G�4�4� 5� 5� 5� 5� �<���D� � ��e�e�k�k�0�0��0�0�0�1�1�� �|�&�&�s�+�+� ,� ,�q� 0� 0�� �9�@�@��N�N�O�3�9�9�#�>�>�?��� � �Mrc��t|t��oxt|��dkoet|jdt�� oD|jdjo2t|jdt�� o|jdjS)zUA range is defined as (symbol, start, end). start and end should be numbers. ���)r"rrQrBr>� is_number)rMs r� _is_rangerb�s��� �1�e��� E� ��V�V�q�[� E��A�F�1�I�s�+�+� +� E�12����1D� E��A�F�1�I�s�+�+� +� E�23����1D� rc���d�|D��}d�|D��}|sdn|d}d�|D��}|sdn|d}d�|D��}d�t||��D��}||||fS)a�Given a list/tuple of arguments previously processed by _plot_sympify() and/or _check_arguments(), separates and returns its components: expressions, ranges, label and rendering keywords. Examples ======== >>> from sympy import cos, sin, symbols >>> from sympy.plotting.utils import _plot_sympify, _unpack_args >>> x, y = symbols('x, y') >>> args = (sin(x), (x, -10, 10), "f1") >>> args = _plot_sympify(args) >>> _unpack_args(*args) ([sin(x)], [(x, -10, 10)], 'f1', None) >>> args = (sin(x**2 + y**2), (x, -2, 2), (y, -3, 3), "f2") >>> args = _plot_sympify(args) >>> _unpack_args(*args) ([sin(x**2 + y**2)], [(x, -2, 2), (y, -3, 3)], 'f2', None) >>> args = (sin(x + y), cos(x - y), x + y, (x, -2, 2), (y, -3, 3), "f3") >>> args = _plot_sympify(args) >>> _unpack_args(*args) ([sin(x + y), cos(x - y), x + y], [(x, -2, 2), (y, -3, 3)], 'f3', None) c�0�g|]}t|���|��Sr�rb�r�ts rrz _unpack_args.<locals>.<listcomp>�s#�� .� .� .�A��1��� .�a� .� .� .rc�<�g|]}t|t���|��Sr�r"r>rfs rrz _unpack_args.<locals>.<listcomp>�s'�� 4� 4� 4�A��A�s�!3�!3� 4�a� 4� 4� 4rNrc�<�g|]}t|t���|��Sr�r"r?rfs rrz _unpack_args.<locals>.<listcomp>�s'��;�;�;�!�z�!�T�':�':�;�A�;�;�;rc�n�g|]2}t|��pt|ttf��p|du ��3Sr)rbr"r>r?�rrDs rrz _unpack_args.<locals>.<listcomp>�s>��]�]�]�ST�I�a�L�L�M�J�q�3��+�$>�$>�M�1��9�N�]�]�]rc��g|] \}}|�|�� Srr)rrD�bs rrz _unpack_args.<locals>.<listcomp>�s!�� 3� 3� 3�4�1�a�� 3�Q� 3� 3� 3r)�zip)rBrU�labelsrW� rendering_kw�resultsr(s r� _unpack_argsrt�s���4/� .�� .� .� .�F� 4� 4�� 4� 4� 4�F�� -�D�D�F�1�I�E�;�;�t�;�;�;�L�+�@�4�4��a��L�^�]�X\�]�]�]�G� 3� 3�3�t�W�-�-� 3� 3� 3�E� �&�%�� -�-rc ���|sgSg}|�dd��}td�|d|�D����r�t|�\}}}} t��jd�|D���} t |||||��}|dkr#t |��|krt|��f}|D]I} t| tttf��} | r| fn| } |� g| �|�|�| �R���J�n�t|�\}}}} |r|gng}t |��t |��z| �t | ��ndz}|dkr |d| �n|}t|dtttf��s|g}|D�]�d��D��}|s|}d��D��}|s|���}d ��D��}t |��dkr| n|d}�fd �t!|��D���t��} td ��D����r| jd ��D���} t |��|krt �||d |��}|sdn|d}|� g��|�|�|�R����|S)a,Checks the arguments and converts into tuples of the form (exprs, ranges, label, rendering_kw). Parameters ========== args The arguments provided to the plot functions nexpr The number of sub-expression forming an expression to be plotted. For example: nexpr=1 for plot. nexpr=2 for plot_parametric: a curve is represented by a tuple of two elements. nexpr=1 for plot3d. nexpr=3 for plot3d_parametric_line: a curve is represented by a tuple of three elements. npar The number of free symbols required by the plot functions. For example, npar=1 for plot, npar=2 for plot3d, ... **kwargs : keyword arguments passed to the plotting function. It will be used to verify if ``params`` has ben provided. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import cos, sin, symbols >>> from sympy.plotting.plot import _check_arguments >>> x = symbols('x') >>> _check_arguments([cos(x), sin(x)], 2, 1) [(cos(x), sin(x), (x, -10, 10), None, None)] >>> _check_arguments([cos(x), sin(x), "test"], 2, 1) [(cos(x), sin(x), (x, -10, 10), 'test', None)] >>> _check_arguments([cos(x), sin(x), "test", {"a": 0, "b": 1}], 2, 1) [(cos(x), sin(x), (x, -10, 10), 'test', {'a': 0, 'b': 1})] >>> _check_arguments([x, x**2], 1, 1) [(x, (x, -10, 10), None, None), (x**2, (x, -10, 10), None, None)] rXNc3�ZK�|]&}t|tttf��V��'dSr)r"rrr rms rrz#_check_arguments.<locals>.<genexpr>s3���� T� T�!�:�a�$� �O�<� =� =� T� T� T� T� T� Trc��g|] }|j�� Srr rs rrz$_check_arguments.<locals>.<listcomp> s��$C�$C�$C��Q�^�$C�$C�$Crr_rc�<�g|]}t|t���|��Srrirms rrz$_check_arguments.<locals>.<listcomp>/s'��6�6�6�q�:�a��#5�#5�6��6�6�6rc�0�g|]}t|���|��Srrerms rrz$_check_arguments.<locals>.<listcomp>2s#��0�0�0�q�9�Q�<�<�0��0�0�0rc�<�g|]}t|t���|��Srrkrms rrz$_check_arguments.<locals>.<listcomp>5s'��=�=�=�Q��A�t�)<�)<�=�q�=�=�=rc� ��g|] }�|�� Srr)rrC�args �rrz$_check_arguments.<locals>.<listcomp>:s���0�0�0�a�3�q�6�0�0�0rc3�6K�|]}t|�� V��dSrrrms rrz#_check_arguments.<locals>.<genexpr><s*����0�0�q�x��{�{�?�0�0�0�0�0�0rc��g|] }|j�� Srr rms rrz$_check_arguments.<locals>.<listcomp>=s��3P�3P�3P�q�A�N�3P�3P�3PrrE)�getr&rtr%r'r\rQr$r"rrr rTr#r�copyr3)rB�nexprrV�kwargs�outputrXr(rUrWrrr!�expr�is_exprr�_rqr/�new_args�lrM�rend_kwr|s @r�_check_argumentsr��s!���` ��� � �F� �Z�Z��$� '� '�F� � T� T�t�F�U�F�|� T� T� T�T�T�?6� .:�4�-@�*��v�u�l�"�s�u�u�{�$C�$C�U�$C�$C�$C�D� ���v�t�U�F�C�C�� �1�9�9��5�z�z�U�"�"��u������ >� >�D�!���j�/�'J�K�K�G�"�,�����A� �M�M�<�A�<��<��<�|�<�<� =� =� =� =�  >�+7��*=�'��6�6�<�#�+�&�������[�[�3�v�;�;� &�".�":�S�� � � ��C�� !�A���4��!���9�9�4�� �(�1�+��e�U�';�<�<� "� �z�H�� 6� 6�C�6�6�C�6�6�6�A�� ���0�0�C�0�0�0�A�� "��K�K�M�M��=�=�#�=�=�=�G�&)�'�l�l�a�&7�&7�l�l�W�Q�Z�G�1�0�0�0�5��<�<�0�0�0�C��5�5�L��0�0�C�0�0�0�0�0� R�1�|�1�3P�3P�C�3P�3P�3P�Q� ��1�v�v��~�~�"�3��4��V�<�<�� !�+�D�D�q��t�E� �M�M�4�C�4�!�4�U�4�G�4�4� 5� 5� 5� 5� �Mr)r+)rEN)�sympy.core.containersr�sympy.core.basicr�sympy.core.exprr�sympy.core.functionr�sympy.core.relationalr�sympy.core.symbolr �sympy.core.sympifyr �sympy.logic.boolalgr �sympy.sets.fancysetsr �sympy.sets.setsr �sympy.tensor.indexedrr*r9r=r\rbrtr�rrr�<module>r�sV��'�'�'�'�'�'�"�"�"�"�"�"� � � � � � �,�,�,�,�,�,�,�,�,�,�,�,�#�#�#�#�#�#�&�&�&�&�&�&�/�/�/�/�/�/�)�)�)�)�)�)�%�%�%�%�%�%�(�(�(�(�(�(�A�A�A�&����*���>C�C�C�C�L � � �#.�#.�#.�Lu�u�u�u�ur
Memory