
    \hL7                     t    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
\5      rS rg)   )PlotInterval)
PlotObject)parse_option_string    Symbol)sympify)GeometryEntity)is_sequencec                   
   \ rS rSrSrSu  rr/ r/ rSr	S r
/ r0 0 S.0 0 S.0 0 S.S.r0 0 0 S.rSu  rrS	 r\S
 5       r\SS j5       r\SS j5       r\S 5       r\S 5       rSr\S 5       rS rS r\S 5       r\S 5       rSrg)PlotMode
   z
Grandparent class for plotting
modes. Serves as interface for
registration, lookup, and init
of modes.

To create a new plot mode,
inherit from PlotModeBase
or one of its children, such
as PlotSurface or PlotCurve.
) r   Fc                     [        5       eN)NotImplementedError)selfs    [/var/www/auris/envauris/lib/python3.13/site-packages/sympy/plotting/pygletplot/plot_mode.pydrawPlotMode.draw%   s    !##    )r      )r   r      )r   r   c                    [         R                  X5      u  p4UR                  SS5      n[         R                  U5      u  pg[         R	                  Xg5      n[        [        U5      [        U5      /5      [        U5      p[         R                  XYU
5      n[        R                  U5      nXll
        UR                  U5        UR                  U5        XLl        U$ )z
This is the function which interprets
arguments given to Plot.__init__ and
Plot.__setattr__. Returns an initialized
instance of the appropriate child class.
moder   )r   _extract_optionsget_interpret_args_find_i_varsmaxlen	_get_modeobject__new__d_vars_fill_i_vars_fill_intervalsoptions)clsargskwargsnewargs	newkwargsmode_argr%   	intervalsi_varsidsubclsos                r   r$   PlotMode.__new__<   s     &66tD==, %44W=&&v9CKY013v;1 ##H3 NN6" 	v	)$	r   c                     Sn[        U [        5      (       a  U nW(       a  UR                  (       d(  [	        SUR
                  < SUR
                  < S35      eX#R                  :w  a$  [	        SUR
                  UR                  4-  5      eXR                  :  a$  [	        SUR
                  UR                  4-  5      eU$ [        U [        5      (       a  XpTU[        R                  :  a  [	        [        SS5      5      eU[        R                  :  a  [	        [        SS5      5      eU (       d  [        R                  XE5      $ [        R                  XU5      $ [	        S	5      e! [         a     GN[f = f)
a  
Tries to return an appropriate mode class.
Intended to be called only by __new__.

mode_arg
    Can be a string or a class. If it is a
    PlotMode subclass, it is simply returned.
    If it is a string, it can an alias for
    a mode or an empty string. In the latter
    case, we try to find a default mode for
    the i_var_count and d_var_count.

i_var_count
    The number of independent variables
    needed to evaluate the d_vars.

d_var_count
    The number of dependent variables;
    usually the number of functions to
    be evaluated in plotting.

For example, a Cartesian function y = f(x) has
one i_var (x) and one d_var (y). A parametric
form x,y,z = f(u,v), f(u,v), f(u,v) has two
two i_vars (u,v) and three d_vars (x,y,z).
NzTo use unregistered plot mode z you must first call z._init_mode().z7%s can only plot functions with %i dependent variables.zA%s cannot plot functions with more than %i independent variables.TFz-PlotMode argument must be a class or a string)
issubclassr   	TypeError_was_initialized
ValueError__name__d_var_counti_var_count
isinstancestr
_i_var_maxvar_count_error
_d_var_max_get_default_mode_get_aliased_mode)r.   r=   r<   mr1   r2   s         r   r"   PlotMode._get_modeZ   sf   @	A(H-- %% $%JJ

"< = = mm+  #A$%JJ%&]]$4"4 5 5 ]]*  #/ %&JJ%&]]$4"4 5 5
 Hh$$q8&&& t!<==8&&& !=>> 11!77  11(qAA 3 4 4G  		s   E) )
E76E7c                     US:X  a  U n [         R                  U   U    $ ! [         a?    U [         R                  :  a  [         R	                  U S-   X5      s $ [        SX!4-  5      ef = f)Nr   zKCouldn't find a default mode for %i independent and %i dependent variables.)r   _mode_default_mapKeyErrorr@   rC   r:   )r1   r2   r0   s      r   rC   PlotMode._get_default_mode   s    R<F	I--a033 		I 8&&&11!a%CC  #9=CK"H I I		Is     7A)A)c                 j   US:X  a  UnU [         R                  ;  a1  [        SU < SSR                  [         R                  5      < S35      e [         R                  U   U   U    $ ! [
         a@    U[         R                  :  a  [         R                  XS-   X#5      s $ [        SXU4-  5      ef = f)NrH   zCouldn't find a mode called z. Known modes: z, .r   zFCouldn't find a %s mode for %i independent and %i dependent variables.)r   _mode_alias_listr:   join	_mode_mapr8   r@   rD   )aliasr1   r2   r0   s       r   rD   PlotMode._get_aliased_mode   s    R<F111 %tyy1J1J'KM N N	7%%a(+E22 
	7 8&&&11%QJJ  #9 %*1#5"6 7 7
	7s   A( (7B2!B2c           	         U R                   nU R                  5          U R                  U R                  p2U R                   HO  nU[
        R                  ;  a  [
        R                  R                  U5        U [
        R                  U   U   U'   MQ     U R                  (       a  U [
        R                  U   U'   gg! [         a!  n[        SU< S[        U5      < 35      eSnAff = f)z
Called once for each user-usable plot mode.
For Cartesian2D, it is invoked after the
class definition: Cartesian2D._register()
zFailed to register plot mode z
. Reason: N)r;   
_init_moder=   r<   aliasesr   rN   appendrP   
is_defaultrI   	ExceptionRuntimeErrorr?   )r)   namer1   r2   aes         r   	_registerPlotMode._register   s     ||	3??COOq [[H555 --44Q7.1""1%a(+ ! ~~ 47**1-a0	   	3"&Q 2 3 3	3s   BB= =
C(C##C(c                    S nU" U R                   5      U l         U" U R                  5      U l        [        U R                   5      U l        [        U R                  5      U l        U R                  [
        R                  :  a  [        [        SS5      5      eU R                  [
        R                  :  a  [        [        SS5      5      e[        U R                  5      S:  a  U R                  S   U l        OU R                  U l        U R                  n[        U5      U R                  :w  a  [        S5      e[        U R                  5       H/  n[        X#   5      S:w  a  [        S5      e[        S/X#   Q76 X#'   M1     SU l        g)	z
Initializes the plot mode based on
the 'mode-specific parameters' above.
Only intended to be called by
PlotMode._register(). To use a mode without
registering it, you can directly call
ModeSubclass._init_mode().
c                 D    U  Vs/ s H  n[        U5      PM     sn$ s  snf r   r   )
symbol_strss     r   symbols_list)PlotMode._init_mode.<locals>.symbols_list   s    '12z!F1Iz222s   TFr   z9Plot mode must provide a default interval for each i_var.r   zlength should be equal to 3N)r0   r%   r!   r=   r<   r   r@   r:   rA   rB   rU   primary_aliasr;   r/   ranger   r9   )r)   rc   dir1   s       r   rT   PlotMode._init_mode   s;   	3
 "#**-
!#**-
 cjj/cjj/??X000_T59::??X000_UE:;; s{{a #AC #C]]r7coo% @ A As'A 25zQ !>??
 !..BE (  $r   c                 :   / nU H^  nUR                   c  M  UR                   U;   a!  [        S[        UR                   5      -  5      eUR                  UR                   5        M`     U  H.  nUR                   H  nXR;  d  M
  UR                  U5        M     M0     U$ )Nz Multiple intervals given for %s.)vr:   r?   rV   free_symbols)	functionsr/   r0   r1   fr[   s         r   r   PlotMode._find_i_vars$  s    
 Ass{  #,03ACC": ; ;MM!##  A^^?MM!$ $ 
 r   c                     U R                    Vs/ s H  n[        [        U5      5      PM     snU l         [        [	        U5      5       H  nX   U R                   U'   M     g s  snf r   )r0   r   r?   rf   r!   )r   r0   r1   s      r   r&   PlotMode._fill_i_vars=  sK    /3{{;{!vc!f~{;s6{#A#YDKKN $ <s   A"c                    U R                    Vs/ s H  n[        U5      PM     snU l         / n[        [        U5      5       Hg  nU R                   U   R	                  X   5        U R                   U   R
                  c  M?  UR                  U R                   U   R
                  5        Mi     [        [        U R                   5      5       H  nU R                   U   R
                  b  M  U R                   Vs/ s H  oDU;  d  M
  UPM     nn[        U5      S:X  a  [        S5      eUS   U R                   U   l        UR                  US   5        M     g s  snf s  snf )Nr   zlength should not be equal to 0)	r/   r   rf   r!   	fill_fromrj   rV   r0   r:   )r   r/   r1   v_usedrj   us         r   r'   PlotMode._fill_intervalsD  s   37>>B>a,q/>B s9~&ANN1''	5~~a "".dnnQ/112 ' s4>>*+A~~a ""* $?1Q?q6Q;$%FGG&'dq!#ad# , C @s   E8	EEc                    SnSn/ / pC[        U S   [        5      (       am  [        U S   R                  5       5       H  nUR	                  U5        M     UR	                  [
        R                  " U S   R                  5       5      5        X44$ U  H  n[
        R                  " U5      nUb9  [        U5      S:X  a  [        U[        U5      -  5      eUR	                  U5        MU  [        U[        S9(       a  [        U[        U5      -  5      e [        U5      nUR	                  U5        M     X44$ ! [         a    [        U[        U5      -  5      ef = f)Nz1PlotInterval %s was given before any function(s).z1Could not interpret %s as a function or interval.r   )include)r>   r
   listarbitrary_pointrV   r   	try_parseplot_intervalr!   r:   r?   r   r	   r8   )	r*   interval_wrong_orderinterpret_errorrl   r/   coordsr[   r1   rm   s	            r   r   PlotMode._interpret_argsY  s=   RM!29d1g~..tAw6689  ( :\33DG4I4I4KLM$ ##!  **1-=9~*()=Q)HII!((+"1c2(CF)CDDC#AJ!((+   ## % C(3q6)ABBCs   D22"Ec                     0 / p2U  H@  n[        U[        5      (       a  [        U40 [        U5      D6nM/  UR	                  U5        MB     [        U40 UD6nX24$ r   )r>   r?   dictr   rV   )r*   r+   r-   r,   r[   s        r   r   PlotMode._extract_optionsv  s[    7A!S!! E.A!.DE	q!	 
 -f-	!!r   )r0   r/   N)rH   )r;   
__module____qualname____firstlineno____doc__r0   r%   r/   rU   rW   r   rN   rP   rI   r@   rB   r$   staticmethodr"   rC   rD   classmethodr]   rT   r9   r   r&   r'   r   r   __static_attributes__ r   r   r   r   
   s&   
" NFFIGJ$ b>b>b>I 
 "J
< G4 G4R I I  7 7* 3 3> 2$ 2$h   0'$* $ $8 " "r   r   c                 |    U(       a  SnOSnU (       a  [         R                  SpCO[         R                  SpCSX#U4-  $ )zE
Used to format an error message which differs
slightly in 4 places.
PlottingzRegistering plot modesindependent	dependentz3%s with more than %i %s variables is not supported.)r   r@   rB   )is_independentis_plottingrj   nrb   s        r   rA   rA     sD    
 $""M1""K1 $%!9- -r   N)r{   r   plot_objectr   utilr   sympy.core.symbolr   sympy.core.sympifyr	   sympy.geometry.entityr
   sympy.utilities.iterablesr   r   rA   r   r   r   <module>r      s.    ' # % $ & 0 1u"z u"p-r   