K iL7tddlmZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z Gd d eZd Zy ) ) PlotInterval) PlotObject)parse_option_stringSymbol)sympify)GeometryEntity) is_sequenceceZdZdZd\ZZgZgZdZdZ gZ iidiidiiddZ iiidZ d\Z ZdZed Zedd Zedd Zed Zed ZdZedZdZdZedZedZy)PlotModez 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. )rFctN)NotImplementedError)selfs i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/plotting/pygletplot/plot_mode.pydrawz PlotMode.draw%s !##)r)rr)rrctj||\}}|jdd}tj|\}}tj ||}t t |t |gt |} } tj|| | } tj| } || _ | j|| j||| _ | S)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_optionsget_interpret_args _find_i_varsmaxlen _get_modeobject__new__d_vars _fill_i_vars_fill_intervalsoptions) clsargskwargsnewargs newkwargsmode_argr# intervalsi_varsidsubclsos rr"zPlotMode.__new__<s&66tVD==,%44W= &&vy9CKY013v;1##Ha3 NN6 " v )$ rc d}t|tr|}r|js&t d|j d|j d||j k7r$t d|j |j fz||jkDr$t d|j |jfz|St|tr||}}|tjkDrt tdd|tjkDrt tdd|stj||Stj|||St d #t$rYFwxYw) 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). NzTo 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 isinstancestr _i_var_maxvar_count_error _d_var_max_get_default_mode_get_aliased_mode)r,r:r9mr/r0s rr zPlotMode._get_modeZsl@ A(H- %% $%JJ "<==amm+ #A$%JJ%&]]$4"455Q]]* #/%&JJ%&]]$4"455 H h $ qA8&&& t!<==8&&& !=>>11!Q77 11(AqAA34 4G   sE EEc|dk(r|} tj||S#t$r@|tjkrtj |dz||cYSt d||fzwxYw)NrzKCouldn't find a default mode for %i independent and %i dependent variables.)r _mode_default_mapKeyErrorr=r@r7)r/r0r.s rr@zPlotMode._get_default_modes R<F I--a03 3 I8&&&11!a%FCC #9=CQK"HII Is6A(A(cb|dk(r|}|tjvr/td|ddjtjd tj|||S#t $rB|tj krtj||dz||cYStd|||fzwxYw)NrDzCouldn't find a mode called z. Known modes: z, .rzFCouldn't find a %s mode for %i independent and %i dependent variables.)r _mode_alias_listr7join _mode_mapr5r=rA)aliasr/r0r.s rrAzPlotMode._get_aliased_modes R<F 11 1 %tyy1J1J'KMN N 7%%a(+E2 2 78&&&11%Q6JJ #9%*61#5"677 7s A##7B.B.c |j}|j |j|j}}|jD]L}|t j vrt j j||t j|||<N|jr|t j||<yy#t$r}td|dt|d}~wwxYw)z Called once for each user-usable plot mode. For Cartesian2D, it is invoked after the class definition: Cartesian2D._register() zFailed to register plot mode z . Reason: N)r8 _init_moder:r9aliasesr rIappendrK is_defaultrE Exception RuntimeErrorr<)r'namer/r0aes r _registerzPlotMode._registers||  3??COOqA[[ 2H555--44Q7.1""1%a(+  2~~47**1-a0   3"&Q 23 3 3sBB55 C>CCcd}||j|_||j|_t|j|_t|j|_|jt j kDrttdd|jt jkDrttddt|jdkDr|jd|_ n|j|_ |j}t||jk7r tdt|jD]0}t||dk7r tdtdg||||<2d|_y) a  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>|Dcgc] }t|c}Scc}wrr) symbol_strss r symbols_listz)PlotMode._init_mode..symbols_lists'12!F1I2 22sTFrz9Plot mode must provide a default interval for each i_var.rzlength should be equal to 3N)r.r#rr:r9r r=r7r>r?rO primary_aliasr8r-rangerr6)r'r\dir/s rrNzPlotMode._init_modesF 3 "#**- !#**- cjj/cjj/ ??X00 0_T59: : ??X00 0_UE:; ; s{{ a  # AC  # C  ]] r7coo %@A As' /A2a5zQ !>?? !.1.BqE / $rc"g}|D]Y}|j|j|vr!tdt|jz|j|j[|D])}|jD]}||vs|j|+|S)Nz Multiple intervals given for %s.)vr7r<rP free_symbols) functionsr-r.r/frUs rrzPlotMode._find_i_vars$s  Ass{ #,03ACC":;; MM!##    %A^^ %F?MM!$ % %  rc|jDcgc]}tt|c}|_tt |D]}|||j|<ycc}wr)r.rr<r^r)rr.r/s rr$zPlotMode._fill_i_vars=sN/3{{;!vc!f~; s6{# 'A#AYDKKN '|j |j|j gtt|jD]~}|j|j |jDcgc] }||vs| }}t|dk(r td|d|j|_|j |dycc}wcc}w)Nrzlength should not be equal to 0) r-rr^r fill_fromrarPr.r7)rr-r/v_usedraus rr%zPlotMode._fill_intervalsDs37>>Ba,q/Bs9~& 3A NN1  ' ' ! 5~~a "". dnnQ/112 3 s4>>*+ $A~~a ""* $ ?1qQ??q6Q;$%FGG&'dq!# ad#  $C@sE0 E :E cd}d}gg}}t|dtrkt|djD]}|j ||j t j |dj||fS|D]}t j |}|7t|dk(rt|t|z|j |Qt|trt|t|z t|}|j |||fS#t$rt|t|zwxYw)Nz1PlotInterval %s was given before any function(s).z1Could not interpret %s as a function or interval.r)include)r;r listarbitrary_pointrPr try_parse plot_intervalrr7r<r r r5) r(interval_wrong_orderinterpret_errorrcr-coordsrUr/rds rrzPlotMode._interpret_argsYsLRM!29 d1g~ .tAw6689 )  ( )   \33DG4I4I4KL M$)##! C **1-=9~*()=Q)HII!((+"1c2(CF)CDDC#AJ!((+ C )##%C(3q6)ABBCs D%%!Ecig}}|D]9}t|trt|fit|})|j |;t|fi|}||fSr)r;r<dictrrP)r(r)r+r*rUs rrzPlotMode._extract_optionsvsa7  "A!S! E.A!.DE q!  " -f-  !!rN)rD)r8 __module__ __qualname____doc__r.r#r-rOrQrrIrKrEr=r?r" staticmethodr r@rA classmethodrWrNr6rr$r%rrrrr r s& "NFFIGJ $b>b>b>I   "J <G4G4RII 77*33>2$2$h0'$*$$8""rr cn|rd}nd}|rtjd}}ntjd}}d|||fzS)zQ Used to format an error message which differs slightly in 4 places. PlottingzRegistering plot modes independent dependentz3%s with more than %i %s variables is not supported.)r r=r?)is_independent is_plottingranr[s rr>r>sJ   $""M1""K1 $%q!9 --rN)ror plot_objectrutilrsympy.core.symbolrsympy.core.sympifyr sympy.geometry.entityr sympy.utilities.iterablesr r r>rzrrrs.'#%$&01u"zu"p -r