
    -j                        % S r SSKJr  SSKrSSKJr  SSKrSSKrSSK	J
r
  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  \(       a  SSKr\" \R.                  5      \" S5      :  r\(       a  SSKJr  SqS\S'   / qS\S'   \qSqS\S'   Sq S\S'   1 Sk1 SkS.r!Sr"S6S7S jjr#S8S9S jjr$S r%S:S jr&S r'0 \RP                  S_\RR                  S_\RT                  S_\RV                  S_\RX                  S_\RZ                  S_\R\                  S _\R^                  S _\R`                  S_\Rb                  S_\Rd                  S_\Rf                  S_\Rh                  S!_\Rj                  S!_\Rl                  S"_\R,                  S#_\Rn                  S$_\Rp                  S%\Rr                  S&\Rt                  S'\Rv                  S(\Rx                  S(\Rz                  S)\R|                  S)\R~                  S*\R                  S*\AS\R                  S0ErCS+ rDS, rE\#" \
" S-5      5        S. rFS)S(S*S/.rGS:S0 jrHS6S;S1 jjrIS6S;S2 jjrJS6S7S3 jjrKS<S4 jrLS=S5 jrMg)>zL
Expressions
-----------

Offer fast expression evaluation through numexpr

    )annotationsN)TYPE_CHECKING)
get_option)np_version_gt2_3)find_stack_level)	roperator)NUMEXPR_INSTALLED)Versionz2.11.0)FuncTypezbool | None
_TEST_MODE
list[bool]_TEST_RESULTzFuncType | None	_evaluate_where>   boolint32int64float32float64>   r   r   r   )evaluatewherei@B c                    [         (       a  [        (       a  [        (       d  SqOU q[        (       a  [        O[
        q[        (       a  [        q	g [        q	g )NF)
r	   r   	ne_gt_211USE_NUMEXPR_evaluate_numexpr_evaluate_standardr   _where_numexpr_where_standardr   vs    [/mnt/data/Frawley/.venv/lib/python3.13/site-packages/pandas/core/computation/expressions.pyset_use_numexprr"   2   s<     II  KK
 &1[!6HI*{^FF    c                    [         (       a;  [        (       a/  U c  [        R                  " 5       n [        R                  " U 5        g g g N)r	   r   nedetect_number_of_coresset_num_threads)ns    r!   set_numexpr_threadsr*   D   s7     [[9))+A
1 )r#   c                >    [         (       a  [        S5        U " X#5      $ )z
Standard evaluation.
F)r   _store_test_result)opop_strleft_opright_ops       r!   r   r   M   s     z5!g  r#   c                    Ubr  UR                   [        :  a^  [        5       nX#4 H/  n[        US5      (       d  M  XVR                  R
                  1-  nM1     [        U5      (       a  [        U   U:  a  gg)z2return left_op boolean if we WILL be using numexprdtypeTF)size_MIN_ELEMENTSsethasattrr2   namelen_ALLOWED_DTYPES)r-   r.   r/   r0   dtype_checkdtypesos          r!   _can_use_numexprr=   V   sd    <<-'"uF(1g&&ww||n,F ) v;;/+">&"Hr#   c                   S n[        XX#S5      (       a]  U R                  R                  S5      R                  S5      nU(       a  X2p2UnUn [        R
                  " SU S3XgS.SS9nU(       a  X2p2[        (       a  [        US L5        Uc  [        XX#5      nU$ ! [         a     N>[         a    [        XU5      (       a   NZe f = f)	Nr   _rzleft_value z right_value)
left_valueright_valuesafe
local_dictcasting)r=   __name__strip
startswithr&   r   	TypeErrorNotImplementedError_bool_arith_fallbackr   r,   r   )r-   r.   r/   r0   resultis_reversedrA   rB   s           r!   r   r   i   s    FGzBBkk'',77< (X
	[[fX\2*4QF  (Xz6-.~#BBM)  	 " 	#FX>>		s   B 
C'CC+*-/z**z==z!=z<=<z>=>&|^c                0    [         R                  " XU5      $ r%   )npr   )condr/   r0   s      r!   r   r      s    88D8,,r#   c                    S n[        S SXS5      (       a  [        R                  " SXUS.SS9nUc  [        XU5      nU$ )Nr   z#where(cond_value, a_value, b_value))
cond_valuea_valueb_valuerC   rD   )r=   r&   r   r   )rZ   r/   r0   rM   s       r!   r   r      sL    Fgw'BB1&*8T
 ~ 9Mr#   zcompute.use_numexprc                     U R                   [        :H  $ ! [         a#    [        U [        [        R
                  45      s $ f = fr%   )r2   r   AttributeError
isinstancerY   bool_)xs    r!   _has_bool_dtyperd      s:    /ww$ /!dBHH-../s    *AA)rO   rP   rQ   c                    [        U5      (       aH  [        U5      (       a8  U [        ;   a.  [        R                  " SU < S[        U    < S3[	        5       S9  gg)z
Check if we should fallback to the python `_evaluate_standard` in case
of an unsupported operation by numexpr, which is the case for some
boolean ops.
z'evaluating in Python space because the z> operator is not supported by numexpr for the bool dtype, use z	 instead.)
stacklevelTF)rd   _BOOL_OP_UNSUPPORTEDwarningswarnr   )r.   r/   r0   s      r!   rL   rL      s^     wOH$=$=))MM9& D+F36iA ,-	 r#   c                X    [         U    nUb  U(       a  [        XX5      $ [        XX5      $ )z
Evaluate and return the expression of the op on left_op and right_op.

Parameters
----------
op : the actual operand
left_op : left operand
right_op : right operand
use_numexpr : bool, default True
    Whether to try to use numexpr.
)_op_str_mappingr   r   )r-   r/   r0   use_numexprr.   s        r!   r   r      s1     R FR;;b'<<r#   c                R    [         c   eU(       a  [        XU5      $ [        XU5      $ )z
Evaluate the where condition cond on left_op and right_op.

Parameters
----------
cond : np.ndarray[bool]
left_op : return if cond is True
right_op : return if cond is False
use_numexpr : bool, default True
    Whether to try to use numexpr.
)r   r   )rZ   r/   r0   rl   s       r!   r   r      s-     dX..th77r#   c                    U q / qg)z
Keeps track of whether numexpr was used.

Stores an additional ``True`` for every successful use of evaluate with
numexpr since the last ``get_test_result``.
N)r   r   r   s    r!   set_test_modero     s     JLr#   c                >    U (       a  [         R                  U 5        g g r%   )r   append)used_numexprs    r!   r,   r,     s    L) r#   c                     [         n / q U $ )z)
Get test result and reset test_results.
)r   )ress    r!   get_test_resultru   $  s    
 CLJr#   )T)r    r   returnNoner%   )rv   rw   )rv   r   )rl   r   )rr   r   rv   rw   )rv   r   )N__doc__
__future__r   operatortypingr   rh   numpyrY   pandas._configr   pandas.compat.numpyr   pandas.util._exceptionsr   pandas.corer   pandas.core.computation.checkr	   pandas.util.versionr
   numexprr&   __version__r   pandas._typingr   r   __annotations__r   r   r   r   r9   r4   r"   r*   r   r=   r   addraddmulrmulsubrsubtruedivrtruedivfloordiv	rfloordivmodrmodpowrpoweqleltgegtand_rand_or_ror_xorrxordivmodrdivmodrk   r   r   rd   rg   rL   r   r   ro   r,   ru    r#   r!   <module>r      s   #      % 0 4 ! ; ''78+<<I'
K j !	? !  A) @$!&&R!LL#!NNC! LL#! NNC	!
 LL#! NNC! c! ! t! ! LL$!  NND!!" LL$#!$ NND%!& KK'!( KK)!* KK+!, KKKKKKMM3OOSLL#NNCLL#NNC
DtA!H-
$ 
01 2/ !s5 $=(8&	*
r#   