
    'h^                       S SK Jr  S SKrS SKrS SKJr  S SKJrJrJ	r	J
r
  S SKJr  S SKJr  S SKJr  S SKJr  \(       aF  S SKJr  S S	KJr  S S
KJr  \R4                  S:  a  S SKJr  OS SKJr  \
" S5      r\" S5      r\	S\4   rSS jr SS jr!SS jr"SS jr#SS jr$ " S S5      r%\%" 5       r&        SS jr'SS jr(g)     )annotationsN)wraps)TYPE_CHECKINGAnyCallableTypeVar)	functions)wrap_s)dtype_to_ffiname)Series)PySeries)PolarsDataType)   
   )	ParamSpecTP.c                   [        U SS5      n[        U5      n[        U 5       H  nUR                  S5      (       a  M  US:w  d  M#  [        X5      n[	        U5      (       d  M@  [        U5      nUR                  R                  SUR                  R                   nXU4U;   d  M  [        U5      (       d  M  [        X[        U5      5        M     U $ )ai  
Series/NameSpace class decorator that sets up expression dispatch.

* Applied to the Series class, and/or any Series 'NameSpace' classes.
* Walks the class attributes, looking for methods that have empty function
  bodies, with signatures compatible with an existing Expr function.
* IFF both conditions are met, the empty method is decorated with @call_expr.
	_accessorN_plot)getattr_expr_lookupdir
startswithcallable_undecorated__code__co_varnamesco_argcount_is_empty_methodsetattr	call_expr)cls	namespaceexpr_lookupnameattrargss         fC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\polars/series/utils.pyexpr_dispatchr+      s     [$/Iy)KC $$ 3%D~~#D) }}001L4==3L3LM T*k9>Nt>T>TCy7% & J    c                   [         R                  " 5       nSUl        U b  [        X5      n[	        5       n[        U5       H  nUR                  S5      (       a  M   [        X5      n[        U5      (       d  M9  [        U5      nUR                  R                  SUR                  R                   nUR                  XU45        M     U$ ! [         a     M  f = f)zACreate lookup of potential Expr methods (in the given namespace).Nr   )plExpr_pyexprr   setr   r   AttributeErrorr   r   r   r   r    add)r%   exprlookupr'   mr)   s         r*   r   r   ?   s     779DDL t'UFD	s##D' {{ !Ozz--.F

0F0FG

IT23  M " s   C


CCc                f    [        U S5      (       a  U R                  n [        U S5      (       a  M  U $ )z1Return the given function without any decorators.__wrapped__)hasattrr8   )functions    r*   r   r   Y   s.    
(M
*
*'' (M
*
*Or,   c                v   ^  [        T 5      SU 4S jj5       n[        US[        R                  " T 5      5        U$ )z7Dispatch Series method to an expression implementation.c                6  > [        U R                  5      n[        R                  " UR                  5      n[        U SS 5      =nb  [        XE5      n[        UTR                  5      nUR                  5       R                  U" U0 UD65      R                  5       $ )Nr   )
r
   _sFcolr'   r   __name__to_frame
select_seq	to_series)selfr)   kwargssr4   r%   ffuncs          r*   wrappercall_expr.<locals>.wrapperc   sy    477OuuQVV} {D99IF4+DD$--(zz|&&q$'9&'9:DDFFr,   __signature__)rD   r   r)   zP.argsrE   zP.kwargsreturnr   )r   r"   inspect	signature)rH   rI   s   ` r*   r#   r#   `   s;     4[G G G_g&7&7&=>Nr,   c                "   U R                   nUR                  [        ;   =(       aj    [        UR                  5      S:H  =(       a    UR                  S   SL =(       d3    [
        R                  R                  S:H  =(       a    UR                  S:H  $ )z
Confirm that the given function has no implementation.

Definitions of empty:

- only has a docstring (body is empty)
- has no docstring and just contains 'pass' (or equivalent)
      NN)r   co_code_EMPTY_BYTECODElen	co_constssysflagsoptimize)rH   fcs     r*   r!   r!   r   sl     
BJJ/) 	R\\	a		;BLLOt$; 	AII!#?(?r,   c                  (    \ rS rSrSS jrSS jrSrg)_EmptyBytecodeHelper   c                z    SS jnSS jnUR                   R                  UR                   R                  4U l        g )Nc                     g) N ra   r,   r*   _empty_with_docstring<_EmptyBytecodeHelper.__init__.<locals>._empty_with_docstring   s    r,   c                     g rR   ra   ra   r,   r*   _empty_without_docstring?_EmptyBytecodeHelper.__init__.<locals>._empty_without_docstring   s    r,   rL   None)r   rS   empty_bytecode)rD   rb   re   s      r*   __init___EmptyBytecodeHelper.__init__   s6    		 "**22$--55
r,   c                    XR                   ;   $ rR   ri   )rD   items     r*   __contains__!_EmptyBytecodeHelper.__contains__   s    ****r,   rm   Nrg   )rn   bytesrL   bool)r@   
__module____qualname____firstlineno__rj   ro   __static_attributes__ra   r,   r*   r\   r\      s    
+r,   r\   c                T    [        U5      nU R                  SU5      n[        X$S5      $ )a:  
Dynamically obtain the proper FFI function/ method.

Parameters
----------
name
    function or method name where dtype is replaced by <>
    for example
        "call_foo_<>"
dtype
    polars dtype.
obj
    Object to find the method for.

Returns
-------
callable or None
    FFI function, or None if not found.
z<>N)r   replacer   )r'   dtypeobjffi_namefnames        r*   get_ffi_funcr}      s+    ,  &HLLx(E3t$$r,   c                p    SSK Jn   U" S5        U " 5       nU" S5        U$ ! [         a
    U" S5        e f = f)Nr   )check_lengthFT)polars._plrr   	Exception)rH   r   results      r*   _with_no_check_lengthr      sD    (UT
 	  Ts   ! 5)r$   type[T]rL   r   )r%   z
str | NonerL   z,set[tuple[str | None, str, tuple[str, ...]]])r:   Callable[P, T]rL   r   )rH   SeriesMethodrL   r   )rH   r   rL   rr   )r'   strry   r   rz   r   rL   zCallable[..., Any] | None)rH   zCallable[..., Any]rL   r   ))
__future__r   rM   rW   	functoolsr   typingr   r   r   r   polars._reexport	_reexportr.   polarsr	   r>   polars._utils.wrapr
   polars.datatypesr   r   r   r   polars._typingr   version_infor   typing_extensionsr   r   r   r+   r   r   r#   r!   r\   rT   r}   r   ra   r,   r*   <module>r      s    "  
  8 8  ! % -$-
7"$/A#ACK(L F4$"+ +$ '(%
%$%+3%%6r,   