Ë
    7^(hã/  ã                   ó¶   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d„ Zdd„Zd„ Zdd„Zd„ Zd„ Zd„ Zy)é    ©ÚTuple)ÚBasic)ÚExpr)ÚAppliedUndef)Ú
Relational)ÚDummy)Úsympify)ÚBooleanFunction)ÚImageSet)Ú	FiniteSet)ÚIndexedc                 óÊ  — t        | t        t        t        f«      s| g} t	        d„ | D «       «      r
t        «       S  t        «       j
                  | D �cg c]  }|j                  t        «      ‘Œ c}Ž } |j
                  | D �cg c]  }|j                  t        «      ‘Œ c}Ž }|xs/  t        «       j
                  | D �cg c]  }|j                  ‘Œ c}Ž S c c}w c c}w c c}w )a  Returns 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)
    c              3   ó2   K  — | ]  }t        |«      –— Œ y ­w©N©Úcallable)Ú.0Úes     úR/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/plotting/utils.pyú	<genexpr>z$_get_free_symbols.<locals>.<genexpr>   s   è ø€ Ò
&˜1Œ8�A�;Ñ
&ùs   ‚)
Ú
isinstanceÚlistÚtupleÚsetÚallÚunionÚatomsr   r   Úfree_symbols)Úexprsr   Úfrees      r   Ú_get_free_symbolsr"      s­   € ô �eœd¤E¬3Ð/Ô0Ø�ˆÜ
Ñ
& Ô
&Ô&Ü‹uˆàŒ3‹5�;‰;°5Ö9¨a˜Ÿ™¤Õ)Ò9Ð:€DØˆ4�:‰:°uÖ=°!˜Ÿ™¤Õ-Ò=Ð>€DØÒ@�;”3“5—;‘;¸Ö ?°A §£Ò ?Ð@Ð@ùò :ùÚ=ùÚ ?s   ÁCÂCÂ?C c           	      óÔ   — | j                  t        «      }|D ]H  }t        |«      }t        t	        d«      D �cg c]  }t        |«      ‘Œ c}Ž }| j                  ||«      } ŒJ | S c c}w )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.
    r   )Úfindr   Úiterr   ÚrangeÚnextÚsubs)Úset_solÚnÚimagesÚimÚitÚss         r   Úextract_solutionr/   !   se   € ð �\‰\œ(Ó#€FØò &ˆÜ�"‹XˆÜ¬%°°1«+Ö6 Qœ˜R�Ò6Ð7ˆØ—,‘,˜r 1Ó%‰ð&ð €Nùò 7s   ¹A%
c                 óx  — t        | t        «      r| S t        | «      } t        | «      D ]Ž  \  }}t        |t        t        f«      rt        t        |«      ddiŽ| |<   Œ4t        |t        t        f«      rŒKt        |«      rŒW|j                  j                  dk(  rt        |t        «      sŒ�t        |«      | |<   Œ� | S )a  This 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   r   r   Ú	enumerater   r   Ú_plot_sympifyÚstrÚdictr   Ú	__class__Ú__name__r   r
   )ÚargsÚiÚas      r   r3   r3   6   sž   € ô �$œÔØˆä�‹:€DÜ˜$“ò 
!‰ˆˆ1Ü�aœ$¤˜Ô'Üœ]¨1Ó-Ð=°uÑ=ˆD�ŠGÜ˜Q¤¤d Õ,´¸µð
 —‘×%Ñ%¨Ò1¼:ÀaÌÕ;Oä˜a“jˆD�ŠGð
!ð €Kó    Nc                 ó   — d„ }t        | «      }|�|j                  |j                  «       «      }t        |«      |kD  r9t	        ddj                  |«      z   dj                  t        |«      |«      z   «      ‚t        |«      |kD  rt	        dt        |«      ›d|›�«      ‚t        «       j                  |D �cg c]  }|d   ‘Œ	 c}«      }t        |«      t        |«      k7  rt	        d«      ‚t        |«      |k  rw|j                  |«      }	|	t        «       k7  r|	D ]  }
|j                   ||
«      «       Œ t        |t        |«      z
  «      D ]!  }|j                   |t        «       «      «       Œ# t        |«      |k(  rvt        «       j                  |D �cg c]  }|d   ‘Œ	 c}«      }t        |j                  |«      «      dkD  r/t	        d	d
j                  |«      z   dj                  |«      z   «      ‚|S c c}w c c}w )a  This 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        | dd«      S )Niöÿÿÿé
   r   )Úsymbols    r   ú<lambda>z _create_ranges.<locals>.<lambda>l   s   € ¤u¨V°S¸"Ó'=€ r;   zToo many free symbols.
zExpected {} free symbols.
zReceived {}: {}zToo many ranges. Received z, expected r   z$Multiple ranges with the same symbolz>Incompatible free symbols of the expressions with the ranges.
z$Free symbols in the expressions: {}
zFree symbols in the ranges: {})r"   Ú
differenceÚkeysÚlenÚ
ValueErrorÚformatr   r   Úappendr&   r	   )r    ÚrangesÚnparÚlabelÚparamsÚget_default_ranger   ÚrÚrfsÚsymbolsr.   r9   s               r   Ú_create_rangesrO   U   sï  € ñ. >Ðä$ UÓ+€LØÐØ#×.Ñ.¨v¯{©{«}Ó=ˆä
ˆ<Ó˜4ÒÜØ&Ø+×2Ñ2°4Ó8ñ9à×&Ñ&¤s¨<Ó'8¸,ÓGñHó
ð 	
ô ˆ6ƒ{�TÒÝÜ;>¸v½;ÉÐMóOð 	Oô ‹%�+‰+ VÖ, �q˜“tÒ,Ó
-€CÜ
ˆ3ƒx”3�v“;ÒÜÐ?Ó@Ð@ä
ˆ6ƒ{�TÒØ×)Ñ)¨#Ó.ˆØ”c“eÒàò 4�Ø—‘Ñ/°Ó2Õ3ð4ô �tœc &›kÑ)Ó*ò 	6ˆAØ�M‰MÑ+¬E«GÓ4Õ5ð	6ô ˆ<Ó˜DÒ ô ‹e�k‰k¨Ö0 A˜1˜Q›4Ò0Ó1ˆÜˆ|×&Ñ& sÓ+Ó,¨qÒ0Üð à9×@Ñ@ÀÓNñOð 3×9Ñ9¸#Ó>ñ?óð ð €Mùò5 -ùò$ 1s   Â6G6ÆG;c                 ó.  — t        | t        «      xr„ t        | «      dk(  xrt t        | j                  d   t        «       xrT | j                  d   j
                  xr9 t        | j                  d   t        «       xr | j                  d   j
                  S )zUA range is defined as (symbol, start, end). start and end should
    be numbers.
    é   é   é   )r   r   rC   r8   r4   Ú	is_number)rL   s    r   Ú	_is_rangerU   ›   sŒ   € ô 	�1”eÓò 	EÜ�‹V�q‰[ò	Eä˜AŸF™F 1™I¤sÓ+Ð+ò	Eà12·±¸±×1DÑ1Dò	Eô ˜AŸF™F 1™I¤sÓ+Ð+ò	Eð 23·±¸±×1DÑ1Dð	r;   c                  óÌ  — | D �cg c]  }t        |«      sŒ|‘Œ }}| D �cg c]  }t        |t        «      sŒ|‘Œ }}|sdn|d   }| D �cg c]  }t        |t        «      sŒ|‘Œ }}|sdn|d   }| D �cg c],  }t        |«      xs t        |t        t        f«      xs |du  ‘Œ. }}t	        | |«      D ��cg c]
  \  }}|sŒ	|‘Œ }	}}|	|||fS c c}w c c}w c c}w c c}w c c}}w )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)
    Nr   )rU   r   r4   r5   Úzip)
r8   ÚtrG   ÚlabelsrI   Úrendering_kwr:   ÚresultsÚbr    s
             r   Ú_unpack_argsr]   ¨   sê   € ð4 Ö.�A¤¨1¥ŠaÐ.€FÐ.ØÖ4�A¤¨A¬sÕ!3ŠaÐ4€FÐ4Ù‰D F¨1¡I€EØ#Ö;˜!¤z°!´TÕ':’AÐ;€LÐ;Ù+‘4°¸a±€Lð Y]Ö]ÐST”I˜a“LÒM¤J¨q´3¼°+Ó$>ÒMÀ1ÈÀ9ÒNÐ]€GÐ]Ü˜t WÓ-×3‘4�1�a²ŠQÐ3€EÑ3Ø�&˜% Ð-Ð-ùò /ùÚ4ùâ;ùò ^ùÛ3s2   …C–C C¶CÁ	CÁCÁ21CÂ4
C Â?C c                 ó&  — | sg S g }|j                  dd«      }t        d„ | d| D «       «      r¯t        | Ž \  }}}}	 t        «       j                  |D �
cg c]  }
|
j
                  ‘Œ c}
Ž }t        |||||«      }|dkD  rt        |«      |k(  rt        |«      f}|D ]>  }t        |t        t        t        f«      }|r|fn|}
|j                  g |
¢|¢|‘|	‘­«       Œ@ |S t        | Ž \  }}}}	|r|gng }t        |«      t        |«      z   |	�t        |	«      ndz   }|dkD  r| d|  n| }t        |d   t        t        t        f«      s|g}|D �]'  }|D �cg c]  }t        |t         «      sŒ|‘Œ }}|s|}|D �cg c]  }t#        |«      sŒ|‘Œ }}|s|j%                  «       }|D �cg c]  }t        |t&        «      sŒ|‘Œ }}t        |«      dk(  r|	n|d   }t)        |«      D �cg c]  }||   ‘Œ	 }}t        «       }t        d„ |D «       «      r' |j                  |D �cg c]  }|j
                  ‘Œ c}Ž }t        |«      |k7  rt        |||d|«      }|sdn|d   }|j                  g |¢|¢|‘|‘­«       �Œ* |S c c}
w c c}w c c}w c c}w c c}w c c}w )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)]
    rJ   Nc              3   óR   K  — | ]  }t        |t        t        t        f«      –— Œ! y ­wr   )r   r   r   r   ©r   r:   s     r   r   z#_check_arguments.<locals>.<genexpr>  s   è ø€ Ò
TÀ!Œ:�aœ$¤
¬OÐ<×=Ñ
Tùs   ‚%'rR   r   c              3   ó4   K  — | ]  }t        |«       –— Œ y ­wr   r   r`   s     r   r   z#_check_arguments.<locals>.<genexpr><  s   è ø€ Ò0 q”x “{”?Ñ0ùs   ‚Ú )Úgetr   r]   r   r   r   rO   rC   r   r   r   r   r   rF   r   r   r4   rU   Úcopyr5   r&   )r8   ÚnexprrH   ÚkwargsÚoutputrJ   r    rG   rI   rZ   r   r   ÚexprÚis_exprÚ_rY   r*   Únew_argsÚargr:   ÚlrL   Úrend_kwr9   s                           r   Ú_check_argumentsro   Î   sÈ  € ñ` Øˆ	Ø€FØ�Z‰Z˜ $Ó'€Fä
Ñ
TÀtÈFÈUÀ|Ô
TÔTô
 .:¸4Ð-@Ñ*ˆˆv�u˜lØ"”s“u—{‘{¸UÖ$C¸ Q§^£^Ò$CÐDˆÜ  v¨t°U¸FÓCˆà�1Š9ô �5‹z˜UÒ"Ü˜u›˜�Øò 	>ˆDô ! ¬¬j¼/Ð'JÓKˆGÙ"�‘¨ˆAØ�M‰MÐ<˜AÐ< Ð<¨Ð<¨|Ñ<Õ=ð	>ðd €MôM +7¸Ð*=Ñ'ˆˆ6�6˜<Ù#�&‘¨ˆô �‹[œ3˜v›;Ñ&Ø".Ð":ŒS�ÔÀñCˆà ! A¢�4˜˜!˜‘9¨4ˆô
 ˜( 1™+¬¬e´UÐ';Ô<Ø �zˆHð ó 	6ˆCàÖ6�q¤:¨a´Õ#5’Ð6ˆAÐ6ÙØ�ØÖ0�q¤9¨Q¥<’Ð0ˆAÐ0ÙØ—K‘K“M�Ø"%Ö=˜Q¬°A´tÕ)<’qÐ=ˆGÐ=Ü&)¨'£l°aÒ&7‘l¸WÀQ¹ZˆGô $)¨£<Ö0˜a�3�q“6Ð0ˆCÐ0Ü›5ˆLÜÑ0¨CÔ0Ô0Ø1˜|×1Ñ1ÈCÖ3PÀq°A·N³NÒ3PÐQ�Ü�1‹v˜Š~Ü" 3¨¨4°°VÓ<�á !‘D q¨¡tˆEØ�M‰MÐ4˜CÐ4 !Ð4 UÐ4¨GÑ4Ö5ð+	6ð, €Mùòu %DùòL 7ùò 1ùò >ùò
 1ùò 4Qs6   ÁI5ÅI:Å&I:Å4I?ÆI?Æ!JÆ7JÇJ	ÈJ
)r>   )rb   N)Ú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.indexedr   r"   r/   r3   rO   rU   r]   ro   © r;   r   ú<module>r|      sN   ðÝ 'Ý "Ý  Ý ,Ý ,Ý #Ý &Ý /Ý )Ý %Ý (òAó&ò*ó>CòL
ò#.óLur;   