+
    i:T                     r    R t ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt R tR tR	 tR
tRR ltR# )z7Tools for setting up printing in interactive sessions. )BytesIO)latex)preview)debug)	Printable)import_modulec                8   a aa ^ RI p^ RIoVVV 3R lpW2n        R# )z.Setup printing in Python interactive session. Nc                T   < V e#   RSn         \        S! V 3/ SB 4       V Sn         R# R# )ztPython's pretty-printer display hook.

This function was adapted from:

 https://www.python.org/dev/peps/pep-0217/

N)_print)argbuiltinssettingsstringify_funcs   &X/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/interactive/printing.py_displayhook+_init_python_printing.<locals>._displayhook   s/     ?HJ.112HJ     )sysr   displayhook)r   r   r   r   r   s   fl  @r   _init_python_printingr      s     #Or   c                  aaaaaaa
aaaaa a!a"a#a$a%a&a' \        RRR7      o ^ RIHo& Sf=   V P                  P                  4       pVR8X  d   RoMVR8X  d   R	oMR
o\        RS4       VR8X  d   RS,          o$MRo$RpRp\        ^S
,          4      pRWVSV3,          pVP                  4       o"R+S
,          pRRP                  V4      .o#\        RS"4       \        RS#4       T	;'       g    \        o%VVV3R lpV"VV$V3R lo V#VV$V3R lo!VV&V
3R loR,o'VVV'3R loVVV V%VV3R lpVV!V%VV3R lpVVV%V3R lpVV%VV3R lp\        \        \        \        \        \         \"        .pV P$                  P&                  R,          pV\(        .,            F  pVP+                  VV4       K  	  V P$                  P&                  R ,          pVR-9   d3   \        R!4       V F  pVP+                  VV4       K  	  V\(        n        M[\        R"4       V F1  pVVP.                  9   g   K  VP.                  P1                  V4       K3  	  \(        P2                  \(        n        V P$                  P&                  R#,          pVR.9   d3   \        R$4       V F  pVP+                  VV4       K  	  V\(        n        MVR%8X  d3   \        R&4       V F  pVP+                  VV4       K  	  V\(        n        M[\        R'4       V F1  pVVP.                  9   g   K  VP.                  P1                  V4       K3  	  \(        P2                  \(        n        V P$                  P&                  R(,          pVR/9   d4   \        R)4       V F  pVP+                  VV4       K  	  V\(        n        R# \        R*4       V F1  pVVP.                  9   g   K  VP.                  P1                  V4       K3  	  \(        P2                  \(        n        R#   \         d     ELi ; i)0z/Setup printing in IPython interactive session. IPythonz1.0)min_module_version)latex_to_pngNlightbgBlacklinuxWhiteGrayz*init_printing: Automatic foreground color:svgz
\special{color %s} tightz0cm,0cmz-T %s -D %d -bg %s -fg %s -O %sz
--no-fontsz
--scale={}zinit_printing: DVIOPTIONS:zinit_printing: DVIOPTIONS_SVG:c                   < S! V 4      '       d   VP                  S! V 4      4       R# VP                  SP                  P                  P                  V 4      4       R# )z*caller for pretty, for use in IPython 0.11N)textlibpretty)r   pcycler   
_can_printr   s   &&&r   _print_plain,_init_ipython_printing.<locals>._print_plainP   s>    c??FF>#&'FF7;;%%,,S12r   c                    < \        4       p \        V R RSVSSSR7       VP                  4       #   \         d   p\        RR\	        T4      4       h Rp?ii ; i)pngr   outputviewereuleroutputbufferextra_preamble
dvioptionsfontsizezpng printing:"_preview_wrapper exception raised:N)r   r   	Exceptionr   reprgetvalue)o
exprbufferer4   r1   r3   r5   s   &  r   _preview_wrapper0_init_ipython_printing.<locals>._preview_wrapperW   sc    Y
	AeIU!+N)H> ""$$  	/#Gq'		s   0 AAAc                    < \        4       p \        V R RSVSSSR7       TP                  4       P                  R4      #   \         d   p\        RR\	        T4      4       h Rp?ii ; i)r    r   r.   zsvg printing:r6   Nzutf-8)r   r   r7   r   r8   r9   decode)r:   r;   r<   dvioptions_svgr1   r3   r5   s   &  r   _svg_wrapper,_init_ipython_printing.<locals>._svg_wrapperd   so    Y
	AeIU!+N-B ""$++G44  	/#Gq'		s   ? A&
A!!A&c                    <   S! V SSR 7      #   \          d    S! T 4      u # i ; i  \         d!   p\        R\        T4      4        Rp?R# Rp?ii ; i))colorscalezmatplotlib exception caught:N)	TypeError
ValueErrorr   r8   )r:   r<   	forecolorr   rF   s   & r   _matplotlib_wrapper3_init_ipython_printing.<locals>._matplotlib_wrapperq   sV    	'#AYeDD '#A&' 	0$q':	s$   
 %( %( AAAc                P  <a   \         \        \        \        3p\	        S V4      '       d   \        S 4      P                  R V 4       9  g"   \        S 4      P                  R V 4       9  d   R# \        ;QJ d    V3R lS  4       F  '       d   K   R# 	  R# ! V3R lS  4       4      # \	        S \        4      '       d=   \        ;QJ d     VV 3R lS  4       F  '       d   K   R# 	  R# ! VV 3R lS  4       4      # \	        S \        4      '       d   R# \	        S \        4      '       d   R# \        ;QJ d    V 3R lS 4       F  '       g   K   RM	  RM! V 3R lS 4       4      '       d   R# \	        S \        \        34      '       d   S'       d   R# R#   \         d     R# i ; i)zReturn True if type o can be printed with one of the SymPy printers.

If o is a container type, this is True if and only if every element of
o can be printed in this way.
c              3   8   "   T F  qP                   x  K  	  R # 5iN)__str__.0is   & r   	<genexpr>=_init_ipython_printing.<locals>._can_print.<locals>.<genexpr>   s     +M}!II}   c              3   8   "   T F  qP                   x  K  	  R # 5irN   )__repr__rP   s   & r   rS   rT      s     ,OAZZrU   Fc              3   4   <"   T F  pS! V4      x  K  	  R # 5irN    )rQ   rR   r)   s   & r   rS   rT      s     4!Q:a==!s   Tc              3   b   <"   T F$  pS! V4      ;'       d    S! SV,          4      x  K&  	  R # 5irN   rY   )rQ   rR   r)   r:   s   & r   rS   rT      s)     Iq!:a===Z!-==qs   //c              3   <   <"   T F  p\        SV4      x  K  	  R # 5irN   )hasattr)rQ   hookr:   s   & r   rS   rT      s     A.$WQ%%.s   )listtupleset	frozenset
isinstancetyperO   rW   alldictboolr   anyfloatintRuntimeError)r:   builtin_typesr)   print_builtinprinting_hookss   f r   r)   *_init_ipython_printing.<locals>._can_print   s&   	 "5#y9M!]++ GOO+M}+MMG$$,O,OO s4!4ss4s4s4!444At$$sIqIssIsIsIqIIIAt$$Ay))A.AA.AAAAs|,, 		sw   'F AF 0
F ;F F F F * F F #F &F *F <F F ,
F 7F F .#F F%$F%c                   < S! V 4      '       d%   S! V 3RS/SB pSR8X  d
   RV,          p S! V4      # R#   \          d;   p\        R\        T4      R4       SR8w  d   S! T 3RR/SB pS! T4      u Rp?# Rp?ii ; i)zp
A function that returns a png rendered by an external latex
distribution, falling back to matplotlib rendering
modeplain$\displaystyle %s$preview failed with:z# Falling back to matplotlib backendinlineNrj   r   r8   )	r:   sr<   r)   rJ   r=   r   
latex_moder   s	   &  r   _print_latex_png0_init_ipython_printing.<locals>._print_latex_png   s    
 a==a5j5H5AW$)A-.'**    .,d1g;=)a;h;(;A*1--.s   6 A;/A60A;6A;c                   < S! V 4      '       d%   S! V 3RS/SB pSR8X  d
   RV,          p S! V4      # R#   \          d"   p\        R\        T4      R4        Rp?R# Rp?ii ; i)zb
A function that returns a svg rendered by an external latex
distribution, no fallback available.
rp   rq   rr   rs   z No fallback available.Nru   )r:   rv   r<   r)   rB   r   rw   r   s   &  r   _print_latex_svg0_init_ipython_printing.<locals>._print_latex_svg   ss    
 a==a5j5H5AW$)A-1#A&    1,d1g/1 11s   6 A"AA"c                J   < S! V 4      '       d   S! V 3RR/SB pS! V4      # R# )z4
A function that returns a png rendered by mathtext
rp   rt   NrY   )r:   rv   r)   rJ   r   r   s   & r   _print_latex_matplotlib7_init_ipython_printing.<locals>._print_latex_matplotlib   s2     a==a3h3(3A&q)) r   c                ^   < S! V 4      '       d   S! V 3RS/SB pSR8X  d
   RV,          # V# R# )zG
A function to generate the latex representation of SymPy expressions.
rp   rq   rr   NrY   )r:   rv   r)   r   rw   r   s   & r   _print_latex_text1_init_ipython_printing.<locals>._print_latex_text   s?     a==a5j5H5AW$,q00H	 r   z
text/plainzimage/svg+xmlz"init_printing: using svg formatterz*init_printing: not using any svg formatterz	image/pngz"init_printing: using png formatter
matplotlibz)init_printing: using matplotlib formatterz*init_printing: not using any png formatterz
text/latexz&init_printing: using mathjax formatterz-init_printing: not using text/latex formatterg @)_latex	_sympystr_pretty
_sympyrepr)r    )Tr-   )Tmathjax)r   IPython.lib.latextoolsr   ImportErrorcolorslowerr   roundsplitformatdefault_latexrh   r_   r^   r`   ra   re   ri   display_formatter
formattersr   for_type
_repr_svg_type_printerspop_repr_disabled
_repr_png__repr_latex_)(ipr   	use_latexr1   rI   	backcolorr5   rw   rl   latex_printerrF   r   rE   	imagesizeoffset
resolutiondvi	svg_scaler*   rx   r{   r~   r   printable_typesplaintext_formatterclssvg_formatterpng_formatterlatex_formatterr   r)   rJ   r=   rB   r4   rA   r3   r   r   rm   s(   &f&ff&fff&fl                 @@@@@@@@@@@r   _init_ipython_printingr   !   s    I%@G7 		!IIgI I:IFE09<IFs5y!J
,y)V0= =CJuI"L$7$7	$BCN	
&
3	
*N;**]E3% %5 5 FN!L. .$1 1* *  eT3	4EO..99,G
 ),,$$S,7 - ((33ODMI23"C""3(89 #/	:;"C m111++//4	 #
  )77	((33K@MM!23"C""3(89 #/		l	"9:"C""3(?@ #6	:;"C m111++//4	 #
  )77	**55lCO%%67"C$$S*;< #!2	=>"C o333--11#6	 #
 "+!9!9	e  s   O= =PPc                    ^ RI Hp RV9  d   R#  ^ RIHp \        Y4      #   \         d     ^ RIHp  L  \         d      R# i ; ii ; i)z%Is a shell instance an IPython shell?)modulesr   F)InteractiveShell)r   r   IPython.core.interactiveshellr   r   IPython.iplibrb   )shellr   r   s   &  r   _is_ipythonr     sT     	B e..  	6 	 		s$   " A
6AA
AA
FNc                  aaaaa ^ RI p^ RIHp V '       d   Ve   TpM^ RIHp MVe   TpM^ RIHp RpVf    \        4       pVRJpV'       d   V'       g   \        V4      pV'       dl   V '       dd    ^ RI	H
p ^ RIHp \        VVV34      '       gC   RR	P                  VP                  4      9  d#   Sf   \!        R
4       RoVf   \!        R4       Rp\$        '       g   V'       g   VP'                  SSSSR7       MVoV '       d   VVVVV3R lpMVV3R lpV'       d;   VP)                  RR4      pV'       d   \!        R4       \+        VVW8WWVVV3/ VB  R# \-        V3/ VB  R#   \         d     EL2i ; i  \"         d     Li ; i)a  
Initializes pretty-printer depending on the environment.

Parameters
==========

pretty_print : bool, default=True
    If ``True``, use :func:`~.pretty_print` to stringify or the provided pretty
    printer; if ``False``, use :func:`~.sstrrepr` to stringify or the provided string
    printer.
order : string or None, default='lex'
    There are a few different settings for this parameter:
    ``'lex'`` (default), which is lexographic order;
    ``'grlex'``, which is graded lexographic order;
    ``'grevlex'``, which is reversed graded lexographic order;
    ``'old'``, which is used for compatibility reasons and for long expressions;
    ``None``, which sets it to lex.
use_unicode : bool or None, default=None
    If ``True``, use unicode characters;
    if ``False``, do not use unicode characters;
    if ``None``, make a guess based on the environment.
use_latex : string, bool, or None, default=None
    If ``True``, use default LaTeX rendering in GUI interfaces (png and
    mathjax);
    if ``False``, do not use LaTeX rendering;
    if ``None``, make a guess based on the environment;
    if ``'png'``, enable LaTeX rendering with an external LaTeX compiler,
    falling back to matplotlib if external compilation fails;
    if ``'matplotlib'``, enable LaTeX rendering with matplotlib;
    if ``'mathjax'``, enable LaTeX text generation, for example MathJax
    rendering in IPython notebook or text rendering in LaTeX documents;
    if ``'svg'``, enable LaTeX rendering with an external latex compiler,
    no fallback
wrap_line : bool
    If True, lines will wrap at the end; if False, they will not wrap
    but continue as one line. This is only relevant if ``pretty_print`` is
    True.
num_columns : int or None, default=None
    If ``int``, number of columns before wrapping is set to num_columns; if
    ``None``, number of columns before wrapping is set to terminal width.
    This is only relevant if ``pretty_print`` is ``True``.
no_global : bool, default=False
    If ``True``, the settings become system wide;
    if ``False``, use just for this console/session.
ip : An interactive console
    This can either be an instance of IPython,
    or a class that derives from code.InteractiveConsole.
euler : bool, optional, default=False
    Loads the euler package in the LaTeX preamble for handwritten style
    fonts (https://www.ctan.org/pkg/euler).
forecolor : string or None, optional, default=None
    DVI setting for foreground color. ``None`` means that either ``'Black'``,
    ``'White'``, or ``'Gray'`` will be selected based on a guess of the IPython
    terminal color setting. See notes.
backcolor : string, optional, default='Transparent'
    DVI setting for background color. See notes.
fontsize : string or int, optional, default='10pt'
    A font size to pass to the LaTeX documentclass function in the
    preamble. Note that the options are limited by the documentclass.
    Consider using scale instead.
latex_mode : string, optional, default='plain'
    The mode used in the LaTeX printer. Can be one of:
    ``{'inline'|'plain'|'equation'|'equation*'}``.
print_builtin : boolean, optional, default=True
    If ``True`` then floats and integers will be printed. If ``False`` the
    printer will only print SymPy types.
str_printer : function, optional, default=None
    A custom string printer function. This should mimic
    :func:`~.sstrrepr`.
pretty_printer : function, optional, default=None
    A custom pretty printer. This should mimic :func:`~.pretty`.
latex_printer : function, optional, default=None
    A custom LaTeX printer. This should mimic :func:`~.latex`.
scale : float, optional, default=1.0
    Scale the LaTeX output when using the ``'png'`` or ``'svg'`` backends.
    Useful for high dpi screens.
settings :
    Any additional settings for the ``latex`` and ``pretty`` commands can
    be used to fine-tune the output.

Examples
========

>>> from sympy.interactive import init_printing
>>> from sympy import Symbol, sqrt
>>> from sympy.abc import x, y
>>> sqrt(5)
sqrt(5)
>>> init_printing(pretty_print=True) # doctest: +SKIP
>>> sqrt(5) # doctest: +SKIP
  ___
\/ 5
>>> theta = Symbol('theta') # doctest: +SKIP
>>> init_printing(use_unicode=True) # doctest: +SKIP
>>> theta # doctest: +SKIP
\u03b8
>>> init_printing(use_unicode=False) # doctest: +SKIP
>>> theta # doctest: +SKIP
theta
>>> init_printing(order='lex') # doctest: +SKIP
>>> str(y + x + y**2 + x**2) # doctest: +SKIP
x**2 + x + y**2 + y
>>> init_printing(order='grlex') # doctest: +SKIP
>>> str(y + x + y**2 + x**2) # doctest: +SKIP
x**2 + x + y**2 + y
>>> init_printing(order='grevlex') # doctest: +SKIP
>>> str(y * x**2 + x * y**2) # doctest: +SKIP
x**2*y + x*y**2
>>> init_printing(order='old') # doctest: +SKIP
>>> str(x**2 + y**2 + x + y) # doctest: +SKIP
x**2 + x + y**2 + y
>>> init_printing(num_columns=10) # doctest: +SKIP
>>> x**2 + x + y**2 + y # doctest: +SKIP
x + y +
x**2 + y**2

Notes
=====

The foreground and background colors can be selected when using ``'png'`` or
``'svg'`` LaTeX rendering. Note that before the ``init_printing`` command is
executed, the LaTeX rendering is handled by the IPython console and not SymPy.

The colors can be selected among the 68 standard colors known to ``dvips``,
for a list see [1]_. In addition, the background color can be
set to  ``'Transparent'`` (which is the default value).

When using the ``'Auto'`` foreground color, the guess is based on the
``colors`` variable in the IPython console, see [2]_. Hence, if
that variable is set correctly in your IPython console, there is a high
chance that the output will be readable, although manual settings may be
needed.


References
==========

.. [1] https://en.wikibooks.org/wiki/LaTeX/Colors#The_68_standard_colors_known_to_dvips

.. [2] https://ipython.readthedocs.io/en/stable/config/details.html#terminal-colors

See Also
========

sympy.printing.latex
sympy.printing.pretty

N)Printer)r&   )sstrreprF)TerminalInteractiveShell)InteractiveConsolezipython-consoler!   z*init_printing: Setting use_unicode to TrueTz(init_printing: Setting use_latex to Trueorderuse_unicode	wrap_linenum_columnsc                 &   < S! V 3R SRSRSRS/VB # r   rY   )exprr   _stringify_funcr   r   r   r   s   &,r   <lambda>init_printing.<locals>.<lambda>  s9    ,T 9 99D97@9 :E9 08	9r   c                    < S! V 3R S/VB # )r   rY   )r   r   r   r   s   &,r   r   r     s    *3 %*3)1*3r   rp   zMinit_printing: Mode is not able to be set due to internalsof IPython printing)r   sympy.printing.printerr   sympy.printingr&   r   get_ipython	NameErrorr   !IPython.terminal.interactiveshellr   coder   rb   joinargvr   r   	NO_GLOBALset_global_settingsr   r   r   )pretty_printr   r   r   r   r   	no_globalr   r1   rI   r   r5   rw   rl   str_printerpretty_printerr   rF   r   r   r   r   
in_ipythonr   r   mode_in_settingsr   s   &ff&ff&&&&&&&&&&&&,       @r   init_printingr   1  s   v .%+N?"(NA J	z	*B D.J	* _
l	%R/
 b#57O"PQQ)1BB&FG"&K$DE $I9Y##%[.7[ 	$ 	R )9 9N3  #<<5 ( )r>9(X,mU	+ "*	+
 	n99k  		  		s#   
E, 4E> ,E;:E;>FF)TNNNNNFNFNTransparent10ptrq   TNNNg      ?)__doc__ior   sympy.printing.latexr   r   sympy.printing.previewr   sympy.utilities.miscr   sympy.printing.defaultsr   sympy.externalr   r   r   r   r   r   rY   r   r   <module>r      s8    =  7 * & - (#*y:v/& 	c:r   