+
    ii                     <   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 0 RkRkR	kR
kRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkR kR!kR"kR#kR$kR%kR&kR'ktR(R)R*R+R,R-/t/ R.R.bR/R/bR0R0bR1R1bR2R2bR3R3bR4R4bR5R6bR7R7bR8R8bR9R9bR:R:bR;R;bR<R<bR=R=bR>R>bR?R?bR@R@RARARBRBRCRDRERERFRERGRGRHRHRIRIRJRJRKRKRLRMRNRNRORO/CtRPRQRRRSRTRQRURVRWRXRYRX/tRZ tR[ t ! R\ R]]4      t ! R^ R_4      t ! R` Ra]4      t]P*                   F  t]! ]Rb],          ]4       K  	  ] F  t]! ]Rb],          ]4       K  	  Rc t^ RIHt ^ RdIHt R;R;RMRMRERER7R7RJRJRNRNR.R.R0R0R2R2R8R8RKRKROROR/R/R1R1R4R4/tRRRSRTRQRURVReRf/t ! Rg Rh]4      t]P*                   F  t]! ]Rb],          ]P                   4       K   	  ] F  t]! ]Rb],          ]P"                  4       K   	  RiP;                  4       t]P?                  4        U Uu. uF  w  rV ]9  g   K  W3NK  	  upp t ]!! ] 3/ RjRjRkRkRlRlRmRmRnRnRCRCRoRoRpRpRqRqRrRrRsRsRtRt/B t"RPRQRRRSRuRvRwRxRyRzRWRXRURVReR{/t#R| t$ ! R} R~]4      t%]%P*                   F  t]! ]%Rb],          ]4       K  	  ]# F  t]! ]%Rb],          ]4       K  	   ! R R]4      t&R# u upp i )zy
Python code printers

This module contains Python code printers for plain Python as well as NumPy & SciPy enabled code.
)defaultdict)chain)S)Mod)
precedence)CodePrinterandasassertbreakclasscontinuedefdelelifelseexceptfinallyforfromglobalifimportinislambdanotorpassraisereturntrywhilewithyieldNoneFalsenonlocalTrueAbsabsMinminMaxmaxacosacoshasinasinhatanatan2atanhceilingceilcoscosherferfcexpexpm1	factorialfloorgammahypotisinfisnanloggammalgammaloglnlog10log1plog2sinsinhSqrtsqrttantanhExp1ePipiEInfinityinfNaNnanComplexInfinityc                    a  S P                   VP                  P                  ,          pR P                  S P	                  V4      RP                  V 3R lVP                   4       4      R7      # )z{name}({args}), c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5iN_print.0argselfs   & u/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/printing/pycode.py	<genexpr>$_print_known_func.<locals>.<genexpr>G   s     2Yy4;;s3C3Cy   !)nameargs)known_functions	__class____name__format_module_formatjoinrj   rd   exprknowns   f& re   _print_known_funcrt   D   sZ      !8!89E""(;(;E(B(,		2Ytyy2Y(Z # \ \    c                 r    V P                   VP                  P                  ,          pV P                  V4      # r^   )known_constantsrl   rm   ro   rq   s   && re   _print_known_constrx   J   s-      !8!89Eu%%ru   c                   v  aa ] tR t^Ot oRtRt]tRtRt	]
! ]! ]P                  4       ]P                  4        U Uu. uF  w  rV RV,           3NK  	  upp 4      4      t]P                  4        U Uu/ uF  w  rV RV,           bK  	  upp tRRRRRR/t]
! ]P(                  / ^R	R	R
RR7      tR/V3R lltR tR0R ltR tR tR tR tR tR tR tR tR t R t!R t"V3R lt#R t$R t%R t&R t'R  t(R! ;t);t*;t+;t,;t-;t.;t/t0R" t1R# t2R$ t3R% t4R& t5R' t6R( t7R) t8R* t9R+ t:R, t;R1R- lt<R.t=Vt>V;t?# u upp i u upp i )2AbstractPythonCodePrinter_pythoncodePythonNz    zmath.r   r   r   TFpython3)user_functions	precisioninlinefully_qualified_modulescontractstandardc                  < \         SV `  V4       V P                  R ,          pVf*   ^ RIpRP	                  VP
                  P                  4      pVR8w  d   \        R4      hW n        \        \        4      V n        \        V P                  3/ T;'       g    / P                  R/ 4      B V n        \        V P                   3/ T;'       g    / P                  R/ 4      B V n        R# )r   Nzpython{}r}   zOnly Python 3 is supported.r~   user_constants)super__init__	_settingssysrn   version_infomajor
ValueErrorr   r   setmodule_importsdict_kfgetrk   _kcrw   )rd   settingsstdr   rl   s   &&  re   r   "AbstractPythonCodePrinter.__init__e   s    " nnZ(;##C$4$4$:$:;C):;;)#.  $DHH  #R0D0Db1"  ##DHH  #R0D0Db1"  #ru   c                    V: R V: 2# z =  )rd   ri   values   &&&re   _declare_number_const/AbstractPythonCodePrinter._declare_number_consty   s     %((ru   c                   VP                  R 4      pV'       dL   \        V4      ^8  d<   V P                  R P                  VRR 4      ,          P	                  VR,          4       V P
                  R,          '       d   V# VP                  R4      ^ ,          P                  R4      ^ ,          P                  R 4      R,          # ).Nr   ([)splitlenr   rp   addr   )rd   fqnregisterpartss   &&& re   ro   (AbstractPythonCodePrinter._module_format|   s    		#E
Qs 4599%)D>>344J99S>!$**3/288=bAAru   c                    V# r^   r   )rd   liness   &&re   _format_code&AbstractPythonCodePrinter._format_code   s    ru   c                $    R P                  V4      # )z{}rn   )rd   
codestrings   &&re   _get_statement(AbstractPythonCodePrinter._get_statement   s    {{:&&ru   c                $    R P                  V4      # )z  # {}r   )rd   texts   &&re   _get_comment&AbstractPythonCodePrinter._get_comment   s    t$$ru   c                    \        V4      ^8X  d   V P                  V^ ,          4      # V P                  V4      : RV P                  WRR 4      : RV P                  VR,          4      : R2# )z
This method expands a fold on binary operations.

``functools.reduce`` is an example of a folded operation.

For example, the expression

`A + B + C + D`

is folded into

`((A + B) + C) + D`
r   Nr\   )r   )r   r`   ro   _expand_fold_binary_op)rd   oprj   s   &&&re   r   0AbstractPythonCodePrinter._expand_fold_binary_op   s`     t9>;;tAw'' ##B'++BSb	:DH% ru   c           	         \        V4      ^8X  d   V P                  V^ ,          4      # \        V4      pV^,          pV P                  V4      : RV P                  VRV 4      : RV P                  W$R 4      : R2# )z
This method expands a reduction on binary operations.

Notice: this is NOT the same as ``functools.reduce``.

For example, the expression

`A + B + C + D`

is reduced into:

`(A + B) + (C + D)`
r   Nr\   r   )r   r`   ro   _expand_reduce_binary_op)rd   r   rj   NNhalfs   &&&  re   r   2AbstractPythonCodePrinter._expand_reduce_binary_op   sr     t9>;;tAw''D	AFE##B'--d6El;--d6l; ru   c                    R # )zfloat('nan')r   rd   rr   s   &&re   
_print_NaN$AbstractPythonCodePrinter._print_NaN       ru   c                    R # )zfloat('inf')r   r   s   &&re   _print_Infinity)AbstractPythonCodePrinter._print_Infinity   r   ru   c                    R # )zfloat('-inf')r   r   s   &&re   _print_NegativeInfinity1AbstractPythonCodePrinter._print_NegativeInfinity   s    ru   c                $    V P                  V4      # r^   )r   r   s   &&re   _print_ComplexInfinity0AbstractPythonCodePrinter._print_ComplexInfinity   s    t$$ru   c                f   a a \        V4      oR P                  ! VV 3R lVP                   4       !  # )z{} % {}c              3   H   <"   T F  pSP                  VS4      x  K  	  R # 5ir^   )parenthesize)rb   xPRECrd   s   & re   rf   7AbstractPythonCodePrinter._print_Mod.<locals>.<genexpr>   s!     "Qy!4#4#4Q#=#=ys   ")r   rn   rj   rd   rr   r   s   f&@re   
_print_Mod$AbstractPythonCodePrinter._print_Mod   s(    $  "Qtyy"QRSru   c                B   . p^ pVP                    F  pVP                  pVP                  pV^ 8X  d   VP                  R4       VP                  R4       VP                  V P	                  V4      4       VP                  R4       VP                  R4       VP                  V P	                  V4      4       VP                  R4       V^,          pK  	  VRR	 pVR	,          R8X  d   VRR
 pVP                  R4       MVP                  R4       RP                  V4      # )    r   r   z if z else Nr(   z else None) r   )rj   rr   condappendr`   rp   )rd   rr   resultirc   rR   cs   &&     re   _print_Piecewise*AbstractPythonCodePrinter._print_Piecewise   s    99CAAAvc"MM#MM$++a.)MM#MM&!MM$++a.)MM(#FA  ":CR[FMM#MM-(wwvru   c                  < RRRRRRRRR	R
RR/pVP                   V9   dT   V P                  VP                  4      pV P                  VP                  4      pRP	                  VP                   W4R7      # \
        SV `  V4      # )z.Relational printer for Equality and Unequalityz==equalz!=	not_equal<lessz<=
less_equal>greaterz>=greater_equalz({lhs} {op} {rhs}))r   lhsrhs)rel_opr`   r   r   rn   r   _print_Relational)rd   rr   r   r   r   rl   s   &&   re   r   +AbstractPythonCodePrinter._print_Relational   s     '+&,)/
 ;;"++dhh'C++dhh'C'..$++3.PPw(..ru   c                N    ^ RI Hp V P                  VP                  V4      4      # )r   )	Piecewise)$sympy.functions.elementary.piecewiser   r`   rewrite)rd   rr   r   s   && re   
_print_ITE$AbstractPythonCodePrinter._print_ITE   s    B{{4<<	233ru   c                   a  V 3R  lVP                   RRR1,           4       pRP                  S P                  VP                  4      RP	                  V4      R7      # )c              3      <"   T FI  w  rpR P                  SP                  V4      SP                  V4      SP                  V4      R7      x  KK  	  R# 5i)zfor {i} in range({a}, {b}+1))r   abN)rn   r`   )rb   r   r   r   rd   s   &   re   rf   7AbstractPythonCodePrinter._print_Sum.<locals>.<genexpr>   sV      .
 -a	 +11++a.++a.++a. 2 " " -s   AANz"(builtins.sum({function} {loops})) )functionloopsr   )limitsrn   r`   r   rp   )rd   rr   r   s   f& re   
_print_Sum$AbstractPythonCodePrinter._print_Sum   sV    .
  ;;tt,. 4::[[/((5/ ; # 	#ru   c                    R # )1jr   r   s   &&re   _print_ImaginaryUnit.AbstractPythonCodePrinter._print_ImaginaryUnit  s    ru   c                    VP                   w  r#R P                  V P                  V4      V P                  V4      R7      # )z(1 if {a} == {b} else 0))r   r   )rj   rn   r`   )rd   rr   r   r   s   &&  re   _print_KroneckerDelta/AbstractPythonCodePrinter._print_KroneckerDelta  s;    yy)00AA 1 
 	
ru   c                    VP                   P                  pV P                  P                  W"4      pV: R V P	                  VP                  4       4      : R2# )r   r   )rl   rm   rk   r   r`   tolist)rd   rr   ri   funcs   &&  re   _print_MatrixBase+AbstractPythonCodePrinter._print_MatrixBase  sA    ~~&&##''3T[[]!;<<ru   c                $    V P                  V4      # r^   )r
  r   s   &&re   <lambda>"AbstractPythonCodePrinter.<lambda>  s    411$7ru   c                    R P                  VP                  R 4       Uu. uF  q P                  V,           NK  	  up4      # u upi )
)rp   r   tab)rd   r   lines   && re   _indent_codestring,AbstractPythonCodePrinter._indent_codestring  s8    yyj6F6Ft6LM6Ld((T//6LMNNMs   Ac                T  a  R P                  V 3R lVP                   4       4      pRP                  S P                  VP                  4      RP                  VP
                   Uu. uF  pS P                  VP                  4      NK   	  up4      S P                  V4      R7      # u upi )r  c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5ir^   r_   ra   s   & re   rf   FAbstractPythonCodePrinter._print_FunctionDefinition.<locals>.<genexpr>#  s     >gs$++c**grh   z def {name}({parameters}):
{body}r\   )ri   
parametersbody)rp   r  rn   r`   ri   r  symbolr  )rd   fdr  vars   f&  re   _print_FunctionDefinition3AbstractPythonCodePrinter._print_FunctionDefinition"  s    yy>bgg>?299RWW%yyR]]!S]c$++cjj"9]!ST((. : 
 	
!Ss   %$B%c                   a  R P                  V 3R lVP                   4       4      pRP                  S P                  VP                  4      S P                  V4      R7      # )r  c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5ir^   r_   ra   s   & re   rf   9AbstractPythonCodePrinter._print_While.<locals>.<genexpr>+  s     ?hs$++c**hrh   zwhile {cond}:
{body})r   r  )rp   r  rn   r`   	conditionr  )rd   whlr  s   f& re   _print_While&AbstractPythonCodePrinter._print_While*  sQ    yy?chh?@&--S]]+((. . 
 	
ru   c                    V P                  VP                  P                  4      : R V P                  VP                  P                  4      : 2# r   )r`   variabler  r   )rd   decls   &&re   _print_Declaration,AbstractPythonCodePrinter._print_Declaration1  s8    KK,,-KK++,
 	
ru   c                    R # )r   r   )rd   bts   &&re   _print_BreakToken+AbstractPythonCodePrinter._print_BreakToken7  s    ru   c                N    VP                   w  pR V P                  V4      ,          # )z	return %srj   r`   )rd   retrc   s   && re   _print_Return'AbstractPythonCodePrinter._print_Return:  s!    xxT[[---ru   c                N    VP                   w  pR V P                  V4      ,          # )zraise %sr0  )rd   rsrc   s   && re   _print_Raise&AbstractPythonCodePrinter._print_Raise>  s!    wwDKK,,,ru   c                N    VP                   w  pR V P                  V4      ,          # )zRuntimeError(%s)r0  )rd   remessages   && re   _print_RuntimeError_.AbstractPythonCodePrinter._print_RuntimeError_B  s!    77!DKK$888ru   c                X  a  R P                  V 3R lVP                   4       4      p^ RIHp VP                  V8w  d,   RP                  S P                  VP                  4      V4      pVP                  R8w  d*   VRS P                  VP                  4      ,          ,          pRV,          # )r\   c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5ir^   r_   ra   s   & re   rf   9AbstractPythonCodePrinter._print_Print.<locals>.<genexpr>G  s     LOSC 0 0Orh   )nonez{} % ({}), end=""Nz	, file=%sz	print(%s))rp   
print_argssympy.codegen.astr@  format_stringrn   r`   file)rd   prntrA  r@  s   f&  re   _print_Print&AbstractPythonCodePrinter._print_PrintF  s    YYLDOOLM
*%,33D../J 99+DII(>>>JZ''ru   c                    \        VP                  4      R 8X  d   V P                  R4      # \        VP                  4      R8X  d   V P                  R4      # V P                  VP                  4      # )stdoutz
sys.stdoutstderrz
sys.stderr)strri   ro   r`   )rd   strms   &&re   _print_Stream'AbstractPythonCodePrinter._print_StreamR  sW    tyy>X%&&|44^x'&&|44;;tyy))ru   c                    R # )r%   r   )rd   rc   s   &&re   _print_NoneToken*AbstractPythonCodePrinter._print_NoneTokenZ  s    ru   c                ^   \        V4      pVP                  \        P                  8X  dG   V'       g?   V P	                  V4      pV P                  VP                  4      pRP                  WVR7      # VP                  '       d   V'       g   VP                  ) \        P                  J dW   V P	                  V4      pV P                  \        P                  4      pV P                  VP                  4      pV RV RV R2# VP                  \        P                  J dE   V P                  \        P                  4      pV P                  VP                  VRR7      pV RV 2# V P                  VP                  VRR7      pV P                  VP                  VRR7      p	RP                  W4      # )	a  Printing helper function for ``Pow``

Notes
=====

This preprocesses the ``sqrt`` as math formatter and prints division

Examples
========

>>> from sympy import sqrt
>>> from sympy.printing.pycode import PythonCodePrinter
>>> from sympy.abc import x

Python code printer automatically looks up ``math.sqrt``.

>>> printer = PythonCodePrinter()
>>> printer._hprint_Pow(sqrt(x), rational=True)
'x**(1/2)'
>>> printer._hprint_Pow(sqrt(x), rational=False)
'math.sqrt(x)'
>>> printer._hprint_Pow(1/sqrt(x), rational=True)
'x**(-1/2)'
>>> printer._hprint_Pow(1/sqrt(x), rational=False)
'1/math.sqrt(x)'
>>> printer._hprint_Pow(1/x, rational=False)
'1/x'
>>> printer._hprint_Pow(1/x, rational=True)
'x**(-1)'

Using sqrt from numpy or mpmath

>>> printer._hprint_Pow(sqrt(x), sqrt='numpy.sqrt')
'numpy.sqrt(x)'
>>> printer._hprint_Pow(sqrt(x), sqrt='mpmath.sqrt')
'mpmath.sqrt(x)'

See Also
========

sympy.printing.str.StrPrinter._print_Pow
z{func}({arg}))r	  rc   /r   r   Fstrictz{}**{})r   r<   r   Halfro   r`   basern   is_commutativeOneNegativeOner   )
rd   rr   rationalrN   r   r	  rc   numbase_strexp_strs
   &&&&      re   _hprint_Pow%AbstractPythonCodePrinter._hprint_Pow]  sX   V $88qvvh&&t,D++dii(C"))t)==xyAFF"**40kk!%%(kk$)),avQse1--xx1==(kk!%%(''		4'Fau~% $$TYYU$C##DHHd5#Ax11ru   )rw   rk   r   r   r^   )T)Fz	math.sqrt)@rm   
__module____qualname____firstlineno__printmethodlanguage_kwreserved_wordsmodulesr  r   r   _known_functionsitems_known_functions_mathr   _known_constants_mathr   
_operatorsr   _default_settingsr   r   ro   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  _print_SparseRepMatrix_print_MutableSparseMatrix_print_ImmutableSparseMatrix_print_Matrix_print_DenseMatrix_print_MutableDenseMatrix_print_ImmutableMatrix_print_ImmutableDenseMatrixr  r  r$  r)  r-  r2  r6  r;  rF  rM  rP  r_  __static_attributes____classdictcell____classcell__kvrl   __classdict__s   00@@re   rz   rz   O   s    KHNG
C
u &;&A&A&CD&Cda!Wq[	&CD C %:$?$?$A
B$ADA1gai<$A
BCdE59J%% $#()B'%.2%T./ 4	#
= 	88 8"8$8 	8 		8
 	"8 	#O


.-9
(*@2 @2M 	E
Bs   D/0D5rz   c                   h   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tRtV tR# )ArrayPrinteri  c                F    ^ RI Hp  V! V4      #   \         d    Tu # i ; i)r   )convert_indexed_to_array)4sympy.tensor.array.expressions.from_indexed_to_arrayr  	Exception)rd   indexedr  s   && re   	_arrayifyArrayPrinter._arrayify  s)    a	+G44 	N	s      c           	     R   V P                  4       pR p^ pV UUu/ uF  qf F  qw\        V4      bK  	  K  	  ppp. p	V F`  p
. p\        V
4       F;  pWX9   d   VP                  W,          4       MVP                  V4       V^,          pK=  	  V	P                  V4       Kb  	  / p. p. pV	 Fm  pV F[  pW|9  d   \	        V4      pWV&   MW,          pWO,          pWx9   d   W9  d   VP                  V4       KH  KJ  VP                  V4       K]  	  VR,          pKo  	  VRR pWMV3# u uppi )r   ,Nr   ) _get_letter_generator_for_einsumr,   ranger   next)rd   subrankscontraction_indicesletterscontraction_stringcounterr   jdindicesrank_arglindicesmappingletters_freeletters_dumls   &&&             re   _get_einsum_stringArrayPrinter._get_einsum_string  s=   779 3? 31QAYQQ 3? HH8_<OOAJ/OOG,1 % NN8$ ! A#WA!"AJ
A"'"6+#**1- , !''*  #%  04!<<; @s   D#c              #     "   \        ^a^{4       F  p\        V4      x  K  	  \        ^A^[4       F  p\        V4      x  K  	  \        R4      h5i)a   zout of letters)r  chrr   )rd   r   s   & re   r  -ArrayPrinter._get_letter_generator_for_einsum  sC     r3Aa&L  r2Aa&L )**s   AAc                   V P                  4       pR P                  VP                   UUu. uF6  pRP                  \        V4       Uu. uF  p\	        V4      NK  	  up4      NK8  	  upp4      pV P                  V P                  R,           V P                  ,           4      : RV: RRP                  VP                   Uu. uF  q`P                  V4      NK  	  up4      : R2# u upi u uppi u upi )r  r   r   ("", r\   r   )
r  rp   r  r  r  ro   _module_einsumrj   r`   )rd   rr   r  r   r  r  rc   s   &&     re   _print_ArrayTensorProduct&ArrayPrinter._print_ArrayTensorProduct  s    779 XX[_[h[h&i[hVWrwwuQx/Px!Wx/P'Q[h&ij##DLL3$6$EF"		tyyAy;;s+yAB
 	
 0Q&i Bs   C*
C%C*
C0%C*
c           
     N   ^ RI Hp VP                  pVP                  p\	        W24      '       dO   RP                  VP                   Uu. uF  pRV P                  V4      ,          NK  	  up4      pVP                  pM'V P                  V4      p\        VP                  4      .pV P                  Wt4      w  rp
V'       g   V P                  V4      # \	        W24      '       dC   RP                  VP                   Uu. uF  pRV P                  V4      ,          NK  	  up4      pMV P                  V4      pV P                  V P                  R,           V P                  ,           4      : RRP                  VRP                  \!        V	4      4      4      : RV: R	2# u upi u upi )
r   ArrayTensorProductr  z%sr   r  {}->{}r   r  r   )0sympy.tensor.array.expressions.array_expressionsr  rr   r  
isinstancerp   rj   r`   r  r   shaper  ro   r  r  rn   sorted)rd   rr   r  rW  r  rc   elemsranksr  r  r  s   &&         re   _print_ArrayContraction$ArrayPrinter._print_ArrayContraction  sH   Wyy"66d//HH499M9Cddkk#&6779MNEMMEKK%E_%E8<8O8OPU8k5+";;t$$d//HH499M9Cddkk#&6779MNEKK%Es 2T\\ ABOO.|8L0MN
 	
 N Ns   	!F<!F"c           	     R   ^ RI Hp \        VP                  4      p\	        VP
                  V4      '       d.   VP
                  P                  pVP
                  P                  pMVP                  pVP
                  .pV P                  WC4      w  rgpV U	u. uF  qP                  V	4      NK  	  pp	V P                  V P                  R,           V P                  ,           4      : RRP                  VRP                  Wx,           4      4      : RRP                  V4      : R2# u up	i )	r   r  r   r  r  r   r  r\   r   )r  r  listdiagonal_indicesr  rr   r  rj   r  r`   ro   r  r  rn   rp   )
rd   rr   r  r  r  r  diagonal_stringr  r  r   s
   &&        re   _print_ArrayDiagonal!ArrayPrinter._print_ArrayDiagonal  s    W 5 56dii!344yy))HIINNE}}HYYKE595L5LX5h2{)./AQ/s 2T\\ ABOOORWW\5M-NOIIe
 	
 0s   D$c                    V P                  V P                  R ,           V P                  ,           4      : RV P                  VP                  4      : RV P                  VP
                  P                  4      : R2# )r   r   r\   r   )ro   r  
_transposer`   rr   permutation
array_formr   s   &&re   _print_PermuteDimsArrayPrinter._print_PermuteDims  sT    s 2T__ DEKK		"KK((334
 	
ru   c                ~    V P                  V P                  R ,           V P                  ,           VP                  4      # )r   )r   r  _addrj   r   s   &&re   _print_ArrayAddArrayPrinter._print_ArrayAdd  s+    **4<<#+=		+I499UUru   c                    V P                  V P                  R ,           V P                  ,           4      : RRP                  \	        V P
                  VP                  4      4      : R2# r   z((r  z,)))ro   r  _onesrp   mapr`   rj   r   s   &&re   _print_OneArrayArrayPrinter._print_OneArray  sG    c 1DJJ >?HHSTYY/0
 	
ru   c                    V P                  V P                  R ,           V P                  ,           4      : RRP                  \	        V P
                  VP                  4      4      : R2# r  )ro   r  _zerosrp   r  r`   rj   r   s   &&re   _print_ZeroArrayArrayPrinter._print_ZeroArray  sG    c 1DKK ?@HHSTYY/0
 	
ru   c                    V P                  V P                  VP                  4      4      pV P                  V P                  VP                  4      4      pV: R V: 2# r   )r`   r  r   r   )rd   rr   r   r   s   &&  re   _print_AssignmentArrayPrinter._print_Assignment  sE     kk$..23kk$..23 #''ru   c                $    V P                  V4      # r^   )_print_ArraySymbolr   s   &&re   _print_IndexedBaseArrayPrinter._print_IndexedBase$  s    &&t,,ru   r   N)rm   ra  rb  rc  r  r  r  r  r  r  r  r  r  r  r  r  rw  rx  r}  s   @re   r  r    sH     !=F+

4
"
V

(- -ru   r  c                      a a ] tR tRt oR tR tR tR tRR ltR t	R t
R	 tV 3R
 lt]P                  t]P                  t]P                  t]P                  tRtVtV ;t# )PythonCodePrinteri(  c                    R P                  V P                  R4      V P                  VP                  ^ ,          4      R7      # )z"(0.0 if {e} == 0 else {f}(1, {e}))zmath.copysign)frR   rn   ro   r`   rj   rd   rR   s   &&re   _print_signPythonCodePrinter._print_sign*  s=    3::!!/2dkk!&&)6L ; N 	Nru   c                    \        V4      pV P                  R ,          R,           V P                  VP                  ^ ,          V4      ,           # )r   r   )r   rm  r   rj   r   s   && re   
_print_NotPythonCodePrinter._print_Not.  s:    $u%+d.?.?		!d.SSSru   c                    VP                   # r^   )ri   r   s   &&re   r  $PythonCodePrinter._print_IndexedBase2  s    yyru   c                    VP                   ^ ,          pVP                   R,          pRP                  \        V4      RP                  V Uu. uF  q@P	                  V4      NK  	  up4      4      # u upi )r   :   NNz{}[{}]r\   )rj   rn   rK  rp   r`   )rd   rr   rW  indexinds   &&   re   _print_Indexed PythonCodePrinter._print_Indexed5  sV    yy|		"s4y$))QV4WQV#[[5EQV4W*XYY4Ws   A/c                &    V P                  WR 7      # ))r[  r_  rd   rr   r[  s   &&&re   
_print_PowPythonCodePrinter._print_Pow:  s    88ru   c                N    R P                  VP                  VP                  4      # )z{}/{})rn   pqr   s   &&re   _print_Rational!PythonCodePrinter._print_Rational=  s    ~~dffdff--ru   c                $    V P                  V4      # r^   r  r   s   &&re   _print_HalfPythonCodePrinter._print_Half@  s    ##D))ru   c                Z    V P                  \        VP                  ^ ,          ^4      4      # )r   )r   r   rj   r   s   &&re   _print_fracPythonCodePrinter._print_fracC  s     s499Q<344ru   c                4  < \         SV `  V4      pW P                  9   dO   V P                  R ,          '       d   Rp\	        VP                  V4      4      hW P                  R,          ,           # RV9   d#   VP                  RR4      P                  RR4      # V# )error_on_reservedzVThis expression includes the symbol "{}" which is a reserved keyword in this language.reserved_word_suffix{r   })r   _print_Symbolrg  r   r   rn   replace)rd   rr   ri   msgrl   s   &&  re   r  PythonCodePrinter._print_SymbolF  s    w$T*&&&~~122< D!122..)?@@@D[<<R(00b99Kru   r   F)rm   ra  rb  rc  r  r  r  r  r  r  r  r  r  r   _print_not_supported_print_lowergamma_print_uppergamma_print_fresnelc_print_fresnelsrw  rx  ry  )rl   r}  s   @@re   r  r  (  sg     NTZ
9.*5 $88#88!66O!66OOru   r  z	_print_%sc                6    \        V4      P                  V 4      # )a  Converts an expr to a string of Python code

Parameters
==========

expr : Expr
    A SymPy expression.
fully_qualified_modules : bool
    Whether or not to write out full module names of functions
    (``math.sin`` vs. ``sin``). default: ``True``.
standard : str or None, optional
    Only 'python3' (default) is supported.
    This parameter may be removed in the future.

Examples
========

>>> from sympy import pycode, tan, Symbol
>>> pycode(tan(Symbol('x')) + 1)
'math.tan(x) + 1'

)r  doprint)rr   r   s   &,re   pycoder
  b  s    . X&..t44ru   )r  NegativeInfinityz-infc                      aa ] tR tRt oRtRtRt]! ]! ]	P                  4       4      4      t]P                  4        U Uu/ uF  w  rV RV,           bK  	  upp tRR ltR tV3R ltR	 tR
 tR tRtVtV;t# u upp i )CmathPrinteri  z"Printer for Python's cmath module 
_cmathcodezPython with cmathcmath.c                (    V P                  WR R7      # )z
cmath.sqrtr[  rN   r  r  s   &&&re   r  CmathPrinter._print_Pow      lKKru   c                d    R P                  V P                  R4      V P                  V4      R7      # )z{func}({val})z	cmath.mpf)r	  valrn   ro   r`   r  s   &&re   _print_FloatCmathPrinter._print_Float  s0    %%4+>+>{+KQUQ\Q\]^Q_%``ru   c           	        < VP                   P                  pW P                  9   dH   R V P                  V,           RRP                  \	        V P
                  VP                  4      4       R2# \        SV `!  V4      # )r  r   r\   r   )	r	  rm   r   rp   r  r`   rj   r   _print_Function)rd   rr   	func_namerl   s   && re   rt   CmathPrinter._print_known_func  se    II&&	 DHHY/0$))CTYY<W2X1YYZ[[w&t,,ru   c                P    V P                   VP                  P                  ,          # r^   )r   rl   rm   r   s   &&re   rx   CmathPrinter._print_known_const  s    xx//00ru   c                N    RV P                  VP                  ^ ,          4       R2# )zPrints `re(z)` as `z.real`r   z).realr`   rj   r   s   &&re   	_print_reCmathPrinter._print_re  #    4;;tyy|,-V44ru   c                N    RV P                  VP                  ^ ,          4       R2# )zPrints `im(z)` as `z.imag`r   z).imagr   r   s   &&re   	_print_imCmathPrinter._print_im  r#  ru   r   r  )rm   ra  rb  rc  __doc__rd  re  r   r   _known_functions_cmathrj  r   _known_constants_cmathr   r  r  rt   rx   r!  r%  rw  rx  ry  rz  s   00@@re   r  r    s     -K"H
u$$& C (>'C'C'E
F'Etq1hl?'E
FCLa-155 5+ Gs    A8r  z
log1p log2betafracfresnelcfresnelssignhypermeijergbesseljbesselybesselibesselkGoldenRatiophi
EulerGammaeulerCatalancatalanninfc                    . p. pV P                    FG  p\        V4      ^8X  d   Vw  rEpM\        R4      hVP                  V4       VP                  WV34       KI  	  W3# )zhelper function for _print_Integral that
- accepts an Integral expression
- returns a tuple of
   - a list variables of integration
   - a list of tuples of the upper and lower limits of integration
z%Only definite integrals are supported)r   r   NotImplementedErrorr   )integral_exprintegration_varsr   integration_rangeintegration_varlower_limitupper_limits   &      re   _unpack_integral_limitsrD    sl     F*11 !Q&8I5O+%&MNN0{01 2 ##ru   c                   l  a ] tR tRt oRtRtRt]! ]! ]	P                  4       ]P                  4        U Uu. uF  w  rV RV,           3NK  	  upp 4      4      t]P                  4        U Uu/ uF  w  rV RV,           bK  	  upp tR tR tR tR	 tR
 tR tR tRR ltR tR tRtVtR# u upp i u upp i )MpmathPrinteri  z@
Lambda printer for mpmath which maintains precision for floats
_mpmathcodezPython with mpmathzmpmath.c                    \        \        \        \        VP                  4      4      4      pR P                  V P                  R4      VR7      # )z{func}({args})
mpmath.mpf)r	  rj   )rK  tupler  int_mpf_rn   ro   )rd   rR   rj   s   && re   r  MpmathPrinter._print_Float  s@     5S!''*+,&&D,?,?,MTX&YYru   c                    R P                  V P                  R4      V P                  VP                  4      V P                  VP                  4      R7      # )z{func}({p})/{func}({q})rI  )r	  r  r  )rn   ro   r`   r  r  r  s   &&re   r  MpmathPrinter._print_Rational	  sH    (//$$\2kk!##kk!## 0 
 	
ru   c                $    V P                  V4      # r^   r  r  s   &&re   r  MpmathPrinter._print_Half  s    ##A&&ru   c                    R P                  V P                  R4      V P                  VP                  ^ ,          4      V P                  VP                  ^,          4      V P                  R4      4      # )z{}({}, {}, {})mpmath.gammaincz
mpmath.infr  r  s   &&re   r  MpmathPrinter._print_uppergamma  sZ    && 12KKq	"KKq	"-	/ 	/ru   c                    R P                  V P                  R4      V P                  VP                  ^ ,          4      V P                  VP                  ^,          4      4      # )z{}({}, 0, {})rS  r  r  s   &&re   r  MpmathPrinter._print_lowergamma  sL    %% 12KKq	"KKq	"$ 	$ru   c                    R P                  V P                  R4      V P                  VP                  ^ ,          4      4      # )z{0}({1})/{0}(2)z
mpmath.logr  r  s   &&re   _print_log2MpmathPrinter._print_log2   s8     ''-t{{166!9/EG 	Gru   c                    R P                  V P                  R4      V P                  VP                  ^ ,          4      4      # )z{}({})zmpmath.log1pr  r  s   &&re   _print_log1pMpmathPrinter._print_log1p$  s6    /QVVAY1GI 	Iru   c                (    V P                  WR R7      # )zmpmath.sqrtr  r  r  s   &&&re   r  MpmathPrinter._print_Pow(  s    mLLru   c           	       a  \        V4      w  r#R P                  S P                  R4      RP                  \	        S P
                  V4      4      S P                  VP                  ^ ,          4      RP                  V 3R lV 4       4      4      # )z{}(lambda {}: {}, {})zmpmath.quadr\   c              3   p   <"   T F+  pR \        \        SP                  V4      4      ,          x  K-  	  R# 5i)z(%s, %s)N)rJ  r  r`   )rb   r  rd   s   & re   rf   0MpmathPrinter._print_Integral.<locals>.<genexpr>2  s)     R6a*uSa-@'AAA6s   36)rD  rn   ro   rp   r  r`   rj   )rd   rR   r?  r   s   f&  re   _print_IntegralMpmathPrinter._print_Integral+  sr    #:1#= &--##M2		#dkk+;<=AFF1I&		R6RR	T 	Tru   c                t    Vw  pVw  pR P                  V P                  R4      V P                  V4      V4      # )z{}({}, derivative={})zmpmath.zetar  )rd   rj   
seq_ordersrc   deriv_orders   &&&  re   _print_Derivative_zeta$MpmathPrinter._print_Derivative_zeta5  s?    !&--.KKk
 	
ru   r   Nr  )rm   ra  rb  rc  r'  rd  re  r   r   ri  rj  _known_functions_mpmathr   _known_constants_mpmathr   r  r  r  r  r  rX  r[  r  rb  rg  rw  rx  )r{  r|  r}  s   00@re   rF  rF    s       K#H
u (?(E(E(GH(G!Y]	(GH C '>&C&C&E
F&Eda1ik>&E
FCZ
'/$GIMT
 
u 	I
Fs   B*+B0rF  c                   \   a  ] tR tRt o Rt]! ]P                  RR7      tR tR	R lt	Rt
V tR# )
SymPyPrinteriE  zPython with SymPyFrT  c                  a  VP                   P                  ;'       g    R pS P                  Y"'       d   RMR ,           VP                   P                  ,           4      : RRP	                  V 3R lVP
                   4       4      : R2# )r   r   r   r\   c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5ir^   r_   ra   s   & re   rf   /SymPyPrinter._print_Function.<locals>.<genexpr>Q  s     %L)3dkk#&6&6)rh   r   )r	  ra  ro   rm   rp   rj   )rd   rr   mods   f& re   r  SymPyPrinter._print_FunctionN  sb    ii""((b..sScb/IDIIL^L^/^_99%L$))%LMO 	Oru   c                (    V P                  WR R7      # )z
sympy.sqrtr  r  r  s   &&&re   r  SymPyPrinter._print_PowS  r  ru   r   Nr  )rm   ra  rb  rc  re  r   rz   rn  r  r  rw  rx  r  s   @re   rl  rl  E  s3     "H!33
O
L Lru   rl  N)'r'  collectionsr   	itertoolsr   
sympy.corer   sympy.core.modr   r   codeprinterr   rf  ri  rk  rl  rt   rx   rz   r  r  r   r{  setattrr
  sympy.printing.pycoder(  r)  r  r   _not_in_mpmathrj  
_in_mpmathr   ri  rj  rD  rF  rl  )r{  r|  s   00re   <module>r}     s(  
 $    " $	"$+-79>@EGM
!&(.08:>@HJN 	     "( *1 3; =B DK 	 	 	 %	 '1	 39	 
5	5	5 
 
F W  F  W	 
 F  W  W  v  
5  F  
5  F  
5  W     W! " W# $ WWW	5%WW
F	5
F
F	5
F?  F C$	5u \&
N2 N2b
E- E-P071 07f 
		A{Q0AB 
 
A{Q0BC 
54  3 
5
F	5	5	5	5
F
F
F
F
F
FWWW & 	$	  5$  5F 
		AL+/<+I+IJ 
 
 AL+/<+J+JK 
  ##%!6!<!<!>Z!>!>BYfqf!>Z
z 
F
F


F
Wyyyyy.   C$5'y	5	 $&J
% J
Z 
		AM;?,=> 
 
!AM;?,>? 
!L, LE [s   1JJ