K i 7ddlZddlmZddlZddlZddlmZ ddlmZm Z m Z ddl m Z ddlmZddlmZd d giZd Zd Zd ZdddddddZe ddd ddZy#e $rYGwxYw)N)join)Path)STDOUTCalledProcessError check_output)doctest_depends_on)debug)latex)previewpygletcLtjdk(rd}nd}t|d|i|S)Nntir creationflags)osnamer)argskwargs creation_flags \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/printing/preview.py_check_output_no_windowrs. ww$"   E] Ef EEc&tjdtjj |dd5}t |d5}t j||ddddddddl}|jdk(r"ddl }|jd jfy|jd k(r tjjyddl }|jd jfy#1swYxYw#1swYxYw) a Open fname with the default system viewer. In practice, it is impossible for python to know when the system viewer is done. For this reason, we ensure the passed file will not be deleted under it, and this function does not attempt to block. zsympy-preview-r F)prefixsuffixdeleterbNrDarwinopenWindowszxdg-open)tempfileNamedTemporaryFilerpathsplitextrshutil copyfileobjplatformsystem subprocesscallr startfile)fnamefmttemp_ffr'r)s rsystem_default_viewerr0s  $ $,<,.GG,<,.on_closeQs CLrcJ|jjfvryy)N)QESCAPE)symbol modifiersr5rCs r on_key_pressz#pyglet_viewer..on_key_pressVs"#%%,, -rcjddddjjjjjz dz j j z dz y)Ng?r9) glClearColorglClearGL_COLOR_BUFFER_BITblitr;r<)r4imgrBsr on_exposez pyglet_viewer..on_expose\s] OOCc3 / JJr-- . HHSYY&!+cjj(A- r)r r2r3r4 pyglet.windowr5pyglet.image.codecsr6 ImportErrorload ValueErrorformatConfigWindowr;r< set_vsyncrCrIrPrAdispatch_eventsflipKeyboardInterruptclose)r,r-r2r3r6offsetr?rIrPr4rOr5rCrBs @@@@@r pyglet_viewerr_6sGY,,%<UjjF YYUY +F --ii!F("zzAfH$  CMM%     ( " ,,    ! HHJ,, IIKe YWXXY UGNNsSTTUT    s)C<D AD7<D D47 EET)preamblepackagesextra_preambleeulerfontsizec h|h|dz}|r|dz }ddj|Dcgc]}d|z c}z} |r| |z } |sd}n!t|trdj|}d|d| d }n|s|r t d t|t r|} nd t |fd d i|zdz} |dz| zdzdzScc}w)zA Generate string of a LaTeX document rendering ``expr``. )amsmathamsfonts)rd z\usepackage{%s}12ptz{}ptz\documentclass[varwidth,z]{standalone} z \begin{document} zcThe "packages" or "extra_preamble" keywordsmust not be set if a custom LaTeX preamble was specifiedz$\displaystyle modeplain$z z\end{document})r isinstanceintrVrUstrr ) exprrarbrcrdrelatex_settingsactual_packagesppackage_includes latex_strings r_get_latex_mainrwps  "%<<  z )O$))6E-G12.@!-C-G#HH   . H # &}}X.H ! # ~CD D$ *dCCNCD  d?\ )F 25F FF7-Gs B/ )r dvipng)r )evincegimpzsuperior-dvi-viewer)exemodulesdisable_viewersc ||dk(r ddl} t}|>gdgdgdd}|j|gD]}t j |}||}n|t }|dk(r |Ktd |d k(r |9td t|s#t j |std |zt|f|||| | d | }tdt|tj5}tt|dj!|d| t j"t|d| t j ds t%d t'gd|t(d|z}|dk7rdggddgdgd} ||}|D]}t j |}|s|g}n=t1|dkDrt%d d!j|zt%d"|dzgd#d$gd%}d&|d'gd'|gd&|d'gd&|d'gd&|d'gd&|d'gd(}||j3|n!|j3|j|g|j3|| t'||t(|dk(r!t j4t|||no|d k(r5tt||j7}|j9|n5t|r|t|||,n t'||g|t(dddy#t$rYwxYw#t*$r}t%d|j,zd}~wwxYw#t.$rtd|zdwxYw#t*$r/}t%d)d*j|d+|j,d}~wwxYw#t*$r#}t%d)|d*|d+|j,d}~wwxYw#1swYyxYw)-a View expression or LaTeX markup in PNG, DVI, PostScript or PDF form. If the expr argument is an expression, it will be exported to LaTeX and then compiled using the available TeX distribution. The first argument, 'expr', may also be a LaTeX string. The function will then run the appropriate viewer for the given output format or use the user defined one. By default png output is generated. By default pretty Euler fonts are used for typesetting (they were used to typeset the well known "Concrete Mathematics" book). For that to work, you need the 'eulervm.sty' LaTeX style (in Debian/Ubuntu, install the texlive-fonts-extra package). If you prefer default AMS fonts or your system lacks 'eulervm' LaTeX package then unset the 'euler' keyword argument. To use viewer auto-detection, lets say for 'png' output, issue >>> from sympy import symbols, preview, Symbol >>> x, y = symbols("x,y") >>> preview(x + y, output='png') This will choose 'pyglet' by default. To select a different one, do >>> preview(x + y, output='png', viewer='gimp') The 'png' format is considered special. For all other formats the rules are slightly different. As an example we will take 'dvi' output format. If you would run >>> preview(x + y, output='dvi') then 'view' will look for available 'dvi' viewers on your system (predefined in the function, so it will try evince, first, then kdvi and xdvi). If nothing is found, it will fall back to using a system file association (via ``open`` and ``xdg-open``). To always use your system file association without searching for the above readers, use >>> from sympy.printing.preview import system_default_viewer >>> preview(x + y, output='dvi', viewer=system_default_viewer) If this still does not find the viewer you want, it can be set explicitly. >>> preview(x + y, output='dvi', viewer='superior-dvi-viewer') This will skip auto-detection and will run user specified 'superior-dvi-viewer'. If ``view`` fails to find it on your system it will gracefully raise an exception. You may also enter ``'file'`` for the viewer argument. Doing so will cause this function to return a file object in read-only mode, if ``filename`` is unset. However, if it was set, then 'preview' writes the generated file to this filename instead. There is also support for writing to a ``io.BytesIO`` like object, which needs to be passed to the ``outputbuffer`` argument. >>> from io import BytesIO >>> obj = BytesIO() >>> preview(x + y, output='png', viewer='BytesIO', ... outputbuffer=obj) The LaTeX preamble can be customized by setting the 'preamble' keyword argument. This can be used, e.g., to set a different font size, use a custom documentclass or import certain set of LaTeX packages. >>> preamble = "\\documentclass[10pt]{article}\n" \ ... "\\usepackage{amsmath,amsfonts}\\begin{document}" >>> preview(x + y, output='png', preamble=preamble) It is also possible to use the standard preamble and provide additional information to the preamble using the ``extra_preamble`` keyword argument. >>> from sympy import sin >>> extra_preamble = "\\renewcommand{\\sin}{\\cos}" >>> preview(sin(x), output='png', extra_preamble=extra_preamble) If the value of 'output' is different from 'dvi' then command line options can be set ('dvioptions' argument) for the execution of the 'dvi'+output conversion tool. These options have to be in the form of a list of strings (see ``subprocess.Popen``). Additional keyword args will be passed to the :func:`~sympy.printing.latex.latex` call, e.g., the ``symbol_names`` flag. >>> phidd = Symbol('phidd') >>> preview(phidd, symbol_names={phidd: r'\ddot{\varphi}'}) For post-processing the generated TeX File can be written to a file by passing the desired filename to the 'outputTexFile' keyword argument. To write the TeX code to a file named ``"sample.tex"`` and run the default png viewer to display the resulting bitmap, do >>> preview(x + y, outputTexFile="sample.tex") Npngr)ryokularkdvixdvi)ryrgsviewgv)ryrkpdfacroreadxpdfr)dvipspdffilez-filename has to be specified if viewer="file"BytesIOzFoutputbuffer has to be a BytesIO compatible object if viewer="BytesIO"zUnrecognized viewer: %s)rarbrdrcrez Latex code: texput.texzutf-8)encodingr zlatex program is not installed)r z-halt-on-errorz-interaction=nonstopmoder)cwdstderrz7'latex' exited abnormally with the following output: %sz texput.%srdvips)dvipdfmxdvipdfmdvipdfrxdvisvgm)rrrsvgzInvalid output format: %sr zNone of %s are installedz, z%s is not installed)z-Ttightz-z9z --truecolorz --no-fonts)rxrz-oz texput.dvi)rrrrrxr' z/' exited abnormally with the following output: )r-)r r_rSgetr%whichr0rUcallableOSErrorrwr r!TemporaryDirectoryrr write_textcopyfile RuntimeErrorrrroutputKeyErrorlenextendmove read_byteswrite)rqrviewerrdrbfilename outputbufferra dvioptions outputTexFilercrerrr candidates candidater# latex_mainworkdiresrc commandnames cmd_variants cmd_variantcmd_pathcmddefaultoptions commandendss rr r sIT~&E/ # #F~:8K $3 I<< *D  ~&   NO O 9   GH H f fll6&:/&899 F8',^*2F6DFJ - *  $ $ &Y-' T'< ()44Z'4R  $ OOD,7 G||G$?@ @  #  V$ U?i8 z!{ L  Q+F3 , P !<< 4#*C P |$q(&'ADIIlD['[\\&'<|A'NOOD(>N \2'- #|4!3 5l3 #|4 J% :& >--k2>? JJz+. / /'H V  KKWc*H 5 y T'3'(335A   q ! f  4%6 2 -'SMwv?iY-Y-S   p" J  " Q !)A)N=L'N=>L7N= B-N=M BN=!N> L  L  L4L//L44N=7MN= N *NN  N= N:N55N::N==O) rNTr`NNNNNNN)ros.pathrr%r!pathlibrr)rrrrSsympy.utilities.decoratorrsympy.utilities.miscr r __doctest_requires__rr0r_rwr r`rrrs   CC9&$xj1F327t'+R$GN+[EGBDHL>Bm-Gm-a  s A$$A,+A,