K i8 >UdZddlmZddlmZmZmZmZmZm Z m Z m Z m Z m Z ddlmZddlZddlZddlmZddlZddlZddlmZmZddlmZdd lmZdd lmZdd lm Z dd l!m"Z"dd l#m$Z$ddl%m&Z&m'Z'dZ(e)e*e+fZ,e-e+efZ.ee/e,e.e.ge/e,fZ0d8dZ1d9d:dZ2d;dZ3Gdde/e,Z4GddZ5ddZ8d?dZ9d?dZ:d@dZ;dAdZ<e dBdZ? dCd Z@d@d!ZAd@d"ZBd@d#ZCd@d$ZDd@d%ZEd@d&ZFd@d'ZGd@d(ZH dBd)ZIeBeAeEeFeCfZJd*eKd+< dDd,ZLdEd-ZMdeJdd.f dFd/ZNdGd0ZOGd1d2ejZQeBeAeEeFeCe@eDe?e>eIe;eGd3 ZRd4jd5eRjDZUGd6d7ZVeVZWy)HzGTransform a string with Python-like source code into SymPy expression. ) annotations) generate_tokens untokenize TokenErrorNUMBERSTRINGNAMEOP ENDMARKER ERRORTOKENNEWLINE) iskeywordN)StringIO)AnyCallable)reduce)AssumptionKeys)Basic)Symbol)Function func_name)MaxMinczd|vry tjd|z S#t$rt|dkDcYSwxYw)a Predicate for whether a token name can be split into multiple tokens. A token is splittable if it does not contain an underscore character and it is not the name of a Greek letter. This is used to implicitly convert expressions like 'xyz' into 'x*y*z'. _FzGREEK SMALL LETTER ) unicodedatalookupKeyErrorlen) token_names `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/parsing/sympy_parser.py_token_splittabler%sL j#%%&;j&HIII #:""#s  ::c|j|d}|s|j|d}t|xrt|t S)z Predicate for whether a token name represents a callable function. Essentially wraps ``callable``, but looks up the token name in the locals and globals. r)getcallable isinstancer)token local_dict global_dict nextTokenfuncs r$_token_callabler/-sD >>%( #D uQx( D> :*T6":::c|gk(s |dddk(r tt|ftdfg}tdfg}d}t|}t |dddD]r\}}|\}} ||z dz } | dk(r|dz }n | dk(r|dz}|dk(s.| dz dk\r+|| dz dtk(r|d| dz |z|| dz dz|zcS|d| |z|| dz|zcS|S)Nr()r)rr r r" enumerate) nameresult beginningenddifflengthindexr*toknumtokvalis r$_add_factorial_tokensr@:s |vbz!}+lCy)I 9+C D [F!&2,/ A u UNQ  S= AID s] AID 191uzfQUmA.$6fq1u~ 1F1q56NBSHHbqzI-qr :S@@ A Mr0ceZdZdZy)ParenthesisGroupz9List of tokens representing an expression in parentheses.N)__name__ __module__ __qualname____doc__r0r$rBrBVsCr0rBc.eZdZdZdddZd dZdZdZy) AppliedFunctionz A group of tokens representing a function and its arguments. `exponent` is for handling the shorthand sin^2, ln^2, etc. NcH|g}||_||_||_gd|_y)Nfunctionargsexponent)rLrMrNitems)selfrLrMrNs r$__init__zAppliedFunction.__init__as)  H     5 r0c4|jg|jS)z1Return a list of tokens representing the function)rLrMrPs r$expandzAppliedFunction.expandis * **r0c4t||j|SN)getattrrO)rPr<s r$ __getitem__zAppliedFunction.__getitem__mstTZZ.//r0cVd|jd|jd|jdS)NzAppliedFunction(z, r4rKrSs r$__repr__zAppliedFunction.__repr__ps 04 tyy04 ? ?r0rV)rLTOKENrMrB)return list[TOKEN])rCrDrErFrQrTrXrZrGr0r$rIrI[s 6+0?r0rIcg}|D]C}t|tr |j|j3|j |E|SrV)r)rIextendrTappend)r7result2toks r$_flattenrcusEG  c? + NN3::< ( NN3   Nr0cdfd }|S)Ncg}g}d}|D]}|dtk(r|ddk(r |jtg|dz }n|ddk(r|dj||j}t |dkDr|dj |n9|dd} |||}|dg|z|dgz} |jt| |dz}|r|dj||j||r t d|S)zsGroup tokens between parentheses with ParenthesisGroup. Also processes those tokens recursively. rrr3r4r2zMismatched parentheses)r r`rBpopr"r_r) tokensr+r,r7stacks stacklevelr*stackinner parenGrouprecursors r$_innerz"_group_parentheses.._inners, 24)+  %EQx2~8s?MM"22"67!OJ1X_2J%%e,"JJLE6{Qr ))%0!&a  ()3)4!6',AhZ%%759+%E  &6z&BC!OJr !!%( e$7 %8 56 6 r0rgr]r+DICTr,rprG)rmrns` r$_group_parenthesesrqs'P Mr0cg}d}|D]x}t|tr3|rt|||rt|||d<d}4|j |F|dt k(r|}|j |fd}|j |z|S)zConvert a NAME token + ParenthesisGroup into an AppliedFunction. Note that ParenthesisGroups, if not applied to any function, are converted back into lists of tokens. Nr2r)r)rBr/rIr_r r`)rgr+r,r7symbolrbs r$_apply_functionsrts-/F F  c+ ,/&*kJ,VS9r  c" Vt^F MM# F MM#   Mr0c|g}d}t||ddD]\}}|j||rd}|dtk(r|ddk(r|dtk(rd}@t |t rt |t r|jtdfx|tdfk(r@|j dd k(r|j dd f|_|jtdf|dtk(s|jtdf|td fk(rtt |t r|jtdf|dtk(r|jtdfA|tdfk(sN|jtdfg|dtk(sut|||rt |t s|dtk(r&t|||r|jtdf|tdfk(r|jtdf|dtk(s|jtdf|r|j|d |S) aImplicitly adds '*' tokens. Cases: - Two AppliedFunctions next to each other ("sin(x)cos(x)") - AppliedFunction next to an open parenthesis ("sin x (cos x + 1)") - A close parenthesis next to an AppliedFunction ("(x+2)sin x") - A close parenthesis next to an open parenthesis ("(x+2)(x+3)") - AppliedFunction next to an implicitly applied function ("sin(x)cos x") FrNr.T*r3rrr4r2)zipr`r r r)rIrLr/)rgr+r,r7skiprbnextToks r$_implicit_multiplicationr{s -/F DFF12J/)- W c D  q6RCL r3i(t# r3i(r3ig7MM2s),QZ4'MM2s),S )MM2s),Q4Z(Ug7QZ4'OGZQ\,]MM2s),S )MM2s),QZ4'MM2s),S)-T fRj! Mr0c0g}d}d}d}t||ddD]G\}}|j||dtk(rB|dttt fvr,t ||||sI|jtdf|dz }f|dtk(r%|dtk(r|ddk(rt |||sd}|rot|ts|dtk(s|ddk(s|dtk(r |ddk(r|dtk(r|ddk(s|jtdf|dz }d}|s |dtk(r |dd vrd}#|r|dz},|jtd f|dz}J|r|j|d |r|jtd fg|z|S) z+Adds parentheses as needed after functions.rFrNr3**Trw)^r}rwr4r2) rxr`r r r r r/r)rIr_) rgr+r,r7 appendParenry exponentSkiprbrzs r$_implicit_applicationrs,.FK DLFF12J/! W c FdNwqz"i1IIsJ WE r3i(q !fnr!1gajD6HsJ <#  30FbLSVs]  b(WQZ3->"1:+ c0A r3i0#q( #(L qzRGAJ2B$B  MM2s) $ 1 KC!F fRj! CykK/0 Mr0cg}g}d}d}t||ddD]$\}}|dtk(r$|dtk(r|ddk(rt|||rd}n|r|dtk(r|ddk(rtdf}|j ||d|dcxk(r tk(rnn|dd k(r |dd k(rd}|d|dcxk(r tk(rnn|dd k(r |dd k(rd}|d =|rT|sR|dtk(r|dd k(r|dz }n |dd k(r|dz}|dk(r&|j ||j |g}|j |'|r|j |d |r|j ||S) apAllows functions to be exponentiated, e.g. ``cos**2(x)``. Examples ======== >>> from sympy.parsing.sympy_parser import (parse_expr, ... standard_transformations, function_exponentiation) >>> transformations = standard_transformations + (function_exponentiation,) >>> parse_expr('sin**4(x)', transformations=transformations) sin(x)**4 FrrNr}Trrr4r3rwr2)rxr r r/r`r_) rgr+r,r7rNconsuming_exponentlevelrbrzs r$function_exponentiationr8sFH EFF12J/ W q6T>gajB.71:3EsJ <%)" 1v~#a&J"6X& OOC 1v)r)c!fm c@Q%*"1v)r)c!fm c@Q%*"RL  01v|q6S=QJEVs]QJEz c" h' c9: fRj! h Mr0cdfd }|S)a2Creates a transformation that splits symbol names. ``predicate`` should return True if the symbol name is to be split. For instance, to retain the default behavior but avoid splitting certain symbol names, a predicate like this would work: >>> from sympy.parsing.sympy_parser import (parse_expr, _token_splittable, ... standard_transformations, implicit_multiplication, ... split_symbols_custom) >>> def can_split(symbol): ... if symbol not in ('list', 'of', 'unsplittable', 'names'): ... return _token_splittable(symbol) ... return False ... >>> transformation = split_symbols_custom(can_split) >>> parse_expr('unsplittable', transformations=standard_transformations + ... (transformation, implicit_multiplication)) unsplittable cPg}d}d}|D]}|rd} d}|dtk(r |ddvrd}nf|rc|dtk(rV|ddd} |rC|dd}|dd=d} | t|kr|| } | |vs| |vr|jtd| zfn| jr| g} t | dzt|D]0} || js| dz} n| j|| 2d j | } |j td ftd ftd | zftd fgnB| t|k(r|nd} |j t| ftd ftd | zftd fg| dz } | t|krd}d}d}|j||S)NFrr)rrTr2z%srNumberr3z'%s'r4r)r r"r`isdigitrangejoinr_r )rgr+r,r7splitsplit_previousrbrstok_typer?charcharsuse predicates r$_split_symbolsz,split_symbols_custom.._split_symbolss / C$ N1v~#a&,B"B3q6T>Q"V$%bz!}Hrs Ac&k/%ay:-1D"MM4*=>!\\^%)FE%*1q5#f+%>8'-ay'8'8':$%FA$) % VAY 7 8 $&775>D"MMD(+;b#Y,0&4-+@2s)+MN/03v;.>(HC"MMD#;S ,0&4-+@2s)+MNQ%c&k/,"E%)N"E MM# _/ b r0rorG)rrs` r$split_symbols_customrls,6p r0c~tt|||}t|||}t|||}t |}|S)aMakes the multiplication operator optional in most cases. Use this before :func:`implicit_application`, otherwise expressions like ``sin 2x`` will be parsed as ``x * sin(2)`` rather than ``sin(2*x)``. Examples ======== >>> from sympy.parsing.sympy_parser import (parse_expr, ... standard_transformations, implicit_multiplication) >>> transformations = standard_transformations + (implicit_multiplication,) >>> parse_expr('3 x y', transformations=transformations) 3*x*y )rqimplicit_multiplicationrtr{rcrgr+r,res1res2res3r7s r$rrsE" 7 5 6vz; WD D*k :D #D*k BD d^F Mr0c~tt|||}t|||}t|||}t |}|S)aMakes parentheses optional in some cases for function calls. Use this after :func:`implicit_multiplication`, otherwise expressions like ``sin 2x`` will be parsed as ``x * sin(2)`` rather than ``sin(2*x)``. Examples ======== >>> from sympy.parsing.sympy_parser import (parse_expr, ... standard_transformations, implicit_application) >>> transformations = standard_transformations + (implicit_application,) >>> parse_expr('cot z + csc z', transformations=transformations) cot(z) + csc(z) )rqimplicit_applicationrtrrcrs r$rrsE" 4 2 3FJ TD D*k :D z; ?D d^F Mr0cPttttfD] }||||}|S)anAllows a slightly relaxed syntax. - Parentheses for single-argument method calls are optional. - Multiplication is implicit. - Symbol names can be split (i.e. spaces are not needed between symbols). - Functions can be exponentiated. Examples ======== >>> from sympy.parsing.sympy_parser import (parse_expr, ... standard_transformations, implicit_multiplication_application) >>> parse_expr("10sin**2 x**2 + 3xyz + tan theta", ... transformations=(standard_transformations + ... (implicit_multiplication_application,))) 3*x*y*z + 10*sin(x**2)**2 + tan(theta) ) split_symbolsrrr)r7r+r,steps r$#implicit_multiplication_applicationrs70 7%'>@7fj+67 Mr0c g}d}|jdt||ddD]\}}|\}}|\} } |tk(rg|} | dvsOt| sD|dtk(r|ddk(s0|dtk(r|ddvr| tk(r| dk(s| |vr#|| t ur|jt| f| |vrg|j t tj| | d k(rt| || <nt| || <|jt| f| |vrD|| } t| tttfs t| r|jt| f;|j!t| d k7rd nd ftd ftt#t%| ftd fgn|j||f||f}|S) zAInserts calls to ``Symbol``/``Function`` for undefined variables.)r2rrN)TrueFalseNonerrv)r3,=r3rrr4)r`rxr rr null setdefaultsetaddrrr)rrtyper(r_reprstr) rgr+r,r7prevTokrbrztokNumtokVal nextTokNum nextTokValr6objs r$ auto_symbolrsFG MM(FF12J/(# W!( J T>D11  b(WQZ3-> b(WQZ:-E&",s1Bz)j.>d.J tTl+#%%dCE266t<$'/~Jt$'-d|Jt$ tTl+$!$'cNE4#@AXc]MM4,/ MM:#4x*ES tCI'S   MM66* +6"Q(#T Mr0cg}d}|d\}}t|}|tk(r|dk(r|dk(s|dk(r"|ddtk(r|j||S|dkDr|jtdftdftdftd ftd fg|dd D]\\}} |tk(r | d k(rd } d }|s|tk(r| dvr t d|r|j d|| fI|j d|| f^|S|j||S)zSubstitutes "lambda" with its SymPy equivalent Lambda(). However, the conversion does not take place if only "lambda" is passed because that is a syntax error. FrlambdarLambdar3r4N:rT)rwr}z)Starred arguments in lambda not supportedr2r)r"r r r_r rinsert) rgr+r,r7flagr=r>tokLenrrs r$lambda_notationrHs2 F DAYNFF [F ~&H, Q;&A+&)A,'*A MM& !, M+aZ MMx S S S S  #)* 8Rops r$factorial_notationrpsFJ , Rs r$ convert_xorrsaF , R<} r4j) vv./ MM66* +, Mr0cg}d}g}|D]\}}|tk(r|st|dk(st|dk(r"||ddr|j||fng}n|tk(rx|d k(r&t|dk(r|jt|fnO|d k(r&t|dk\r|jt|fn$|dk(r|s|jtd fng}ng}|j||f|s1|ddd k(s>|d t| }|d dj d\}} |dd} t|dk(r | |ddz } |j dd}| j dd} | j dd} dt| z} | | fD cgc]} | jdc} \} } |xsd}| xsdd| z}}| dt| z| z}}tdftdftdft|ftdftdftdftdft|ftdft|ftdftdftdftdft|ftdft|ftdftdfg}|j|g}|Scc} w)zw Allows 0.2[1] notation to represent the repeated decimal 0.2111... (19/90) Run this before auto_number. c&td|DS)Nc3$K|]}|dv yw) 0123456789_NrG).0r?s r$ z6repeated_decimals..is_digit..s1!1 %1s)all)ss r$is_digitz#repeated_decimals..is_digits1q111r0rvejrrr2r[]z0.Nrrr019r3Integerr4+Rationalr) rlowerr`r"r rreplacelstripr r_)rgr+r,r7rnumr=r>prepostrepetendzerosw repetendsabcdrseqs r$repeated_decimalsrsF2C E V C6Mc.G6<<>) FF+,&!s3x1}HMhs2wqz&: FF+, r\}SQ B<(33s8q= B<(3s FD>*C vv&' 3r71:$Jc#hY'FAq ,IC1vayH3x1}CF1I%++c2&C<<R(D''R0HD ME7;X6FGqxx}GOD) sA;3e qAs3x=0E9qAS 9%I II:&I S  II:&I S  IS )C, MM# CKEN MAHsKc g}|D]\}}|tk(r|}g}|jdr|dd}tdftdfg}d|vsd|vsd|vrB|j d s1td ftd ftt t |ftd fg}ntd ftd ft|ftd fg}|j||z|j||f|S)z Converts numeric literals to use SymPy equivalents. Complex numbers use ``I``, integer literals use ``Integer``, and float literals use ``Float``. )rJNr2rwIrvrE)0x0XFloatr3r4r) rendswithr r startswithrrr_r`) rgr+r,r7r=r>numberpostfixrs r$ auto_numberrsF , V FGz*9tSk2f}#-3&=**<8gS T#f+./"c<i(2s)F6$&(#Y0 MM#- ( MM66* +',* Mr0cg}d}|D]f\}}|tk(r|dk(rd}d}|j||f,|dk(r#|tk(rd}|jt|fT|j||fh|S)z=Converts floats into ``Rational``. Run AFTER ``auto_number``.FrTr)r r`rr)rgr+r,r7 passed_floatr=r>s r$ rationalizersFL , T> # # MM66* + T !f&6 L MM66* + MM66* + , Mr0c&g}tdf|vr|jtdf|jtdf|D]6}|tdfk(r|jtdf&|j|8|jtdf|S|}|S)aTransforms the equals sign ``=`` to instances of Eq. This is a helper function for ``convert_equals_signs``. Works with expressions containing one equals sign and no nesting. Expressions like ``(1=2)=False`` will not work with this and should be used with ``convert_equals_signs``. Examples: 1=2 to Eq(1,2) 1*2=x to Eq(1*2, x) This does not deal with function arguments yet. rEqr3rr4)r r`r )rgr+r,r7r*s r$_transform_equals_signr'sF CyF tTl# r3i  !ES ! r3i( MM%  !  r3i  M Mr0c~tt|||}t|||}t|||}t |}|S)a{ Transforms all the equals signs ``=`` to instances of Eq. Parses the equals signs in the expression and replaces them with appropriate Eq instances. Also works with nested equals signs. Does not yet play well with function arguments. For example, the expression ``(x=y)`` is ambiguous and can be interpreted as x being an argument to a function and ``convert_equals_signs`` will not work for this. See also ======== convert_equality_operators Examples ======== >>> from sympy.parsing.sympy_parser import (parse_expr, ... standard_transformations, convert_equals_signs) >>> parse_expr("1*2=x", transformations=( ... standard_transformations + (convert_equals_signs,))) Eq(2, x) >>> parse_expr("(1*2=x)=False", transformations=( ... standard_transformations + (convert_equals_signs,))) Eq(Eq(2, x), False) )rqconvert_equals_signsrtrrcrs r$rrDsE: 4 2 3FJ TD D*k :D !$ K @D d^F Mr0tuple[TRANS, ...]standard_transformationscg}t|j}t|jD]\}}}}}|j ||f|D] } | |||}t |S)zt Converts the string ``s`` to Python code, in ``local_dict`` Generally, ``parse_expr`` should be used. )rstriprreadliner`r) rr+r,transformationsrg input_coder=r>r transforms r$stringify_exprr ps{F!'')$J#2:3F3F#G(1a vv&'(%< 6:{;< f r0c t|||}|S)zn Evaluate Python code generated by ``stringify_expr``. Generally, ``parse_expr`` should be used. )eval)coder+r,exprs r$ eval_exprrs  k: 'D Kr0Tc0|i}n.t|ts tdt|vr t d|hi}t d|t t}|jD]%\}}t|tjs!|||<'t|d<t|d<nt|ts td|xsd}t|tr)|d k(r tdd}n|d k(r tdd }n t d |}t||||} |st!t#| d d} t%| ||} |j'tdD] } t|| < | S#t($r8} |j'tdD] } t|| < | t d| d} ~ wwxYw)aConverts the string ``s`` to a SymPy expression, in ``local_dict``. .. warning:: Note that this function uses ``eval``, and thus shouldn't be used on unsanitized input. Parameters ========== s : str The string to parse. local_dict : dict, optional A dictionary of local variables to use when parsing. global_dict : dict, optional A dictionary of global variables. By default, this is initialized with ``from sympy import *``; provide this parameter to override this behavior (for instance, to parse ``"Q & S"``). transformations : tuple or str A tuple of transformation functions used to modify the tokens of the parsed expression before evaluation. The default transformations convert numeric literals into their SymPy equivalents, convert undefined variables into SymPy symbols, and allow the use of standard mathematical factorial notation (e.g. ``x!``). Selection via string is available (see below). evaluate : bool, optional When False, the order of the arguments will remain as they were in the string and automatic simplification that would normally occur is suppressed. (see examples) Examples ======== >>> from sympy.parsing.sympy_parser import parse_expr >>> parse_expr("1/2") 1/2 >>> type(_) >>> from sympy.parsing.sympy_parser import standard_transformations,\ ... implicit_multiplication_application >>> transformations = (standard_transformations + ... (implicit_multiplication_application,)) >>> parse_expr("2x", transformations=transformations) 2*x When evaluate=False, some automatic simplifications will not occur: >>> parse_expr("2**3"), parse_expr("2**3", evaluate=False) (8, 2**3) In addition the order of the arguments will not be made canonical. This feature allows one to tell exactly how the expression was entered: >>> a = parse_expr('1 + x', evaluate=False) >>> b = parse_expr('x + 1', evaluate=False) >>> a == b False >>> a.args (1, x) >>> b.args (x, 1) Note, however, that when these expressions are printed they will appear the same: >>> assert str(a) == str(b) As a convenience, transformations can be seen by printing ``transformations``: >>> from sympy.parsing.sympy_parser import transformations >>> print(transformations) 0: lambda_notation 1: auto_symbol 2: repeated_decimals 3: auto_number 4: factorial_notation 5: implicit_multiplication_application 6: convert_xor 7: implicit_application 8: implicit_multiplication 9: convert_equals_signs 10: function_exponentiation 11: rationalize The ``T`` object provides a way to select these transformations: >>> from sympy.parsing.sympy_parser import T If you print it, you will see the same list as shown above. >>> str(T) == str(transformations) True Standard slicing will return a tuple of transformations: >>> T[:5] == standard_transformations True So ``T`` can be used to specify the parsing transformations: >>> parse_expr("2x", transformations=T[:5]) Traceback (most recent call last): ... SyntaxError: invalid syntax >>> parse_expr("2x", transformations=T[:6]) 2*x >>> parse_expr('.3', transformations=T[3, 11]) 3/10 >>> parse_expr('.3x', transformations=T[:]) 3*x/10 As a further convenience, strings 'implicit' and 'all' can be used to select 0-5 and all the transformations, respectively. >>> parse_expr('.3x', transformations='all') 3*x/10 See Also ======== stringify_expr, eval_expr, standard_transformations, implicit_multiplication_application Nz!expecting local_dict to be a dictzcannot use "" in local_dictzfrom sympy import *maxminz"expecting global_dict to be a dictrGrimplicitz!unknown transformation group namezr z-Error from parse_expr with transformed code: )r)dict TypeErrorr ValueErrorexecvarsbuiltinsrOtypesBuiltinFunctionTyperrrTr compile evaluateFalserrf Exception) rr+rr,evaluate builtins_dictr6r_transformationsr rvr?rs r$ parse_exprr$sJ  D );<<  677  "K0X &,,. (ID##u889$' D! (! E E  T *<==%+O/3' e # t   * !u @A A* !Z6F GD }T*J? Z tZ 5b) !A JqM ! Zb) !A JqM !Z"OPTx XYY Zs!2E F3FFctj|}tj|}tj|j dj }tj|S)zO Replaces operators with the SymPy equivalent and sets evaluate=False. r)astparseEvaluateFalseTransformervisit Expressionbodyvaluefix_missing_locations)rnodetransformed_nodes r$rrEsX 99Q&D&DE  $ $%5 66r0ceZdZejdej dej dejdejdejdejdejdiZ dZ ejdejd ej d ej"d ej$d ej&d iZdZdZdZdZy)r(AddMulPowOrAndNot)#Absimresignarg conjugateacosacotacscasecasinatanacoshacothacschasechasinhatanhcoscotcscsecsintancoshcothcschsechsinhtanhexplnlogsqrtcbrtNeLtLeGtGerc fd}t|t|j|jg|jf\}}t |dk(r|dSt jt jjt jt j|t jdt jdg S) Nc |\}}|\}}|jjvr tdtjtj j|jtj j|j|gtjdtjdg}||gz|fS)Nz3Only equation or inequality operators are supportedidctxr Fr,r;r,r.rMkeywords) __class__relational_operatorsrr&CallNameLoadr)keywordConstant)accop_rightr7leftrrightnewrPs r$reducerz7EvaluateFalseTransformer.visit_Compare..reducernsLFD IB||4#<#<< !VWW((XX00>CHHJjj& 5(9:++*CLLu5( (r0rrrar Frdrerf)rrxops comparatorsrqr"r&rjrk operatorsBitAndrlrmrn)rPr.rtrMrs` r$ visit_Comparez&EvaluateFalseTransformer.visit_Comparems ) S4#3#34r499o a t9>7NxxT^^CJJ7SXXZHkkj 58QRS  r0clg}|D]}t|tjr|j}t|tjr |j}|j|k(r,|j |j |j||j||j||SrV) r)r&rjr.rbr_flattenrMr`)rPrMr.r7r;arg_funcs r$r{z EvaluateFalseTransformer.flattens #C#sxx(88h1'}}H;;$&MM$,,sxx">?MM#& c" # r0c |jj|jvrX|j|jj}|j|j}|j|j }d}t |jtjrtjtjdtjtjtjtjd|gtjdtjdg }nt |jtj rut |j tjr||}}d }tjtjd tj|tjtjtjdgtjdtjdg }ntjtjd tj|tjtjtjdgtjdtjdg }|r||}}tjtj|tj||gtjdtjdg }|d vr!|j#|j$||_|S|S) NFr2rar)roperandr rdrerfTr3)r1r2)rrhrwr)rrrqr)r&SubrjrkrlUnaryOpUSubrnrmDivr{rM)rPr. sympy_classrrrqrevnew_nodes r$ visit_BinOpz$EvaluateFalseTransformer.visit_BinOps8 77   ...):):;KJJtzz*E::dii(DC$''377+U ;++S\\!_MuU!kkj SX@YZ[ DGGSWW-dii5"'%DC88U ; sxxz3<>> from sympy.parsing.sympy_parser import T, standard_transformations >>> assert T[:5] == standard_transformations c,tt|_yrV)r"_transformationNrSs r$rQz _T.__init__s_%r0ctSrV)rrSs r$__str__z _T.__str__sr0ct|tur|f}g}|D]}t|tur(|jt |j |rsEM">>>  0"(*=  c3h CH~$u+tT*DK78 # ;8 tE{ ??4)X2>B0f1hNn%%67 )-2=0&*/:059>I>0f%P6 UpD&:!&*!/:!P %6 + */2&26-*.tZ 7tZ(tZn 7us22ur& ))]_EZEZE\]]668Dr0