K i ddZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z GddeZdZy) a This module implements the functionality to take any Python expression as a string and fix all numbers and other things before evaluating it, thus 1/2 returns Integer(1)/Integer(2) We use the ast module for this. It is well documented at docs.python.org. Some tips to understand how this works: use dump() to get a nice representation of any node. Then write a string of what you want to get, e.g. "Integer(1)", parse it, dump it and you'll see that you need to do "Call(Name('Integer', Load()), [node], [], None, None)". You do not need to bother with lineno and col_offset, just call fix_missing_locations() before returning the node. )Basic) SympifyError)parseNodeTransformerCallNameLoadfix_missing_locationsConstantTuplec$eZdZdZdZdZdZy) TransformcJtj|||_||_y)N)r__init__ local_dict global_dict)selfrrs ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/parsing/ast_parser.pyrzTransform.__init__s  &$&c t|jtr*tt t dt |ggSt|jtr*tt t dt |ggS|S)NIntegerfuncargskeywordsFloat) isinstancevalueintr rrr float)rnodes rvisit_ConstantzTransform.visit_Constant#so djj# &(4 463J"*./ /  E *(43H"*./ / rc x|j|jvr|S|j|jvr<|j|j}t|tt fs t |r|S|jdvr|Stttdtt|jggS)N)TrueFalseSymbolr) idrrrrtypecallabler rrr r )rr!name_objs r visit_NamezTransform.visit_Name,s 77doo %K WW(( (''0H(UDM2hx6H WW) )K$TtHdf/Etww'(2&78 8rc$|jjDcgc]}|j|}}|j|j}tt dt t |t |gg}t|Scc}w)NLambdar)rvisitbodyrrr r r )rr!argrr/ns r visit_LambdazTransform.visit_Lambda9so+/99>>:C 3::zz$))$ d8TV,df%t,r ;$Q'' ;sB N)__name__ __module__ __qualname__rr"r+r2rrrrs'  8(rrci}td| t|jd}t ||j|}t|dd}t|||S#t$rt dt |zwxYw)z Converts the string "s" to a SymPy expression, in local_dict. It converts all numbers to Integers before feeding it to Python and automatically creates Symbols. zfrom sympy import *eval)modezCannot parse %s.z) execrstrip SyntaxErrorrreprrr.compiler8)srraes r parse_exprrB@sK  ,9 !'')& ) *k*003A:v&A ; ++ 9-Q7889s A !BN)__doc__sympy.core.basicrsympy.core.sympifyrastrrrrr r r r rrBr6rrrGs3*#++++"("(H,r