Ë
    *�£j;  ã                  óð   — d Z ddlmZ ddlZddlZddlmZmZ ddlZ	ddl
mZ ddlmZmZ erddlmZ ddlmZ dd	„Zej(                  	 	 	 	 	 	 	 	 	 	 dd
„«       Zej(                  	 	 	 	 	 	 	 	 	 	 dd„«       Zy)z6Common utilities for Numba operations with groupby opsé    )ÚannotationsN)ÚTYPE_CHECKINGÚAny)Úimport_optional_dependency)ÚNumbaUtilErrorÚjit_user_function)ÚCallable)ÚScalarc                ó"  — t        | «      st        d«      ‚t        t        j                  | «      j
                  j                  «       «      }ddg}t        |«      }t        |«      |k  s|d| |k7  rt        d|› d| j                  › d|› �«      ‚y)a^  
    Validate user defined function for ops when using Numba with groupby ops.

    The first signature arguments should include:

    def f(values, index, ...):
        ...

    Parameters
    ----------
    func : function, default False
        user defined function

    Returns
    -------
    None

    Raises
    ------
    NumbaUtilError
    z5Numba engine can only be used with a single function.ÚvaluesÚindexNz
The first z arguments to z	 must be )
ÚcallableÚNotImplementedErrorÚlistÚinspectÚ	signatureÚ
parametersÚkeysÚlenr   Ú__name__)ÚfuncÚudf_signatureÚexpected_argsÚmin_number_argss       ú<C:\FundamentalWorkbench\vendor\pandas\core\groupby\numba_.pyÚvalidate_udfr      s¢   € ô, �DŒ>Ü!ØCó
ð 	
ô œ×*Ñ*¨4Ó0×;Ñ;×@Ñ@ÓBÓC€MØ˜wÐ'€MÜ˜-Ó(€OäˆMÓ˜_Ò,ØÐ)˜/Ð*¨mÒ;äØ˜Ð)¨¸¿¹°ÀiØˆoðó
ð 	
ð <ó    c                ó¤   ‡‡— t        | «      Št        rddlŠnt        d«      Š‰j	                  |||¬«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆˆfd„«       }|S )aŽ  
    Generate a numba jitted agg function specified by values from engine_kwargs.

    1. jit the user's function
    2. Return a groupby agg function with the jitted function inline

    Configurations specified in engine_kwargs apply to both the user's
    function _AND_ the groupby evaluation loop.

    Parameters
    ----------
    func : function
        function to be applied to each group and will be JITed
    nopython : bool
        nopython to be passed into numba.jit
    nogil : bool
        nogil to be passed into numba.jit
    parallel : bool
        parallel to be passed into numba.jit

    Returns
    -------
    Numba function
    r   NÚnumba©ÚnopythonÚnogilÚparallelc                ó(  •— t        |«      t        |«      k(  sJ ‚t        |«      }t        j                  ||f«      }‰j                  |«      D ]A  }|||   ||    }	‰j                  |«      D ]   }
| ||   ||   …|
f   } ‰||	g|¢­Ž |||
f<   Œ" ŒC |S ©N©r   ÚnpÚemptyÚprange©r   r   ÚbeginÚendÚnum_columnsÚargsÚ
num_groupsÚresultÚiÚgroup_indexÚjÚgroupr   Ú
numba_funcs               €€r   Ú	group_aggz*generate_numba_agg_func.<locals>.group_aggg   s­   ø€ ô �5‹zœS ›XÒ%Ð%Ð%Ü˜“Zˆ
ä—‘˜: {Ð3Ó4ˆØ—‘˜jÖ)ˆAØ  a¡¨3¨q©6Ð2ˆKØ—\‘\ +Ö.�Ø˜u Q™x¨#¨a©&Ð0°!Ð3Ñ4�Ù)¨%°ÐD¸tÒD��q˜!�t’ñ /ð *ð
 ˆr   ©r   ú
np.ndarrayr   r8   r+   r8   r,   r8   r-   Úintr.   r   Úreturnr8   ©r   r   r   r   Újit)r   r!   r"   r#   r6   r   r5   s        @@r   Úgenerate_numba_agg_funcr=   B   s‹   ù€ ô> # 4Ó(€JÝÜä*¨7Ó3ˆà
‡Y�Y˜¨¸€YÓAðØðàðð ðð ð	ð
 ðð ðð 
õó Bðð& Ðr   c                ó¤   ‡‡— t        | «      Št        rddlŠnt        d«      Š‰j	                  |||¬«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆˆfd„«       }|S )a›  
    Generate a numba jitted transform function specified by values from engine_kwargs.

    1. jit the user's function
    2. Return a groupby transform function with the jitted function inline

    Configurations specified in engine_kwargs apply to both the user's
    function _AND_ the groupby evaluation loop.

    Parameters
    ----------
    func : function
        function to be applied to each window and will be JITed
    nopython : bool
        nopython to be passed into numba.jit
    nogil : bool
        nogil to be passed into numba.jit
    parallel : bool
        parallel to be passed into numba.jit

    Returns
    -------
    Numba function
    r   Nr   r    c                óJ  •— t        |«      t        |«      k(  sJ ‚t        |«      }t        j                  t        | «      |f«      }‰j                  |«      D ]I  }|||   ||    }	‰j                  |«      D ](  }
| ||   ||   …|
f   } ‰||	g|¢­Ž |||   ||   …|
f<   Œ* ŒK |S r%   r&   r*   s               €€r   Úgroup_transformz6generate_numba_transform_func.<locals>.group_transform£   sÀ   ø€ ô �5‹zœS ›XÒ%Ð%Ð%Ü˜“Zˆ
ä—‘œ3˜v›;¨Ð4Ó5ˆØ—‘˜jÖ)ˆAØ  a¡¨3¨q©6Ð2ˆKØ—\‘\ +Ö.�Ø˜u Q™x¨#¨a©&Ð0°!Ð3Ñ4�Ù/9¸%ÀÐ/TÈtÒ/T��u˜Q‘x # a¡&Ð(¨!Ð+Ò,ñ /ð *ð
 ˆr   r7   r;   )r   r!   r"   r#   r@   r   r5   s        @@r   Úgenerate_numba_transform_funcrA   ~   s‹   ù€ ô> # 4Ó(€JÝÜä*¨7Ó3ˆà
‡Y�Y˜¨¸€YÓAðØðàðð ðð ð	ð
 ðð ðð 
õó Bðð& Ðr   )r   r	   r:   ÚNone)
r   zCallable[..., Scalar]r!   Úboolr"   rC   r#   rC   r:   úPCallable[[np.ndarray, np.ndarray, np.ndarray, np.ndarray, int, Any], np.ndarray])
r   zCallable[..., np.ndarray]r!   rC   r"   rC   r#   rC   r:   rD   )Ú__doc__Ú
__future__r   Ú	functoolsr   Útypingr   r   Únumpyr'   Úpandas.compat._optionalr   Úpandas.core.util.numba_r   r   Úcollections.abcr	   Úpandas._typingr
   r   Úcacher=   rA   © r   r   Ú<module>rP      sÃ   ðÙ <å "ã Û ÷ó
 å >÷ñ
 Ý(å%ó$
ðN ‡�ð8Ø
ð8àð8ð ð8ð ð	8ð
 Vò8ó ð8ðv ‡�ð8Ø
#ð8àð8ð ð8ð ð	8ð
 Vò8ó ñ8r   