
    `Vg                       U d Z ddlmZ ddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ erddlZdad	ed
<   g aded<   eadaded<   daded<   h dh ddZdZd2d3dZd4d3dZd Zd Zd Zi ej@                  dejB                  dejD                  dejF                  dejH                  dejJ                  dejL                  dejN                  dejP                  dejR                  dejT                  dejV                  dejX                  dejZ                  dej\                  dej$                  dej^                  d ej`                  d!ejb                  d"ejd                  d#ejf                  d$ejh                  d$ejj                  d%ejl                  d%ejn                  d&ejp                  d&e9dejt                  diZ;d' Z<d( Z= e ed)             d* Z>d%d$d&d+Z?d, Z@d2d5d-ZAd2d.ZBd2d6d/ZCd7d0ZDd8d1ZEy)9zL
Expressions
-----------

Offer fast expression evaluation through numexpr

    )annotationsN)
get_option)FuncType)find_stack_level)NUMEXPR_INSTALLED)	roperatorzbool | None
_TEST_MODE
list[bool]_TEST_RESULTzFuncType | None	_evaluate_where>   boolint32int64float32float64>   r   r   r   )evaluatewherei@B c                ^    t         r| at        rt        nt        at        rt
        ay t        ay N)r   USE_NUMEXPR_evaluate_numexpr_evaluate_standardr   _where_numexpr_where_standardr   vs    d/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/pandas/core/computation/expressions.pyset_use_numexprr   *   s$     
 &1!6HI*^FF    c                v    t         r3t        r,| t        j                         } t        j                  |        y y y r   )r   r   nedetect_number_of_coresset_num_threads)ns    r   set_numexpr_threadsr&   7   s2     [9))+A
1 )r    c                6    t         rt        d        | ||      S )z
    Standard evaluation.
    F)r	   _store_test_result)opop_strabs       r   r   r   @   s     5!a8Or    c                    |e|j                   t        kD  rRt               }||fD ])  }t        |d      s||j                  j
                  hz  }+ t        |      rt        |   |k\  ryy)z,return a boolean if we WILL be using numexprdtypeTF)size_MIN_ELEMENTSsethasattrr.   namelen_ALLOWED_DTYPES)r)   r*   r+   r,   dtype_checkdtypesos          r   _can_use_numexprr9   I   si     66M!"uFV -1g&qww||n,F- v;/+">&"Hr    c                r   d }t        | |||d      rZ| j                  j                  d      j                  d      }|r||}}|}|}	 t	        j
                  d| d||dd      }|r||}}t        rt        |d u       |t        | |||      }|S # t        $ r Y 6t        $ r t        |||      rn Y Ow xY w)	Nr   _rza_value z b_value)a_valueb_valuesafe
local_dictcasting)r9   __name__strip
startswithr"   r   	TypeErrorNotImplementedError_bool_arith_fallbackr	   r(   r   )r)   r*   r+   r,   resultis_reversedr=   r>   s           r   r   r   ]   s    FFAq*5kk'',77<aqA	[[6((+'.7CF aqA6-.~#B15M)  	 " 	#FAq1 	s   B 	B6B65B6+*-/z**z==z!=z<=<z>=>&|^c                0    t        j                  | ||      S r   )npr   )condr+   r,   s      r   r   r      s    88D!Qr    c                ~    d }t        d d||d      rt        j                  d| ||dd      }|t        | ||      }|S )Nr   z#where(cond_value, a_value, b_value))
cond_valuer=   r>   r?   r@   )r9   r"   r   r   )rV   r+   r,   rI   s       r   r   r      sO    Fgq!W51&*qQG
 ~ q!,Mr    zcompute.use_numexprc                    	 | j                   t        k(  S # t        $ r# t        | t        t        j
                  f      cY S w xY wr   )r.   r   AttributeError
isinstancerU   bool_)xs    r   _has_bool_dtyper^      s:    /ww$ /!dBHH-../s    )A A)rK   rL   rM   c           	         t        |      rSt        |      rH| t        v r@t        j                  dt	        |        dt	        t        |           dt                      yy)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)r^   _BOOL_OP_UNSUPPORTEDwarningswarnreprr   )r*   r+   r,   s      r   rH   rH      sb     qoa0))MM9$v, H089:)E ,-	 r    c                T    t         |    }||rt        | |||      S t        | |||      S )z
    Evaluate and return the expression of the op on a and b.

    Parameters
    ----------
    op : the actual operand
    a : left operand
    b : right operand
    use_numexpr : bool, default True
        Whether to try to use numexpr.
    )_op_str_mappingr   r   )r)   r+   r,   use_numexprr*   s        r   r   r      s9     R FRA..b&!Q//r    c                J    t         J |rt        | ||      S t        | ||      S )z
    Evaluate the where condition cond on a and b.

    Parameters
    ----------
    cond : np.ndarray[bool]
    a : return if cond is True
    b : return if cond is False
    use_numexpr : bool, default True
        Whether to try to use numexpr.
    )r   r   )rV   r+   r,   rg   s       r   r   r      s/     !,6$1M/$12MMr    c                    | a g ay)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_moderj     s     JLr    c                4    | rt         j                  |        y y r   )r   append)used_numexprs    r   r(   r(     s    L) r    c                     t         } g a | S )z1
    Get test result and reset test_results.
    )r   )ress    r   get_test_resultrp     s    
 CLJr    )T)returnNoner   )rg   r   )r   r   rq   rr   )rm   r   rq   rr   )rq   r
   )F__doc__
__future__r   operatorrb   numpyrU   pandas._configr   pandas._typingr   pandas.util._exceptionsr   pandas.core.computation.checkr   pandas.core.opsr   numexprr"   r	   __annotations__r   r   r   r   r5   r0   r   r&   r   r9   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rdivmodrf   r   r   r^   ra   rH   r   r   rj   r(   rp    r    r   <module>r      s^   #    % # 4 ; %
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 $0(N 	*r    