
    Pid                       d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	Z	ddl
mZmZmZ ddlZddlmZ ddlmZ ddlmc mZ dd	lmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& dd
l'm(Z(m)Z) ddl*m+Z+ ddl,m-Z- erddl.m/Z/ d8dZ0d8dZ1d8dZ2d Z3d Z4 e4e2e1e0e(          fd9dZ5d Z6 e6e7          Z8 e6e9          Z: e;d d  e<e          D             D                       Z=e=fdZ> e;d e=D                       Z? e>ej@                  ZA e>ejB                  ZC e>ejD                  ZE e>ejF                  ZG e>ejH                  ZI e>ejJ                  ZK e>ejL                  ZM e>ejN                  ZO e>ejP                  ZQ e>ejR                  ZS e>ejT                  ZU e>ej                  ZV e>ejW                  ZX e;g d          ZY e;g d          ZZeCeAz  eSz  eUz  eVz  eXz  eGz  eZz  eYz
  Z[e?e[z
  eYz  Z\e[e\z  Z]d e] Z^e]r
J e^            d:d#Z_ ed$          Z`d;d(Zad) Zbe e%d*Zcd+ Zd eae[           edec           G d, d-eje                                          Zf e;g d.          Zg e;eez             Zh eae[egz  eI e;g d/          z  z
             G d0 d1ef                      Zi eae[egz   e;d2g          z             G d3 d4ef                      Zj G d5 d6          Zkejeid7ZldS )<z
:func:`~pandas.eval` parsers.
    )annotationsN)partialreduce	iskeyword)TYPE_CHECKINGClassVarTypeVar)UndefinedVariableError)is_string_dtype)ARITH_OPS_SYMSBOOL_OPS_SYMSCMP_OPS_SYMS	LOCAL_TAGMATHOPS
REDUCTIONSUNARY_OPS_SYMSBinOpConstantFuncNodeOpTermUnaryOpis_term)clean_backtick_quoted_tokstokenize_string)Scope)printing)Callabletoktuple[int, str]returnc                $    | \  }}||dk    rdn|fS )a`  
    Rewrite the assignment operator for PyTables expressions that use ``=``
    as a substitute for ``==``.

    Parameters
    ----------
    tok : tuple of int, str
        ints correspond to the all caps constants in the tokenize module

    Returns
    -------
    tuple of int, str
        Either the input or token or the replacement values
    === r    toknumtokvals      p/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/core/computation/expr.py_rewrite_assignr+   7   s$     NFF6S==44f44    c                    | \  }}|t           j        k    r,|dk    rt           j        dfS |dk    rt           j        dfS ||fS ||fS )aj  
    Replace ``&`` with ``and`` and ``|`` with ``or`` so that bitwise
    precedence is changed to boolean precedence.

    Parameters
    ----------
    tok : tuple of int, str
        ints correspond to the all caps constants in the tokenize module

    Returns
    -------
    tuple of int, str
        Either the input or token or the replacement values
    &and|or)tokenizeOPNAMEr'   s      r*   _replace_booleansr5   J   sZ     NFFS===%''s]]=$&&v~6>r,   c                f    | \  }}|t           j        k    r|dk    rt           j        t          fS ||fS )a(  
    Replace local variables with a syntactically valid name.

    Parameters
    ----------
    tok : tuple of int, str
        ints correspond to the all caps constants in the tokenize module

    Returns
    -------
    tuple of int, str
        Either the input or token or the replacement values

    Notes
    -----
    This is somewhat of a hack in that we rewrite a string such as ``'@a'`` as
    ``'__pd_eval_local_a'`` by telling the tokenizer that ``__pd_eval_local_``
    is a ``tokenize.OP`` and to replace the ``'@'`` symbol with it.
    @)r2   r3   r   r'   s      r*   _replace_localsr8   c   s9    ( NFF3{I%%6>r,   c                      fdS )z
    Compose 2 callables.
    c                 &      | i |          S Nr&   )argskwargsfgs     r*   <lambda>z_compose2.<locals>.<lambda>   s     11QQ%7%7%7#8#8 r,   r&   )r>   r?   s   ``r*   	_compose2rA   }   s     988888r,   c                 f    t          |           dk    s
J d            t          t          |           S )z&
    Compose 2 or more callables.
       z.At least 2 callables must be passed to compose)lenr   rA   )funcss    r*   _composerF      s.     u::>>>K>>>)U###r,   sourcestrc                    t                    s
J d            t          j        fdt          |           D                       S )a  
    Compose a collection of tokenization functions.

    Parameters
    ----------
    source : str
        A Python source code string
    f : callable
        This takes a tuple of (toknum, tokval) as its argument and returns a
        tuple with the same structure but possibly different elements. Defaults
        to the composition of ``_rewrite_assign``, ``_replace_booleans``, and
        ``_replace_locals``.

    Returns
    -------
    str
        Valid Python source code

    Notes
    -----
    The `f` parameter can be any callable that takes *and* returns input of the
    form ``(toknum, tokval)``, where ``toknum`` is one of the constants from
    the ``tokenize`` module and ``tokval`` is a string.
    zf must be callablec              3  .   K   | ]} |          V  d S r;   r&   ).0xr>   s     r*   	<genexpr>z_preparse.<locals>.<genexpr>   s?         	
!     r,   )callabler2   
untokenizer   rG   r>   s    `r*   	_preparserQ      sb    < A;;,,,,,;     ((     r,   c                      fdS )zO
    Factory for a type checking function of type ``t`` or tuple of types.
    c                .    t          | j                  S r;   )
isinstancevalue)rL   ts    r*   r@   z_is_type.<locals>.<lambda>   s    Z++ r,   r&   )rV   s   `r*   _is_typerW      s     ,++++r,   c              #  x   K   | ]5}t          |t                    t          |t          j                  1|V  6d S r;   )rT   type
issubclassastAST)rK   nodes     r*   rM   rM      s\        $ #-T37";";     r,   c              #  @   K   | ]}t          t          |          V  d S r;   )getattrr[   )rK   names     r*   rM   rM      s,      99d##999999r,   c                >      fd|D             }t          |          S )zE
    Filter out AST nodes that are subclasses of ``superclass``.
    c              3  F   K   | ]}t          |          |j        V  d S r;   )rZ   __name__)rK   r]   
superclasss     r*   rM   z _filter_nodes.<locals>.<genexpr>   s4      VVDD*9U9UV$-VVVVVVr,   )	frozenset)rd   	all_nodes
node_namess   `  r*   _filter_nodesrh      s-     WVVVIVVVJZ   r,   c              #  $   K   | ]}|j         V  d S r;   )rc   rK   rL   s     r*   rM   rM      s$      ;;1AJ;;;;;;r,   )AssignModuleExpr)YieldGeneratorExpIfExpDictCompSetCompReprLambdaSetr\   IsIsNotz$cannot both support and not support 	node_nameCallable[..., None]c                      fd}|S )zV
    Return a function that raises a NotImplementedError with a passed node name.
    c                *    t          d d          )N'z' nodes are not implemented)NotImplementedError)selfr<   r=   rx   s      r*   r>   z _node_not_implemented.<locals>.f
  s    !"Li"L"L"LMMMr,   r&   )rx   r>   s   ` r*   _node_not_implementedr     s(    
N N N N N Hr,   _Tnodesset[str]Callable[[type[_T]], type[_T]]c                     d fd}|S )z
    Decorator to disallow certain nodes from parsing. Raises a
    NotImplementedError instead.

    Returns
    -------
    callable
    clstype[_T]r"   c                    d| _         D ]8}t          |          }d| }| xj         |fz  c_         t          | ||           9| S )Nr&   visit_)unsupported_nodesr   setattr)r   r]   
new_methodr`   r   s       r*   
disallowedzdisallow.<locals>.disallowed   sb     " 	+ 	+D.t44J"D??D!!dW,!!Cz****
r,   )r   r   r"   r   r&   )r   r   s   ` r*   disallowr     s)    	 	 	 	 	 	 r,   c                      fd}|S )zw
    Return a function to create an op class with its symbol already passed.

    Returns
    -------
    callable
    c                &    t          g|R i |S )z
        Return a partial function with an Op subclass with an operator already passed.

        Returns
        -------
        callable
        )r   )r~   r]   r<   r=   op_class	op_symbols       r*   r>   z_op_maker.<locals>.f7  s%     x<T<<<V<<<r,   r&   )r   r   r>   s   `` r*   	_op_makerr   .  s)    = = = = = = Hr,   )binaryunaryc                      fd}|S )z9
    Decorator to add default implementation of ops.
    c                                                     D ]^\  }}t          | | d          }t          | | d          }|D ]0}||         }|$t          ||          }t          | d| |           1_| S )N_ops_op_nodes_mapr   )itemsr_   r   r   )	r   op_attr_namer   opsops_mapopop_nodemade_op
op_classess	           r*   r>   zadd_ops.<locals>.fL  s    &0&6&6&8&8 	> 	>"L(#,44455Ccl#A#A#ABBG > >!"+&'"55GC!3'!3!3W===	>
 
r,   r&   )r   r>   s   ` r*   add_opsr   G  s#    
	 	 	 	 	 Hr,   c                     e Zd ZU dZeZded<   eZded<   e	e
z   ez   ZdZ e eeed                    ZeZdZ e eeed                    Zej        ej        ej        ej        ej        ej        ej        ej        iZd	ed
<   efd-dZd Zd Zd Zd Z d.dZ!d Z"d Z#	 	 d/dZ$d Z%d Z&d0dZ'd0dZ(d0dZ)d0dZ*d0d Z+d0d!Z,e,Z-d" Z.d0d#Z/d1d%Z0d& Z1d' Z2d2d(Z3d) Z4d* Z5d+ Z6d, Z7dS )3BaseExprVisitorz
    Custom ast walker. Parsers of other engines should subclass this class
    if necessary.

    Parameters
    ----------
    env : Scope
    engine : str
    parser : str
    preparser : callable
    zClassVar[type[Term]]
const_type	term_type)GtLtGtELtEEqNotEqInNotInBitAndBitOrAndOrAddSubMultDivPowFloorDivModTstrict)UAddUSubInvertNotztuple[str, ...]r   r"   Nonec                L    || _         || _        || _        || _        d | _        d S r;   )envengineparser	preparserassigner)r~   r   r   r   r   s        r*   __init__zBaseExprVisitor.__init__  s)    "r,   c                   t          |t                    r|                     |          }	 t          j        t          j        |                    }nF# t          $ r9}t          d |                                D                       rd|_	        |d }~ww xY wdt          |          j         }t          | |          } ||fi |S )Nc              3  4   K   | ]}t          |          V  d S r;   r   rj   s     r*   rM   z(BaseExprVisitor.visit.<locals>.<genexpr>  s(      ;;y||;;;;;;r,   z4Python keyword not valid identifier in numexpr queryr   )rT   rH   r   r[   fix_missing_locationsparseSyntaxErroranysplitmsgrY   rc   r_   )r~   r]   r=   cleanemethodvisitors          r*   visitzBaseExprVisitor.visit  s    dC   	NN4((E051A1ABB   ;;U[[]];;;;; SRAE
 0$t**-//$''wt&&v&&&s   &A 
B4BBc                    t          |j                  dk    rt          d          |j        d         } | j        |fi |S )NrC   z#only a single expression is allowedr   )rD   bodyr   r   )r~   r]   r=   exprs       r*   visit_ModulezBaseExprVisitor.visit_Module  sI    ty>>QCDDDy|tz$))&)))r,   c                (     | j         |j        fi |S r;   r   rU   r~   r]   r=   s      r*   
visit_ExprzBaseExprVisitor.visit_Expr  s    tz$*/////r,   c                H   |j         }t          |          }t          |          rt          |          r|| j        v rt	          t
          ||f          \  }}t	          t          ||f          \  }}	|s|s|s|	r | j        |                     }|	r;| j                            |j	        g          }
| 
                    |
| j                  }|r;| j                            |j	        g          }
| 
                    |
| j                  }|                     |          }||||fS r;   )r   rY   r   rewrite_mapmap_is_list_is_strr   add_tmprU   r   r   )r~   r]   leftrightop_instanceop_type	left_list
right_listleft_str	right_strr`   r   s               r*   _rewrite_membership_opz&BaseExprVisitor._rewrite_membership_op  s2   g{## 4== 	6WU^^ 	64;K0K0K$'4-$@$@!Iz"%ge}"="=Hi  :J :( :i :7d.w799  7x''66tTX66 6x''55~~dDH55ZZ$$;e++r,   Nc                    ||                      |j        d          }||                      |j        d          }|                     |||          \  }}}}||||fS )Nr   )sider   )r   r   r   r   )r~   r]   r   r   r   r   s         r*   _maybe_transform_eq_nez&BaseExprVisitor._maybe_transform_eq_ne  si    <::dif:55D=JJtzJ88E$($?$?dE$R$R!HdE8T5((r,   c                   t          j        t           j                  }|j        rnt	          |d          r^|j        sW|j        |k    rL| j                            t          j        |j                            }| 	                    || j                  }|j        rnt	          |d          r^|j        sW|j        |k    rL| j                            t          j        |j                            }| 	                    || j                  }||fS )NrU   )
npdtypefloat32	is_scalarhasattrreturn_typer   r   rU   r   )r~   r   r   f32r`   s        r*   _maybe_downcast_constantsz)BaseExprVisitor._maybe_downcast_constants  s    hrz""N	2g&&	2 O	2 !S(( 8##BJtz$:$:;;D>>$11DO	3w''	3 N	3  C'' 8##BJu{$;$;<<DNN422EU{r,   c                \    |                     | j        | j        | j        | j        |          S r;   )evaluater   r   r   r   )r~   binopeval_in_pythons      r*   _maybe_evalzBaseExprVisitor._maybe_eval  s-     ~~Hdk4;
 
 	
r,   inznot inr%   z!=<>z<=z>=c           	         |||          }|j         r(t          d|j         d|j         d|j         d          | j        dk    rK|j        t
          v rt          |dd          st          |dd          r|                     || j                  S |j        |v r|                     ||          S | j        dk    rt          |dd           t          k    sVt          t          |dd                     s8t          |dd           t          k    st          t          |dd                     r|                     |||z             S |S )	Nz unsupported operand type(s) for z: 'z' and 'r|   pytablesis_datetimeFr   )has_invalid_return_type	TypeErrorr   rY   r   r   r_   r   
binary_opsobjectr   )r~   r   r   lhsrhsr   maybe_eval_in_pythonress           r*   _maybe_evaluate_binopz%BaseExprVisitor._maybe_evaluate_binop  sz    bcll& 	136 1 1H1 1%(X1 1 1  
 ;*$$V|##]E(J(J#sM511 $
 ##C9996^####C888[J&&]D11V;;"73t#D#DEE <3t44>>"73t#D#DEE ?
 ''^>R-RSSS
r,   c                    |                      |          \  }}}}|                     ||          \  }}|                     ||||          S r;   )r   r   r  )r~   r]   r=   r   r   r   r   s          r*   visit_BinOpzBaseExprVisitor.visit_BinOp  sQ    $($?$?$E$E!HdE44T5AAe))"heDDDr,   c                    |                      |j                  }|                      |j                  } ||          S r;   )r   r   operand)r~   r]   r=   r   r  s        r*   visit_UnaryOpzBaseExprVisitor.visit_UnaryOp!  s6    ZZ  **T\**r'{{r,   r   c                4     | j         |j        | j        fi |S r;   )r   idr   r   s      r*   
visit_NamezBaseExprVisitor.visit_Name&  s"    t~dgtx::6:::r,   c                B    |                      |j        | j                  S r;   r   rU   r   r   s      r*   visit_NameConstantz"BaseExprVisitor.visit_NameConstant*      tz48444r,   c                B    |                      |j        | j                  S r;   r  r   s      r*   	visit_NumzBaseExprVisitor.visit_Num.  r  r,   c                B    |                      |j        | j                  S r;   r  r   s      r*   visit_ConstantzBaseExprVisitor.visit_Constant1  r  r,   c                v    | j                             |j                  }|                     || j                   S r;   )r   r   sr   r~   r]   r=   r`   s       r*   	visit_StrzBaseExprVisitor.visit_Str5  s/    x''~~dDH---r,   c                      j                              fd|j        D                       }                     | j                   S )Nc                V    g | ]%}                      |          j                  &S r&   r   r   )rK   r   r~   s     r*   
<listcomp>z.BaseExprVisitor.visit_List.<locals>.<listcomp>:  s/     L L LQAtx!8!8 L L Lr,   )r   r   eltsr   r  s   `   r*   
visit_ListzBaseExprVisitor.visit_List9  sE    x L L L L$) L L LMM~~dDH---r,   c                6    |                      |j                  S )zdf.index[4]r   r   s      r*   visit_IndexzBaseExprVisitor.visit_Index?  s    zz$*%%%r,   c                   ddl m} |                     |j                  }|                     |j                  } ||| j        | j        | j                  }	 |j        |         }n6# t          $ r)  ||| j        | j        | j                  }||         }Y nw xY w| j        	                    |          }	| 
                    |	| j                  S )Nr   )eval)
local_dictr   r   )r   )pandasr*  r   rU   slicer   r   r   AttributeErrorr   r   )
r~   r]   r=   pd_evalrU   slobjresultvr  r`   s
             r*   visit_SubscriptzBaseExprVisitor.visit_SubscriptC  s    ******

4:&&

4:&&dht{4;
 
 
	F#AA 	 	 	'$(4;t{  C FAAA	 x""~~d~111s   A( (0BBr-  c                    |j         }||                     |          j        }|j        }||                     |          j        }|j        }||                     |          j        }t          |||          S )zdf.index[slice(4,6)])lowerr   rU   upperstepr-  )r~   r]   r=   r5  r6  r7  s         r*   visit_SlicezBaseExprVisitor.visit_SliceW  sw    
JJu%%+E
JJu%%+Ey::d##)DUE4(((r,   c                   t          |j                  dk    rt          d          t          |j        d         t          j                  st          d          | j        j        t          d          	  | j	        |j        d         fi |}n"# t          $ r |j        d         j        }Y nw xY wt          |d|          | _        | j        t          d           | j	        |j        fi |S )	z
        support a single assignment node, like

        c = a + b

        set the assigner at the top level, must be a Name node which
        might or might not exist in the resolvers

        rC   z#can only assign a single expressionr   z5left hand side of an assignment must be a single nameNz%cannot assign without a target objectr`   z@left hand side of an assignment must be a single resolvable name)rD   targetsr   rT   r[   Namer   target
ValueErrorr   r   r  r_   r   rU   )r~   r]   r=   r   s       r*   visit_AssignzBaseExprVisitor.visit_Assigne  s    t|!!CDDD$,q/3844 	WUVVV8?"DEEE	*!tz$,q/<<V<<HH% 	* 	* 	*|A)HHH	*  &(;;= R   tz$*/////s   8B B10B1c                   |j         }|j        }|j        }t          |t          j                  r|                     |          }t          |d          r|j        }n || j                  }	 t          ||          }| j        
                    |          }	|                     |	| j                  S # t          $ r+ t          |t          j                  r|j        |k    r|cY S  w xY wt          dt!          |          j                   )NrU   zInvalid Attribute context )attrrU   ctxrT   r[   Loadr   r   r   r_   r   r   r.  r;  r  r=  rY   rc   )
r~   r]   r=   r@  rU   rA  visited_valueresolvedr2  r`   s
             r*   visit_AttributezBaseExprVisitor.visit_Attribute  s   y
hc38$$ 	 JJu--M}g.. 3(.(=22Hd++x''**~~dDH555!   eSX.. $58t3C3C#OOO	 Jd3ii6HJJKKKs   .AB3 31C(&C(c                0    t          |j        t          j                  r+|j        j        dk    r                     |j                  }nt          |j        t          j                  st          d          	                      |j                  }n:# t          $ r- 	 t          |j        j                  }n# t          $ r  w xY wY nw xY w|t          d|j        j                   t          |d          r|j        }t          |t                    r7 fd|j        D             }|j        rt          d|j         d           || S  fd|j        D             }|j        D ]p}t          |t          j                  st          d	|j        j         d
          |j        r0                      |j                   j                  ||j        <   q j                             ||i |          }                     | j                  S )N__call__z"Only named functions are supportedzInvalid function call rU   c                :    g | ]}                     |          S r&   )r   rK   argr~   s     r*   r$  z.BaseExprVisitor.visit_Call.<locals>.<listcomp>  s#    ===C

3===r,   z
Function "z$" does not support keyword argumentsc                V    g | ]%}                      |          j                  &S r&   r#  rI  s     r*   r$  z.BaseExprVisitor.visit_Call.<locals>.<listcomp>  s/    GGGc

311GGGr,   z keyword error in function call 'r|   )r`   r   )rT   funcr[   	Attributer@  rE  r;  r  r   r   r   r  r=  r   rU   r<   keywordsr`   keywordrJ  r   r   r   )r~   r]   r   r=   r  new_argskeyr`   s   `       r*   
visit_CallzBaseExprVisitor.visit_Call  sY   di// 	DINj4P4P&&ty11CCDIsx00 	@AAAjj++)   "49<00CC!    C ;777   3   	)Cc8$$ 	;====49===H} OOOO   3>! HGGGTYGGGH} 	F 	F!#s{33  %J49<JJJ   7 F&;djj&;&;DH&E&EF37O8##CC$<V$<$<==D>>t>:::s*   ;B 
C!B;:C;CCCc                    |S r;   r&   )r~   r   s     r*   translate_InzBaseExprVisitor.translate_In  s    	r,   c           
     J   |j         }|j        }t          |          dk    rR|                     |d                   }t	          j        ||j        |d                   }|                     |          S |j        }g }t          ||d          D ][\  }}	|                     t	          j	        |	g||                     |          g                    }
|	}|
                    |
           \|                     t	          j        t	          j                    |                    S )NrC   r   )r   r   r   Tr   )comparatorsr   r   )r   values)r   rV  rD   rT  r[   r   r   r   zipCompareappendBoolOpr   )r~   r]   r=   r   compsr   r   r   rW  compnew_nodes              r*   visit_ComparezBaseExprVisitor.visit_Compare  s   h  u::??""3q6**BI$)58DDDE::e$$$ yCt444 	$ 	$HBzzT@Q@QRT@U@U?VWWW H DMM(####zz#*		&AAABBBr,   c                h    t          |t          t          f          r|S |                     |          S r;   )rT   r   r   r   )r~   bops     r*   _try_visit_binopz BaseExprVisitor._try_visit_binop  s-    cB:&& 	Jzz#r,   c                @      fd}j         }t          ||          S )Nc                                         |           }                     |          }                    ||          \  }}}}                    |j        ||          S r;   )rb  r   r  r   )rL   yr  r	  r   r   r]   r~   s         r*   r   z-BaseExprVisitor.visit_BoolOp.<locals>.visitor  se    ''**C''**C%)%@%@sC%P%P"B#s--b$'3DDDr,   )rW  r   )r~   r]   r=   r   operandss   ``   r*   visit_BoolOpzBaseExprVisitor.visit_BoolOp  sA    	E 	E 	E 	E 	E 	E ;gx(((r,   r"   r   )NN)r   r   )r"   r   )r"   r-  r;   )8rc   
__module____qualname____doc__r   r   __annotations__r   r   r   r   r   r  binary_op_nodesdictrX  binary_op_nodes_mapr   	unary_opsunary_op_nodesunary_op_nodes_mapr[   r   r   r   r   r   rQ   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r   r&  visit_Tupler(  r3  r8  r>  rE  rR  rT  r_  rb  rg  r&   r,   r*   r   r   Z  s        
 
 (0J////&*I****->JO* $ss:tLLLMMI4Ncc)^DIIIJJ 		39	39	K '&&&6?     ' ' '* * *0 0 0, , ,6) ) ) )  .	
 	
 	
" (?& & & &PE E E
  
; ; ; ;5 5 5 55 5 5 55 5 5 5. . . .. . . . K& & &2 2 2 2() ) ) )0 0 0<L L L01; 1; 1; 1;f  C C C*  
	) 	) 	) 	) 	)r,   r   )Dictr[  r   r   )r[  rM  r   r   Tuplec                  P     e Zd Z ee eeee                    fd fdZ	 xZ
S )PandasExprVisitor)r>   r"   r   c                P    t                                          ||||           d S r;   superr   r~   r   r   r   r   	__class__s        r*   r   zPandasExprVisitor.__init__   s)     	ffi88888r,   rh  )rc   ri  rj  r   rQ   rF   r8   r5   r   r   __classcell__r|  s   @r*   rw  rw    sn         'h(9;UVV
 
 

9 
9 
9 
9 
9 
9 
9 
9 
9 
9 
9r,   rw  r   c                  (     e Zd Zddfd fdZ xZS )PythonExprVisitorNc                    | S r;   r&   rP   s     r*   r@   zPythonExprVisitor.<lambda>  s    F r,   r"   r   c                R    t                                          ||||           d S )N)r   ry  r{  s        r*   r   zPythonExprVisitor.__init__  s,     	ff	BBBBBr,   r;   rh  )rc   ri  rj  r   r}  r~  s   @r*   r  r    sY         .K-J-JC C C C C C C C C C Cr,   r  c                      e Zd ZU dZded<   ded<   ded<   	 	 	 	 dddZed             Zd ZddZ	ddZ
d Zed             Zd	S )rm   a  
    Object encapsulating an expression.

    Parameters
    ----------
    expr : str
    engine : str, optional, default 'numexpr'
    parser : str, optional, default 'pandas'
    env : Scope, optional, default None
    level : int, optional, default 2
    r   r   rH   r   r   numexprr,  Nr   Scope | Nonelevelintr"   r   c                    || _         |pt          |dz             | _        || _        || _        t          |         | j        | j        | j                  | _        |                                 | _        d S )NrC   )r  )	r   r   r   r   r   PARSERS_visitorr   terms)r~   r   r   r   r   r  s         r*   r   zExpr.__init__&  sd     	0%eai000$+t{KKZZ\\


r,   c                .    t          | j        dd           S )Nr   )r_   r  r~   s    r*   r   zExpr.assigner5  s    t}j$777r,   c                6    |                      | j                  S r;   )r  r   r  s    r*   rG  zExpr.__call__9  s    zz$(###r,   c                4    t          j        | j                  S r;   )r   pprint_thingr  r  s    r*   __repr__zExpr.__repr__<  s    $TZ000r,   c                *    t          | j                  S r;   )rD   r   r  s    r*   __len__zExpr.__len__?  s    49~~r,   c                @    | j                             | j                  S )z&
        Parse an expression.
        )r  r   r   r  s    r*   r   z
Expr.parseB  s     }""49---r,   c                    t          | j                  rt          | j        j        g          S t          d t	          j        | j                  D                       S )z1
        Get the names in an expression.
        c              3  $   K   | ]}|j         V  d S r;   )r`   )rK   terms     r*   rM   zExpr.names.<locals>.<genexpr>O  s$      GGtGGGGGGr,   )r   r  re   r`   comflattenr  s    r*   namesz
Expr.namesH  sT    
 4: 	0djo.///GGs{4:/F/FGGGGGGr,   )r  r,  Nr   )
r   rH   r   rH   r   r  r  r  r"   r   )r"   rH   )r"   r  )rc   ri  rj  rk  rl  r   propertyr   rG  r  r  r   r  r&   r,   r*   rm   rm     s         
 
 JJJKKKKKK
   " " " " " 8 8 X8$ $ $1 1 1 1   . . . H H XH H Hr,   rm   )pythonr,  )r    r!   r"   r!   )rG   rH   r"   rH   )rx   rH   r"   ry   )r   r   r"   r   )mrk  
__future__r   r[   	functoolsr   r   rO  r   r2   typingr   r	   r
   numpyr   pandas.errorsr   pandas.core.dtypes.commonr   pandas.core.commoncorecommonr  pandas.core.computation.opsr   r   r   r   r   r   r   r   r   r   r   r   r   r   pandas.core.computation.parsingr   r   pandas.core.computation.scoper   pandas.io.formatsr   collections.abcr   r+   r5   r8   rA   rF   rQ   rW   listr   rH   r   re   dir
_all_nodesrh   _all_node_namesmod
_mod_nodesstmt_stmt_nodesr   _expr_nodesexpr_context_expr_context_nodesboolop_boolop_nodesoperator_operator_nodesunaryop_unary_op_nodescmpop_cmp_op_nodescomprehension_comprehension_nodesexcepthandler_handler_nodes	arguments_arguments_nodes_keyword_nodesalias_alias_nodes_hacked_nodes_unsupported_expr_nodes_unsupported_nodes_base_supported_nodesintersection_msgr   r   r   r   _op_classesr   NodeVisitorr   _python_not_supported_numexpr_supported_callsrw  r  rm   r  r&   r,   r*   <module>r     s    # " " " " " 



                            0 0 0 0 0 0 5 5 5 5 5 5                                                          0 / / / / / & & & & & & )((((((5 5 5 5&   2   49 9 9$ $ $ h*O=W " " " " "J, , , 8D>>
(3-- Y  99C999    
 )3 ! ! ! ! );;
;;;;;]37##
mCH%%mCH%%#mC$455 cj))----,,ci(($}S%677 s011 =// s{++}SY'' 	66677 $)    $   	
    	  )+==N !$99<l<<        WT]]   0  , 11  & 

X) X) X) X) X)co X) X)  X)v "	"C"C"CDD $9Z'%9::  
//yy!P!P!PQQQS 9 9 9 9 9 9 9	 9 

4
4yy%7I7I
IJJC C C C C C C KJC:H :H :H :H :H :H :H :Hz '2C
D
Dr,   