
    I j8                    8   S r SSKJr  SSKJr  SSKJr  SSKrSSKJrJ	r	  SSK
rSSKJr  SSKJrJr  SSKJs  Jr  SS	KJrJr  SS
KJr  SSKJrJr  \(       a
  SSKJrJrJ r   Sr!Sr"Sr#\"\#-   r$Sr% " S S5      r& " S S\&5      r'SSSS.r( " S S5      r)S r*S r+Sr,\RZ                  \R\                  \R^                  \R`                  \Rb                  \Rd                  \*\+4r3\4" \5" \,\3SS95      r6S r7\Rp                  \Rr                  \Rp                  \Rr                  4r:\4" \5" \7\:SS95      r;S!r<\Rz                  \R|                  \R~                  \R                  \R                  \R                  \R                  4rD\4" \5" \<\DSS95      rE0 rF\6\;\E4 H  rG\FR                  \G5        M     S,S" jrI " S# S$\)5      rJS%rK\R                  \R                  \R                  \R                  4rO\4" \5" \K\OSS95      rP " S& S'\)5      rQ " S( S)\)5      rR " S* S+5      rSg)-z
Operator classes for eval.
    )annotations)datetime)partialN)TYPE_CHECKINGLiteral)	Timestamp)is_list_like	is_scalar)ensure_decodedresult_type_many)DEFAULT_GLOBALS)pprint_thingpprint_thing_encoded)CallableIterableIterator)sumprodminmax)sincostanexplogexpm1log1psqrtsinhcoshtanharcsinarccosarctanarccosharcsinharctanhabslog10floorceil)arctan2__pd_eval_local_c                  0  ^  \ rS rSr% SU 4S jjrS\S'   SSS jjr\SS j5       rSS jr	S r
SS	 jrS
 rSS jr\SS j5       r\S 5       r\r\SS j5       r\SS j5       r\S 5       r\R(                  SS j5       r\S 5       r\SS j5       rSrU =r$ )TermL   c                j   > [        U[        5      (       d  [        OU n[        [        U]  nU" U5      $ N)
isinstancestrConstantsuperr/   __new__)clsnameenvsideencodingklasssupr_new	__class__s          l/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pandas/core/computation/ops.pyr7   Term.__new__M   s,     *4 5 53u-    boolis_localc                    Xl         X l        X0l        [        U5      nUR	                  [
        5      =(       d	    U[        ;   U l        U R                  5       U l	        X@l
        g r2   )_namer:   r;   r4   
startswith	LOCAL_TAGr   rD   _resolve_name_valuer<   )selfr9   r:   r;   r<   tnames         r@   __init__Term.__init__T   sK    
	D	((3Ou7O((* rB   c                B    U R                   R                  [        S5      $ )N )r9   replacerH   rK   s    r@   
local_nameTerm.local_name^   s    yy  B//rB   c                ,    [        U R                  5      $ r2   )r   r9   rR   s    r@   __repr__Term.__repr__b   s    DII&&rB   c                    U R                   $ r2   valuerK   argskwargss      r@   __call__Term.__call__e       zzrB   c                    U $ r2    r[   s      r@   evaluateTerm.evaluateh   s    rB   c                   [        U R                  5      nU R                  nXR                  R                  ;   a.  [        U R                  R                  U   [        5      (       a  SnU R                  R                  XS9nU R                  U5        [        US5      (       a:  [        UR                  [        5      (       a  UR                  S:  a  [        S5      eU$ )NF)rD   ndim   z?N-dimensional objects, where N > 2, are not supported with eval)r4   rS   rD   r:   scoper3   typeresolveupdatehasattrrf   intNotImplementedError)rK   rS   rD   ress       r@   rI   Term._resolve_namek   s    )
=='JHHNN:&-
 -
 Hhhz=C3Jsxx$=$=#((Q,%Q  
rB   c                    U R                   n[        U[        5      (       a$  U R                  R	                  U R
                  X!S9  Xl        g)z
search order for local (i.e., @variable) variables:

scope, key_variable
[('locals', 'local_name'),
 ('globals', 'local_name'),
 ('locals', 'key'),
 ('globals', 'key')]
)	new_valueN)r9   r3   r4   r:   swapkeyrS   rZ   )rK   rZ   keys      r@   rk   Term.update|   s<     ii c3HHT__cC
rB   c                ,    [        U R                  5      $ r2   )r
   rJ   rR   s    r@   r
   Term.is_scalar   s    %%rB   c                     U R                   R                  R                  $ ! [         aA     U R                   R                  s $ ! [         a    [	        U R                   5      s s $ f = ff = fr2   )rJ   valuesdtypeAttributeErrorri   rR   s    r@   ri   	Term.type   s_    		);;%%+++ 	)){{(((! )DKK(()		)s,   " 
A-AA-A)$A-(A))A-c                h    [        U 5      R                   SU R                  < SU R                    S3$ )Nz(name=z, type=))ri   __name__r9   rR   s    r@   rawTerm.raw   s.    t*%%&fTYYM1MMrB   c                     U R                   R                   n[        U[        [        R
                  45      $ ! [         a    U R                   n N8f = fr2   )ri   r{   
issubclassr   np
datetime64rK   ts     r@   is_datetimeTerm.is_datetime   sF    			A !h677  			A	   8 AAc                    U R                   $ r2   rJ   rR   s    r@   rZ   
Term.value   s    {{rB   c                    Xl         g r2   r   )rK   rr   s     r@   rZ   r      s    rB   c                    U R                   $ r2   rF   rR   s    r@   r9   	Term.name       zzrB   c                .    U R                   R                  $ r2   )rJ   rf   rR   s    r@   rf   	Term.ndim   s    {{rB   )rF   rJ   r<   r:   rD   r;   rZ   )NNreturnNoner   r4   )r   r/   r   rC   )r   rm   )r   
__module____qualname____firstlineno__r7   __annotations__rM   propertyrS   rV   r^   rc   rI   rk   r
   ri   return_typer   r   rZ   setterr9   rf   __static_attributes____classcell__r?   s   @r@   r/   r/   L   s    
 N! 0 0'"$ & & 
) 
) KN N 8 8   \\         rB   r/   c                  4    \ rS rSrS r\S 5       rSS jrSrg)r5      c                    U R                   $ r2   r   rR   s    r@   rI   Constant._resolve_name   r`   rB   c                    U R                   $ r2   rY   rR   s    r@   r9   Constant.name   r   rB   c                ,    [        U R                  5      $ r2   )reprr9   rR   s    r@   rV   Constant.__repr__   s     DIIrB   rb   Nr   )	r   r   r   r   rI   r   r9   rV   r   rb   rB   r@   r5   r5      s       rB   r5   ~&|)notandorc                      \ rS rSr% SrS\S'   SSS jjrSS jrSS jr\	S	 5       r
\	SS
 j5       r\	S 5       r\	SS j5       r\	SS j5       rSrg)Op   z&
Hold an operator of arbitrary arity.
r4   opNc                P    [         R                  X5      U l        X l        X0l        g r2   )_bool_op_mapgetr   operandsr<   )rK   r   r   r<   s       r@   rM   Op.__init__   s    ""2*  rB   c                ,    [        U R                  5      $ r2   )iterr   rR   s    r@   __iter__Op.__iter__   s    DMM""rB   c                x    S U R                    5       n[        SU R                   S3R                  U5      5      $ )zG
Print a generic n-ary operator and its operands using infix notation.
c              3  @   #    U  H  nS [        U5       S3v   M     g7f)(r~   N)r   ).0oprs     r@   	<genexpr>Op.__repr__.<locals>.<genexpr>   s     E}Q|C()+}s    )r   r   r   join)rK   pareneds     r@   rV   Op.__repr__   s5    
 Ft}}EayN//899rB   c                    U R                   [        [        -   ;   a  [        R                  $ [        S [        R                  " U 5       5       6 $ )Nc              3  8   #    U  H  oR                   v   M     g 7fr2   ri   r   terms     r@   r   !Op.return_type.<locals>.<genexpr>   s     !J8I))8I   )r   CMP_OPS_SYMSBOOL_OPS_SYMSr   bool_r   comflattenrR   s    r@   r   Op.return_type   s8     77|m3488O!JD8I!JKKrB   c                    U R                   n[        [        R                  " S5      /5      nU R                  [
        :H  =(       a    X-
  $ )Nobject)operand_types	frozensetr   rz   r   r   )rK   typesobj_dtype_sets      r@   has_invalid_return_typeOp.has_invalid_return_type   s<    ""!288H#5"676)Ce.CCrB   c                N    [        S [        R                  " U 5       5       5      $ )Nc              3  8   #    U  H  oR                   v   M     g 7fr2   r   r   s     r@   r   #Op.operand_types.<locals>.<genexpr>   s     A/@t/@r   )r   r   r   rR   s    r@   r   Op.operand_types   s    As{{4/@AAArB   c                :    [        S U R                   5       5      $ )Nc              3  8   #    U  H  oR                   v   M     g 7fr2   )r
   )r   operands     r@   r   Op.is_scalar.<locals>.<genexpr>   s     BM$$Mr   )allr   rR   s    r@   r
   Op.is_scalar   s    BDMMBBBrB   c                     U R                   R                  n[        U[        [
        R                  45      $ ! [         a    U R                   n N8f = fr2   )r   ri   r{   r   r   r   r   r   s     r@   r   Op.is_datetime   sL    	!  %%A !h677  	!  A	!r   )r<   r   r   r2   )r   r4   r   zIterable[Term | Op]r   r   )r   r   r   r   )r   r   r   r   __doc__r   rM   r   rV   r   r   r   r   r
   r   r   rb   rB   r@   r   r      s     	G!
#: L L D D
 B B C C 8 8rB   r   c                     U R                  U5      $ ! [         a;    [        U 5      (       a$   UR                  U 5      s $ ! [         a     Of = fX;   s $ f = f)zT
Compute the vectorized membership of ``x in y`` if possible, otherwise
use Python.
isinr{   r	   xys     r@   _inr     sY    
vvay ??vvay ! vs1    AAA
AAAAAc                     U R                  U5      ) $ ! [         a<    [        U 5      (       a%   UR                  U 5      ) s $ ! [         a     Of = fX;  s $ f = f)zX
Compute the vectorized membership of ``x not in y`` if possible,
otherwise use Python.
r   r   s     r@   _not_inr     s^    
q	z ??q	z!! zs2    AA A
AAAAA)><z>=z<=z==z!=inznot inT)strict)r   r   r   r   )+-*/z**z//%c                "    [        U [        5      $ r2   )r3   r/   )objs    r@   is_termr  I  s    c4  rB   c                  T   ^  \ rS rSrSrS	U 4S jjrS rS
S jrSS jrSS jr	Sr
U =r$ )BinOpiM  zl
Hold a binary operator and its operands.

Parameters
----------
op : str
lhs : Term or Op
rhs : Term or Op
c                "  > [         TU ]  XU45        X l        X0l        U R	                  5         U R                  5          [        U   U l        g ! [         a5  n[        [        R                  5       5      n[        SU< SU 35      UeS nAff = f)NzInvalid binary operator , valid operators are )r6   rM   lhsrhs_disallow_scalar_only_bool_opsconvert_values_binary_ops_dictfuncKeyErrorlistkeys
ValueError)rK   r   r  r  errr  r?   s         r@   rM   BinOp.__init__X  s    3Z(++-	(,DI 	(--/0D*2&0FtfM	s    A 
B0B		Bc                h    U R                  U5      nU R                  U5      nU R                  X#5      $ )z
Recursively evaluate an expression in Python space.

Parameters
----------
env : Scope

Returns
-------
object
    The result of an evaluated expression.
)r  r  r  )rK   r:   leftrights       r@   r^   BinOp.__call__j  s-     xx}yy%%rB   c                J   US:X  a	  U " U5      nO~U R                   R                  UUUUUS9nU R                  R                  UUUUUS9nU R                  U;   a'  U R	                  UR
                  UR
                  5      nOSSKJn	  U	" XX#S9nUR                  U5      n
U" XS9$ )a  
Evaluate a binary operation *before* being passed to the engine.

Parameters
----------
env : Scope
engine : str
parser : str
term_type : type
eval_in_python : list

Returns
-------
term_type
    The "pre-evaluated" expression as an instance of ``term_type``
python)engineparser	term_typeeval_in_pythonr   )eval)
local_dictr  r  )r:   )	r  rc   r  r   r  rZ   pandas.core.computation.evalr  add_tmp)rK   r:   r  r  r  r  ro   r  r  r  r9   s              r@   rc   BinOp.evaluate}  s    " Xs)C 88$$#- % D HH%%#- & E ww.(ii

EKK8=4N{{3''rB   c                @  ^  U 4S jnT R                   T R                  p2[        U5      (       a  UR                  (       a  [        U5      (       a  UR                  (       a|  UR
                  n[        U[        [        45      (       a  U" U5      n[        [        U5      5      nUR                  b  UR                  S5      nT R                  R                  U5        [        U5      (       a  UR                  (       a  [        U5      (       a  UR                  (       a}  UR
                  n[        U[        [        45      (       a  U" U5      n[        [        U5      5      nUR                  b  UR                  S5      nT R                   R                  U5        ggggg)z;
Convert datetimes to a comparable value in an expression.
c                l   > TR                   b  [        [        TR                   S9nO[        nU" U 5      $ )N)r<   )r<   r   r   r   )rZ   encoderrK   s     r@   	stringify'BinOp.convert_values.<locals>.stringify  s-    }}(!"6O&5>!rB   NUTC)r  r  r  r   r
   rZ   r3   rm   floatr   r   tz
tz_convertrk   )rK   r$  r  r  vs   `    r@   r	  BinOp.convert_values  s   
	" 88TXXS3<<COO		A!c5\**aL.+,AttLL'HHOOA3<<COO		A!c5\**aL.+,AttLL'HHOOA BOO<rB   c                   U R                   nU R                  nUR                  n[        USU5      nUR                  n[        USU5      nUR                  (       d  UR                  (       ak  U R
                  [        ;   aV  [        U[        [        R                  45      (       a%  [        U[        [        R                  45      (       d  [        S5      eg g g )Nri   z$cannot evaluate scalar only bool ops)r  r  r   getattrr
   r   _bool_ops_dictr   rC   r   r   rn   )rK   r  r  rhs_rtlhs_rts        r@   r  $BinOp._disallow_scalar_only_bool_ops  s    hhhh 00]]cmm>) vbhh'788"6D"((+;<< &&LMM	 =	 * ,rB   )r  r  r  )r   r4   r   r   )r  r4   r   )r   r   r   r   r   rM   r^   rc   r	  r  r   r   r   s   @r@   r  r  M  s*    $&&/(bBN NrB   r  )r   r   r   r   c                  X   ^  \ rS rSrSrSU 4S jjrS	S jrS
S jr\SS j5       r	Sr
U =r$ )UnaryOpi  a  
Hold a unary operator and its operands.

Parameters
----------
op : str
    The token used to represent the operator.
operand : Term or Op
    The Term or Op operand to the operator.

Raises
------
ValueError
    * If no function associated with the passed operator token is found.
c                   > [         TU ]  X45        X l         [        U   U l        g ! [
         a  n[        SU< S[         35      UeS nAff = f)NzInvalid unary operator r  )r6   rM   r   _unary_ops_dictr  r  r  UNARY_OPS_SYMS)rK   r   r   r  r?   s       r@   rM   UnaryOp.__init__  sZ    Z(	'+DI 	)"/EnEUV	s   ( 
AA		Ac                F    U R                  U5      nU R                  U5      $ r2   )r   r  )rK   r:   r   s      r@   r^   UnaryOp.__call__  s    ,,s#yy!!rB   c                L    [        U R                   SU R                   S35      $ )Nr   r~   )r   r   r   rR   s    r@   rV   UnaryOp.__repr__  s"    twwiqa899rB   c                `   U R                   nUR                  [        R                  " S5      :X  a  [        R                  " S5      $ [	        U[
        5      (       a>  UR                  [        ;   d  UR                  [        ;   a  [        R                  " S5      $ [        R                  " S5      $ )NrC   rm   )	r   r   r   rz   r3   r   r   _cmp_ops_dictr.  )rK   r   s     r@   r   UnaryOp.return_type  sr    ,,"((6"2288F##gr""JJ-'7::+G88F##xxrB   )r  r   )r   zLiteral['+', '-', '~', 'not']r   r   r   MathCallr   )r   znp.dtype)r   r   r   r   r   rM   r^   rV   r   r   r   r   r   s   @r@   r3  r3    s+     	"
:  rB   r3  c                  <   ^  \ rS rSrSU 4S jjrS rSS jrSrU =r$ )r@  i  c                F   > [         TU ]  UR                  U5        Xl        g r2   )r6   rM   r9   r  )rK   r  r\   r?   s      r@   rM   MathCall.__init__  s    D)	rB   c                    U R                    Vs/ s H
  o"" U5      PM     nnU R                  R                  " U6 $ s  snf r2   )r   r  )rK   r:   r   r   s       r@   r^   MathCall.__call__  s6    &*mm4mBsGm4yy~~x(( 5s   ;c                    [        [        U R                  5      n[        U R                   SSR                  U5       S35      $ )Nr   ,r~   )mapr4   r   r   r   r   )rK   r   s     r@   rV   MathCall.__repr__$  s8    sDMM*twwiq();(<A>??rB   )r  r   r   )	r   r   r   r   rM   r^   rV   r   r   r   s   @r@   r@  r@    s    )
@ @rB   r@  c                  (    \ rS rSrSS jrSS jrSrg)FuncNodei)  c                l    U[         ;  a  [        SU S35      eXl        [        [        U5      U l        g )N"z" is not a supported function)MATHOPSr  r9   r-  r   r  )rK   r9   s     r@   rM   FuncNode.__init__*  s2    wq&CDEE	B%	rB   c                    [        X5      $ r2   )r@  )rK   r\   s     r@   r^   FuncNode.__call__0  s    ##rB   )r  r9   N)r9   r4   r   r   r?  )r   r   r   r   rM   r^   r   rb   rB   r@   rK  rK  )  s    &$rB   rK  r   )Tr   
__future__r   r   	functoolsr   operatortypingr   r   numpyr   pandas._libs.tslibsr   pandas.core.dtypes.commonr	   r
   pandas.core.commoncorecommonr   pandas.core.computation.commonr   r   pandas.core.computation.scoper   pandas.io.formats.printingr   r   collections.abcr   r   r   
REDUCTIONS_unary_math_ops_binary_math_opsrN  rH   r/   r5   r   r   r   r   r   gtltgeleeqne_cmp_ops_funcsdictzipr=  r   and_or__bool_ops_funcsr.  ARITH_OPS_SYMSaddsubmultruedivpowfloordivmod_arith_ops_funcs_arith_ops_dictr
  drk   r  r  r6  posneginvert_unary_ops_funcsr5  r3  r@  rK  rb   rB   r@   <module>r~     s0   #   
  )
 !   :
   +
.   
,
, 	p  p ft  3c238 38l   BKKKKKKKKKKKK	 S~dCD'==(,,x||Lc-FG6LLLLLLLLLL  s>+;DIJ 
	9AA 
:!UNB UNp (LL(,,Q s>+;DIJ-b -`@r @$ $rB   