K i-dZddlmZddlmZddlmZddlmZddl m Z m Z ddl mZmZGd d eZeed Zy ) z A Printer for generating executable code. The most important function here is srepr that returns a string so that the relation eval(srepr(expr))=expr holds in an appropriate environment. ) annotations)Any) AppliedUndef)Mul)repr_dpsto_str)Printerprint_functioncheZdZUdZdddZded<dZdZd>=s/ct|tr|St|dr|jSt|drtt|jdr^g}|jD]"}|j |j |$|jjddj|zzSt|dr)t|drd|jd |jd St|S) z' The fallback printer. __srepr__r__iter__(%s), __module____name__z<'.z'>) isinstancestrhasattrrrappend_print __class__r!rr )rexprlos r emptyPrinterzReprPrinter.emptyPrinter s dC K T; '>># # T6 "wtyy*'EAYY )Q( )>>**Vdiil-BB B T< (WT:-F"&//4==A At9 c|j||}t|j|}t|j}|ddj |zzS)N)rrr)_as_ordered_termsmapr'typer!rrr)rrclsnames r _print_AddzReprPrinter._print_Add2sN%%d%%84;;%t*%%$))D/111r-c"|jSN)__repr__rr)s r _print_CyclezReprPrinter._print_Cycle8s}}r-cddlm}m}ddlm}|j }||d|dddd n|j jd d }|ro|jsy |||jd z jtdd}|jd}|dk(sd||dvr ||d|d|z}d|zS|j}|s6|jdkrdt|jzSd|jzSt|jd|dd zd|jzz}t|jx} } t|t| kr|} d| zS)Nr) PermutationCycle)sympy_deprecation_warningzw Setting Permutation.print_cyclic is deprecated. Instead use init_printing(perm_cyclic=z). z1.6z#deprecated-permutation-print_cyclic)deprecated_since_versionactive_deprecations_target stacklevelrTz Permutation()r r<(,z Permutation%szPermutation(%s)zPermutation([], size=%s)z , size=%s) sympy.combinatorics.permutationsr;r<sympy.utilities.exceptionsr= print_cyclic _settingsgetsizer7lenrfindsupportr$ array_form) rr)r;r<r=rslasttrimusefulls r_print_PermutationzReprPrinter._print_Permutation;soGH!..  " %++6-8*/+P ..,,]DAK 99&d DIIM*335c'lmDA773'>'+{{499'='+{{499'='+{{28 8 tyy! )A HHRL499% )" T!Q$Z( ) ) >>22DKKNCCr-cy)Ntruerer8s r_print_BooleanTruezReprPrinter._print_BooleanTruesr-cy)Nfalserer8s r_print_BooleanFalsezReprPrinter._print_BooleanFalserr-cy)Nnanrer8s r _print_NaNzReprPrinter._print_NaNsr-c|jdvr|j}ntj|}t |j |}t |j}|ddj|zzS)N)oldnonerr) ras_ordered_factorsr make_argsr0r'r1r!rr2s r _print_MulzReprPrinter._print_Mulsc ::_ ,**,D==&D4;;%t*%%$))D/111r-cxd|j|jd|j|jdS)Nz Rational(rr)r'rpqr8s r_print_RationalzReprPrinter._print_Rationals'%)[[%8$++dff:MNNr-cbd|jj|j|jfzS)Nz %s(%d, %d))r(r!rprr8s r_print_PythonRationalz!ReprPrinter._print_PythonRationals&t~~66GGGr-cxd|j|jd|j|jdS)Nz Fraction(rr)r' numerator denominatorr8s r_print_FractionzReprPrinter._print_Fractions)%)[[%@$++dN^N^B_``r-ct|jt|j}d|jj ||jfzS)Nz%s('%s', precision=%i)) mlib_to_str_mpf_r_precr(r!)rr)rZs r _print_FloatzReprPrinter._print_Floats;  HTZZ$8 9'4>>+B+BAtzz*RRRr-c d|j|jd|j|jd|j|jd|j|jd S)NzSum2(z, (rz)))r'frr[br8s r _print_Sum2zReprPrinter._print_Sum2sL+/;;tvv+> DFF@S+/;;tvv+> DFF@SU Ur-cl|jjd|j|jdSNrBr)r(r!r'name)rrPs r _print_StrzReprPrinter._print_Strs$;;//QVV1DEEr-c|j}|jr|j}|j|d<|ik(r5|jj d|j |jdS|jDcgc] \}}|d|}}}|jj d|j |jddj|dScc}}w)N dummy_indexrBr=r) _assumptions_origis_Dummycopyrr(r!r'rrrrr)dkvattrs r _print_SymbolzReprPrinter._print_Symbols  " " ==A#//Am  7#~~66 DII8NO O12;Aq!$;D;#'>>#:#:#';;tyy#9499T?L L>22DLLt4LMMr-ct|Sr6)reprr8s r _print_strzReprPrinter._print_str s Dzr-cvt|dk(rd|j|dzSd|j|dzS)Nr z(%s,)rrr)rLr'rr8s r _print_tuplezReprPrinter._print_tuple s; t9>T[[a11 1DLLt44 4r-cN|jjd|jdS)Nz('z'))r(r!rr8s r_print_WildFunctionzReprPrinter._print_WildFunctions!^^44dii@@r-c|jjd|j|jd|j|j dSr)r(r!r'rootcoeffsr8s r_print_AlgebraicNumberz"ReprPrinter._print_AlgebraicNumbers<#~~66 KK "DKK $>@ @r-c |jjd|j|jd|j|jd|j|j dSrr(r!r'symbolsdomainr)rrings r_print_PolyRingzReprPrinter._print_PolyRingsI#'>>#:#: KK %t{{4;;'?TZZAXZ Zr-c |jjd|j|jd|j|jd|j|j dSrr)rfields r_print_FracFieldzReprPrinter._print_FracFieldsI#(??#;#; KK & ELL(A4;;u{{C[] ]r-ct|j}|j|jjd|j j d|j|jd|j|dSNT)rreverserBrr)listtermssortrrr(r!r')rpolyrs r_print_PolyElementzReprPrinter._print_PolyElement"s[TZZ\" tyy 5#~~66 DII8NPTP[P[\aPbccr-ct|jj}|j|jj dt|j j}|j|jj d|j|}|j|}|jjd|j|jd|d|dSr) rnumerrrrrdenomr'r(r!)rfrac numer_terms denom_termsrrs r_print_FracElementzReprPrinter._print_FracElement's4::++-. TZZ--t<4::++-. TZZ--t< K( K(#'>>#:#:DKK r%sF#,8,|.'|.|  //r-