
    'h@              	         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	J
r
  S SKJr  S SKJr  \R                  " \5         S SKJr  SSS5        \	(       a  S SKJr  S S	KJr  S S
KJr  S/rSSSSSSSSS.                       SS jjrSS jr\" SS9SS.SS jj5       rSS jrSS.SS jjrg! , (       d  f       Nw= f)    )annotationsN)	lru_cache)Path)TYPE_CHECKINGAny)parse_into_list_of_expressions)	wrap_expr)Iterable)Expr)IntoExprregister_plugin_functionF)kwargsis_elementwisechanges_lengthreturns_scalarcast_to_supertypeinput_wildcard_expansionpass_name_to_applyuse_abs_pathc                    [        U5      n[        U5      n[        X
S9n [        [        R
                  " [        U 5      UUUUUUUU	US9
5      $ )a  
Register a plugin function.

See the `user guide <https://docs.pola.rs/user-guide/plugins/expr_plugins>`_
for more information about plugins.

Parameters
----------
plugin_path
    Path to the plugin package. Accepts either the file path to the dynamic library
    file or the path to the directory containing it.
function_name
    The name of the Rust function to register.
args
    The arguments passed to this function. These get passed to the `input`
    argument on the Rust side, and have to be expressions (or be convertible
    to expressions).
kwargs
    Non-expression arguments to the plugin function. These must be
    JSON serializable.
is_elementwise
    Indicate that the function operates on scalars only. This will potentially
    trigger fast paths.
changes_length
    Indicate that the function will change the length of the expression.
    For example, a `unique` or `slice` operation.
returns_scalar
    Automatically explode on unit length if the function ran as final aggregation.
    This is the case for aggregations like `sum`, `min`, `covariance` etc.
cast_to_supertype
    Cast the input expressions to their supertype.
input_wildcard_expansion
    Expand wildcard expressions before executing the function.
pass_name_to_apply
    If set to `True`, the `Series` passed to the function in a group-by operation
    will ensure the name is set. This is an extra heap allocation per group.
use_abs_path
    If set to `True`, the path will be resolved to an absolute path.
    The path to the dynamic library is relative to the virtual environment by
    default.

Returns
-------
Expr

Warnings
--------
This is highly unsafe as this will call the C function loaded by
`plugin::function_name`.

The parameters you set dictate how Polars will handle the function.
Make sure they are correct!
r   )
plugin_pathfunction_nameargsr   r   r   r   r   r   r   )r   _serialize_kwargs_resolve_plugin_pathr	   plrr   str)r   r   r   r   r   r   r   r   r   r   r   pyexprsserialized_kwargss                aC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\polars/plugins.pyr   r      sb    F -T2G)&1&{NK$$K('$)%=)/1)	
     c                :    U (       d  gSSK nUR                  U SS9$ )z+Serialize the function's keyword arguments.r"   r   N   )protocol)pickledumps)r   r&   s     r!   r   r   o   s      <<<++r"      )maxsizer   c                  [        U [        5      (       d  [        U 5      n U R                  5       (       a	  [        XS9$ U R	                  5        H  n[        U5      (       d  M  [        X!S9s  $    SU  3n[        U5      e)z.Get the file path of the dynamic library file.r   z"no dynamic library found at path: )
isinstancer   is_file_resolve_file_pathiterdir_is_dynamic_libFileNotFoundError)pathr   pmsgs       r!   r   r   {   so     dD!!Dz||~~!$BB\\^1%aCC  /tf
5C
C
  r"   c                N    U R                  5       =(       a    U R                  S;   $ )N)z.soz.dllz.pyd)r,   suffix)r1   s    r!   r/   r/      s    <<>Ddkk-DDDr"   c                   [        [        R                  5      nU(       a  U R                  5       $  U R	                  U5      nU$ ! [
         a    U R                  5       n U$ f = f)N)r   sysprefixresolverelative_to
ValueError)r1   r   	venv_path	file_paths       r!   r-   r-      s^    SZZ I||~	'((3I   	'I	's   A A#"A#)r   
Path | strr   r   r   zIntoExpr | Iterable[IntoExpr]r   dict[str, Any] | Noner   boolr   r@   r   r@   r   r@   r   r@   r   r@   r   r@   returnr   )r   r?   rA   bytes)r1   r>   r   r@   rA   r   )r1   r   rA   r@   )r1   r   r   r@   rA   r   ) 
__future__r   
contextlibr7   	functoolsr   pathlibr   typingr   r   polars._utils.parser   polars._utils.wrapr	   suppressImportErrorpolars._plr_plrr   collections.abcr
   polarsr   polars._typingr   __all__r   r   r   r/   r-    r"   r!   <module>rS      s-   "  
   % > (% & ('%
& %)   #%*$TT T (	T
 "T T T T T #T T T 
Tn	, 2CH ! ! E <A  I &%s   B99
C