ó
    Š*£hã/  ã                   óº   • S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S rSS jrS rSS jrS rS rS rg)é    ©ÚTuple)ÚBasic)ÚExpr)ÚAppliedUndef)Ú
Relational)ÚDummy)Úsympify)ÚBooleanFunction)ÚImageSet)Ú	FiniteSet)ÚIndexedc                 óô  • [        U [        [        [        45      (       d  U /n [	        S U  5       5      (       a
  [        5       $ [        5       R
                  " U  Vs/ s H  oR                  [        5      PM     sn6 nUR
                  " U  Vs/ s H  oR                  [        5      PM     sn6 nU=(       d1    [        5       R
                  " U  Vs/ s H  oR                  PM     sn6 $ s  snf s  snf s  snf )zý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   ó8   #   • U  H  n[        U5      v •  M     g 7f©N©Úcallable)Ú.0Úes     ÚQ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/plotting/utils.pyÚ	<genexpr>Ú$_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Ñ0Ø�ˆÜ
Ñ
&¡Ó
&×&Ñ&Ü‹uˆä‹5�;Š;±5Ó9²5¨aŸ™¤Ö)±5Ñ9Ð:€DØ�:Š:±uÓ=²u°!Ÿ™¤Ö-±uÑ=Ð>€DØ×@”3“5—;’;¹Ó ?º°A§¤¹Ñ ?Ð@Ð@ùò :ùÚ=ùÚ ?s   ÁC+ÂC0ÃC5c           	      óÜ   • U R                  [        5      nU HK  n[        U5      n[        [	        SW5       Vs/ s H  n[        U5      PM     sn6 nU R                  X55      n MM     U $ s  snf )ao  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_solutionr0   !   sb   € ð �\‰\œ(Ó#€FÛˆÜ�"‹XˆÜ¬%°°1¬+Ó6ª+ Qœ˜Rž©+Ñ6Ð7ˆØ—,‘,˜rÓ%Šñ ð €Nùò 7s   ¹A)
c                 ó²  • [        U [        5      (       a  U $ [        U 5      n [        U 5       H¥  u  p[        U[        [        45      (       a  [        [        U5      SS06X'   M8  [        U[        [        45      (       a  MU  [        U5      (       a  Mg  UR                  R                  S:X  a  [        U[        5      (       d  M˜  [        U5      X'   M§     U $ )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   r4   r4   6   s¡   € ô �$œ×ÑØˆä�‹:€DÜ˜$–‰ˆÜ�aœ$¤˜×'Ñ'Üœ]¨1Ó-Ð=°uÑ=ˆD‹GÜ˜Q¤¤d ×,Ó,´¸·³ð
 —‘×%Ñ%¨Ó1¼:ÀaÌ×;OÓ;Oä˜a“jˆD‹Gñ  ð €Kó    Nc                 ó$  • S n[        U 5      nUb  UR                  UR                  5       5      n[        U5      U:”  a9  [	        SSR                  U5      -   SR                  [        U5      U5      -   5      e[        U5      U:”  a  [	        S[        U5      < SU< 35      e[        5       R                  U Vs/ s H  owS   PM	     sn5      n[        U5      [        U5      :w  a  [	        S5      e[        U5      U:  a|  UR                  U5      n	U	[        5       :w  a   U	 H  n
UR                  U" U
5      5        M     [        U[        U5      -
  5       H"  nUR                  U" [        5       5      5        M$     [        U5      U:X  ay  [        5       R                  U Vs/ s H  owS   PM	     sn5      n[        UR                  U5      5      S:”  a/  [	        S	S
R                  U5      -   SR                  U5      -   5      eU$ s  snf s  snf )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                 ó   • [        U SS5      $ )Niöÿÿÿé
   r   )Úsymbols    r   Ú<lambda>Ú _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/   r:   s               r   Ú_create_rangesrQ   U   sé  € ñ. >Ðä$ UÓ+€LØÑØ#×.Ñ.¨v¯{©{«}Ó=ˆä
ˆ<Ó˜4ÓÜØ&Ø+×2Ñ2°4Ó8ñ9à×&Ñ&¤s¨<Ó'8¸,ÓGñHó
ð 	
ô ˆ6ƒ{�TÓÝÜ;>¸v¾;ÊÐMóOð 	Oô ‹%�+‰+¡VÓ,¢V ˜”t¡VÑ,Ó
-€CÜ
ˆ3ƒx”3�v“;ÓÜÐ?Ó@Ð@ä
ˆ6ƒ{�TÓØ×)Ñ)¨#Ó.ˆØ”c“eÓã�Ø—‘Ñ/°Ó2Ö3ñ ô �tœc &›kÑ)Ö*ˆAØ�M‰MÑ+¬E«GÓ4Ö5ñ +ô ˆ<Ó˜DÓ ô ‹e�k‰k©Ó0ª A˜Qœ4©Ñ0Ó1ˆÜˆ|×&Ñ& sÓ+Ó,¨qÓ0Üð à9×@Ñ@ÀÓNñOð 3×9Ñ9¸#Ó>ñ?óð ð €Mùò5 -ùò$ 1s   Â;HÆ$Hc                 óp  • [        U [        5      =(       a     [        U 5      S:H  =(       a‹    [        U R                  S   [        5      (       + =(       ab    U R                  S   R
                  =(       aB    [        U R                  S   [        5      (       + =(       a    U R                  S   R
                  $ )zMA range is defined as (symbol, start, end). start and end should
be numbers.
é   é   é   )r   r   rE   r9   r5   Ú	is_number)rN   s    r   Ú	_is_rangerW   ›   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                  óB  • U  Vs/ s H  n[        U5      (       d  M  UPM     nnU  Vs/ s H  n[        U[        5      (       d  M  UPM     nnU(       d  SOUS   nU  Vs/ s H  n[        U[        5      (       d  M  UPM     nnU(       d  SOUS   nU  Vs/ s H;  n[        U5      =(       d!    [        U[        [        45      =(       d    USL (       + PM=     nn[	        X5       VVs/ s H  u  phU(       d  M  UPM     n	nnX’XE4$ s  snf s  snf s  snf s  snf s  snnf )aR  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   )rW   r   r5   r6   Úzip)
r9   ÚtrI   ÚlabelsrK   Úrendering_kwr;   ÚresultsÚbr!   s
             r   Ú_unpack_argsr_   ¨   së   € ñ4 Ó.š�A¤¨1§�a™€FÐ.ÙÓ4š�A¤¨A¬s×!3�a™€FÐ4Þ‰D F¨1¡I€EÙ#Ó;št˜!¤z°!´T×':—A™t€LÐ;Þ+‘4°¸a±€Lñ Y]Ó]ÒX\ÐST”I˜a“L×M¤J¨q´3¼°+Ó$>×MÀ1ÈÀ9×NÑX\€GÐ]Ü˜tÔ-Ô3Ò-‘4�1´�QÑ-€EÑ3Ø˜%Ð-Ð-ùò /ùÚ4ùâ;ùò ^ùÛ3s4   …D�D©DÁDÁ DÁ=DÂADÃ)DÃ:Dc                 óÎ  • U (       d  / $ / nUR                  SS5      n[        S U SU  5       5      (       a¶  [        U 6 u  pgp‰[        5       R                  " U V
s/ s H  oªR
                  PM     sn
6 n[        XgX(U5      nUS:”  a  [        U5      U:X  a  [        U5      4nU HD  n[        U[        [        [        45      nU(       a  U4OUn
UR                  / U
QUQUPU	P75        MF     U$ [        U 6 u  pçpùU(       a  U/O/ n[        U5      [        U5      -   U	b  [        U	5      OS-   nUS:”  a  U SU*  OU n[        US   [        [        [        45      (       d  U/nU GH_  nU Vs/ s H  n[        U[         5      (       d  M  UPM     nnU(       d  UnU Vs/ s H  n[#        U5      (       d  M  UPM     nnU(       d  UR%                  5       nU Vs/ s H  n[        U[&        5      (       d  M  UPM     nn[        U5      S:X  a  U	OUS   n[)        U5       Vs/ s H  nUU   PM
     nn[        5       n[        S U 5       5      (       a*  UR                  " U Vs/ s H  nUR
                  PM     sn6 n[        U5      U:w  a  [        UUUSU5      nU(       d  SOUS   nUR                  / UQUQUPUP75        GMb     U$ s  sn
f s  snf s  snf s  snf s  snf s  snf )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)]
rL   Nc              3   óX   #   • U  H   n[        U[        [        [        45      v •  M"     g 7fr   )r   r   r   r   ©r   r;   s     r   r   Ú#_check_arguments.<locals>.<genexpr>  s!   é € Ð
TÂ|À!Œ:�aœ$¤
¬OÐ<×=Ð=Â|ùs   ‚(*rT   r   c              3   óB   #   • U  H  n[        U5      (       + v •  M     g 7fr   r   rb   s     r   r   rc   <  s   é € Ð0ªC q”x “{—?‘?ªCùs   ‚Ú )Úgetr   r_   r   r   r    rQ   rE   r   r   r   r   r   rH   r   r   r5   rW   Úcopyr6   r'   )r9   ÚnexprrJ   ÚkwargsÚoutputrL   r!   rI   rK   r\   r   r    ÚexprÚis_exprÚ_r[   r+   Únew_argsÚargr;   ÚlrN   Úrend_kwr:   s                           r   Ú_check_argumentsrr   Î   sÁ  € ö` Øˆ	Ø€FØ�Z‰Z˜ $Ó'€Fä
Ñ
TÀtÈFÈUÁ|Ó
T×TÑTô
 .:¸4Ð-@Ñ*ˆ�uÜ“u—{’{¹UÓ$CºU¸§^¤^¹UÑ$CÐDˆÜ ¨t¸FÓCˆà�1‹9ô �5‹z˜UÓ"Ü˜u›˜�ÛˆDô ! ¬¬j¼/Ð'JÓKˆGÞ"�‘¨ˆAØ�M‰MÐ<˜AÐ< Ð<¨Ð<¨|Ñ<Ö=ñ ðd €MôM +7¸Ð*=Ñ'ˆ�6Þ#�&‘¨ˆô �‹[œ3˜v›;Ñ&Ø".Ñ":ŒS�ÔÀñCˆà ! A£�4˜˜!˜‘9¨4ˆô
 ˜( 1™+¬¬e´UÐ';×<Ñ<Ø �zˆHô ˆCáÓ6šC�q¤:¨a´×#5—™CˆAÐ6ÞØ�ÙÓ0šC�q¤9¨Q§<—™CˆAÐ0ÞØ—K‘K“M�Ù"%Ó=¢#˜Q¬°A´t×)<—q¡#ˆGÐ=Ü&)¨'£l°aÓ&7‘l¸WÀQ¹ZˆGô $)¨¤<Ó0¢<˜a�3�q”6¡<ˆCÐ0Ü›5ˆLÜÑ0©CÓ0×0Ñ0Ø+×1Ò1ÉCÓ3PÊCÀq°A·N´NÉCÑ3PÐQ�Ü�1‹v˜‹~Ü" 3¨¨4°°VÓ<�æ !‘D q¨¡tˆEØ�M‰MÐ4˜CÐ4 !Ð4 UÐ4¨GÑ4×5ñ+ ð, €Mùòu %DùòL 7ùò 1ùò >ùò
 1ùò 4Qs6   ÁK	Å+KÆKÆKÆ5KÇKÇ5KÈ KÉ"K"
)r?   )re   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#   r0   r4   rQ   rW   r_   rr   © r<   r   Ú<module>r      sN   ðÝ 'Ý "Ý  Ý ,Ý ,Ý #Ý &Ý /Ý )Ý %Ý (òAô&ò*ô>CòL
ò#.óLur<   