o
    Ôôj�Z  ã                   @   s@  d dl mZmZmZmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZH d dlImJZJ d dlKZKd dlLmMZM d dlNZNd dlOZPd dlOmQZQ d dlRmSZS dd„ ZTeJd	d
ƒZUdd„ ZVdd„ ZWdd„ ZXdd„ ZYdd„ ZZdd„ Z[dd„ Z\dd„ Z]e]ƒ  d2dd„Z^d3ddœdd„Z_d dd!œd"d#„Z`d$d%„ Zad4ddœd&d'„Zbd4ddœd(d)„Zcd*ddd+œd,d-„Zdd.d/„ Zed0d1„ ZfdS )5é    )HÚFunctionÚFunctionOptionsÚFunctionRegistryÚHashAggregateFunctionÚHashAggregateKernelÚKernelÚScalarAggregateFunctionÚScalarAggregateKernelÚScalarFunctionÚScalarKernelÚVectorFunctionÚVectorKernelÚArraySortOptionsÚAssumeTimezoneOptionsÚCastOptionsÚCountOptionsÚCumulativeOptionsÚCumulativeSumOptionsÚDayOfWeekOptionsÚDictionaryEncodeOptionsÚRunEndEncodeOptionsÚElementWiseAggregateOptionsÚExtractRegexOptionsÚFilterOptionsÚIndexOptionsÚJoinOptionsÚListSliceOptionsÚListFlattenOptionsÚMakeStructOptionsÚMapLookupOptionsÚMatchSubstringOptionsÚModeOptionsÚNullOptionsÚ
PadOptionsÚPairwiseOptionsÚPartitionNthOptionsÚQuantileOptionsÚRandomOptionsÚRankOptionsÚReplaceSliceOptionsÚReplaceSubstringOptionsÚRoundBinaryOptionsÚRoundOptionsÚRoundTemporalOptionsÚRoundToMultipleOptionsÚScalarAggregateOptionsÚSelectKOptionsÚSetLookupOptionsÚSliceOptionsÚSortOptionsÚSplitOptionsÚSplitPatternOptionsÚStrftimeOptionsÚStrptimeOptionsÚStructFieldOptionsÚTakeOptionsÚTDigestOptionsÚTrimOptionsÚUtf8NormalizeOptionsÚVarianceOptionsÚWeekOptionsÚcall_functionÚfunction_registryÚget_functionÚlist_functionsÚcall_tabular_functionÚregister_scalar_functionÚregister_tabular_functionÚregister_aggregate_functionÚregister_vector_functionÚ
UdfContextÚ
Expression)Ú
namedtupleN)Údedent)Ú_compute_docstrings)Ú	docscrapec                 C   s   | j jS ©N)Ú_docÚ	arg_names)Úfunc© rR   úb/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/pyarrow/compute.pyÚ_get_arg_namesk   s   rT   Ú_OptionsClassDoc)Úparamsc                 C   s"   | j sd S t | j ¡}t|d ƒS )NÚ
Parameters)Ú__doc__rM   ÚNumpyDocStringrU   )Úoptions_classÚdocrR   rR   rS   Ú_scrape_options_class_docr   s   r\   c                 C   sâ  |j }t|j|j|j|jd�| _|| _|| _g }|j	}|s-|jdkr$dnd}d 
|j|¡}| |› d�¡ |j}|rB| |› d�¡ tj |j¡}	| tdƒ¡ t|ƒ}
|
D ]}|jd	v r`d
}nd}| |› d|› d�¡ | d¡ qV|d urÑt|ƒ}|r |jD ]}| |j› d|j› d�¡ |jD ]}| d|› d�¡ q’q€n%t d|j› d�t¡ t |¡}|j ¡ D ]}| td 
|j|j¡ƒ¡ qµ| td|j› d�ƒ¡ | tdƒ¡ |	d uré| d 
t|	ƒ d¡¡¡ d |¡| _ | S )N)ÚnameÚarityrZ   Úoptions_requiredé   Ú	argumentsÚargumentz,Call compute function {!r} with the given {}z.

z

z.        Parameters
        ----------
        )ÚvectorÚscalar_aggregatez
Array-likezArray-like or scalar-likez : Ú
z"    Argument to compute function.
z    zOptions class z does not have a docstringz¾                {0} : optional
                    Parameter for {1} constructor. Either `options`
                    or `{0}` can be passed, but not both at the same time.
                z&            options : pyarrow.compute.zK, optional
                Alternative way of passing options.
            z‰        memory_pool : pyarrow.MemoryPool, optional
            If not passed, will allocate memory from the default memory pool.
        z
{}
Ú )!rO   Údictr]   r^   rZ   r_   Z__arrow_compute_function__Ú__name__Ú__qualname__ÚsummaryÚformatÚappendÚdescriptionrL   Zfunction_doc_additionsÚgetrK   rT   Úkindr\   rV   ÚtypeÚdescÚwarningsÚwarnÚRuntimeWarningÚinspectÚ	signatureÚ
parametersÚvaluesÚstripÚjoinrX   )ÚwrapperZexposed_namerQ   rZ   Zcpp_docZ
doc_piecesrj   Úarg_strrm   Zdoc_additionrP   Úarg_nameÚarg_typeZoptions_class_docÚpÚsÚoptions_sigrR   rR   rS   Ú_decorate_compute_functiony   sl   ü
ÿ


ÿþÿ
üÿr‚   c                 C   sD   | j j}|sd S ztƒ | W S  ty!   t d |¡t¡ Y d S w )Nz!Python binding for {} not exposed)rO   rZ   ÚglobalsÚKeyErrorrr   rs   rk   rt   )rQ   Ú
class_namerR   rR   rS   Ú_get_options_classÌ   s   ÿýr†   c                 C   st   |s|r|d urt d | ¡ƒ‚||i |¤ŽS |d ur8t|tƒr&|di |¤ŽS t||ƒr-|S t d | |t|ƒ¡ƒ‚d S )NzMFunction {!r} called with both an 'options' argument and additional argumentsz-Function {!r} expected a {} parameter, got {}rR   )Ú	TypeErrorrk   Ú
isinstancerg   rp   )r]   rZ   ÚoptionsÚargsÚkwargsrR   rR   rS   Ú_handle_optionsØ   s"   ý

þrŒ   c                    s@   ˆd u rd dœ‡ ‡‡fdd„
}|S d d dœ‡ ‡‡‡fdd„
}|S )N©Úmemory_poolc                    sb   ˆ t urt|ƒˆ krtˆ› dˆ › dt|ƒ› d�ƒ‚|r*t|d tƒr*t ˆt|ƒ¡S ˆ |d | ¡S )Nú takes ú positional argument(s), but ú were givenr   )ÚEllipsisÚlenr‡   rˆ   rI   Ú_callÚlistÚcall)rŽ   rŠ   )r^   rQ   Ú	func_namerR   rS   r{   ï   s   ÿÿz&_make_generic_wrapper.<locals>.wrapper)rŽ   r‰   c                    s’   ˆ t ur&t|ƒˆ k rtˆ› dˆ › dt|ƒ› d�ƒ‚|ˆ d … }|d ˆ … }nd}tˆˆ|||ƒ}|rBt|d tƒrBt ˆt|ƒ|¡S ˆ ||| ¡S )Nr�   r�   r‘   rR   r   )	r’   r“   r‡   rŒ   rˆ   rI   r”   r•   r–   )rŽ   r‰   rŠ   r‹   Zoption_args©r^   rQ   r—   rZ   rR   rS   r{   ù   s    ÿÿÿrR   )r—   rQ   rZ   r^   r{   rR   r˜   rS   Ú_make_generic_wrapperí   s
   ðr™   c                 C   sÒ   ddl m} g }| D ]}| |||jƒ¡ q
|D ]}| |||jƒ¡ q|d urYt  |¡}|j ¡ D ]}|j|j	|j
fv s?J ‚|rH|j|j
d�}| |¡ q2| |d|j
d d�¡ | |d|j
d d�¡ t  |¡S )Nr   )Ú	Parameter)ro   r‰   )ÚdefaultrŽ   )ru   rš   rl   ÚPOSITIONAL_ONLYÚVAR_POSITIONALrv   rw   rx   ro   ÚPOSITIONAL_OR_KEYWORDÚKEYWORD_ONLYÚreplaceÚ	Signature)rP   Úvar_arg_namesrZ   rš   rV   r]   r�   r   rR   rR   rS   Ú_make_signature  s,   

ÿÿÿ
r£   c                 C   sj   t |ƒ}t|ƒ}|o|d  d¡}|r| ¡  d¡g}ng }t| |||jd�}t|||ƒ|_t	|| ||ƒS )NéÿÿÿÿÚ*)r^   )
r†   rT   Ú
startswithÚpopÚlstripr™   r^   r£   Ú__signature__r‚   )r]   rQ   rZ   rP   Z
has_varargr¢   r{   rR   rR   rS   Ú_wrap_function#  s   
ÿÿrª   c                  C   s†   t ƒ } tƒ }dddœ}| ¡ D ]1}| ||¡}| |¡}|jdkr"q|jdkr-|jdkr-q|| vs5J |ƒ‚t||ƒ | |< | |< qdS )z«
    Make global functions wrapping each compute function.

    Note that some of the automatically-generated wrappers may be overridden
    by custom versions below.
    Úand_Úor_)ÚandÚorZhash_aggregaterd   r   N)rƒ   r@   rB   rn   rA   ro   r^   rª   )ÚgÚregÚrewritesZcpp_namer]   rQ   rR   rR   rS   Ú_make_global_functions3  s   ÿ

ôr²   c                 C   sh   |dup|du}|r|durt dƒ‚|du r,tjj |¡}|du r't |¡}nt |¡}td| g||ƒS )a†  
    Cast array values to another data type. Can also be invoked as an array
    instance method.

    Parameters
    ----------
    arr : Array-like
    target_type : DataType or str
        Type to cast to
    safe : bool, default True
        Check for overflows or other unsafe conversions
    options : CastOptions, default None
        Additional checks pass by CastOptions
    memory_pool : MemoryPool, optional
        memory pool to use for allocations during function execution.

    Examples
    --------
    >>> from datetime import datetime
    >>> import pyarrow as pa
    >>> arr = pa.array([datetime(2010, 1, 1), datetime(2015, 1, 1)])
    >>> arr.type
    TimestampType(timestamp[us])

    You can use ``pyarrow.DataType`` objects to specify the target type:

    >>> cast(arr, pa.timestamp('ms'))
    <pyarrow.lib.TimestampArray object at ...>
    [
      2010-01-01 00:00:00.000,
      2015-01-01 00:00:00.000
    ]

    >>> cast(arr, pa.timestamp('ms')).type
    TimestampType(timestamp[ms])

    Alternatively, it is also supported to use the string aliases for these
    types:

    >>> arr.cast('timestamp[ms]')
    <pyarrow.lib.TimestampArray object at ...>
    [
      2010-01-01 00:00:00.000,
      2015-01-01 00:00:00.000
    ]
    >>> arr.cast('timestamp[ms]').type
    TimestampType(timestamp[ms])

    Returns
    -------
    casted : Array
        The cast result as a new Array
    NzRMust either pass values for 'target_type' and 'safe' or pass a value for 'options'FÚcast)	Ú
ValueErrorÚpaÚtypesÚlibÚensure_typer   ÚunsafeÚsafer?   )ÚarrÚtarget_typerº   r‰   rŽ   Zsafe_vars_passedrR   rR   rS   r³   S  s   6
r³   r�   c                C   sÌ   |dur|dur|   ||| ¡} n|   |¡} n
|dur!|   d|¡} t|tjƒs0tj|| jd�}n| j|jkr@tj| ¡ | jd�}t|d�}td| g||ƒ}|durd| ¡ dkrdtj| ¡ | t 	¡ d�}|S )a©  
    Find the index of the first occurrence of a given value.

    Parameters
    ----------
    data : Array-like
    value : Scalar-like object
        The value to search for.
    start : int, optional
    end : int, optional
    memory_pool : MemoryPool, optional
        If not passed, will allocate memory from the default memory pool.

    Returns
    -------
    index : int
        the index, or -1 if not found
    Nr   ©rp   ©ÚvalueÚindex)
Úslicerˆ   rµ   ÚScalarÚscalarrp   Úas_pyr   r?   Úint64)Údatar¿   ÚstartÚendrŽ   r‰   ÚresultrR   rR   rS   rÀ   ˜  s   
rÀ   T)ÚboundscheckrŽ   c                C   s   t |d�}td| |g||ƒS )a–  
    Select values (or records) from array- or table-like data given integer
    selection indices.

    The result will be of the same type(s) as the input, with elements taken
    from the input array (or record batch / table fields) at the given
    indices. If an index is null then the corresponding value in the output
    will be null.

    Parameters
    ----------
    data : Array, ChunkedArray, RecordBatch, or Table
    indices : Array, ChunkedArray
        Must be of integer type
    boundscheck : boolean, default True
        Whether to boundscheck the indices. If False and there is an out of
        bounds index, will likely cause the process to crash.
    memory_pool : MemoryPool, optional
        If not passed, will allocate memory from the default memory pool.

    Returns
    -------
    result : depends on inputs
        Selected values for the given indices

    Examples
    --------
    >>> import pyarrow as pa
    >>> arr = pa.array(["a", "b", "c", None, "e", "f"])
    >>> indices = pa.array([0, None, 4, 3])
    >>> arr.take(indices)
    <pyarrow.lib.StringArray object at ...>
    [
      "a",
      null,
      "e",
      null
    ]
    )rÊ   Útake)r9   r?   )rÆ   ÚindicesrÊ   rŽ   r‰   rR   rR   rS   rË   ¾  s   
(rË   c                 C   sV   t |tjtjtjfƒstj|| jd�}n| j|jkr$tj| ¡ | jd�}td| |gƒS )ae  Replace each null element in values with a corresponding
    element from fill_value.

    If fill_value is scalar-like, then every null element in values
    will be replaced with fill_value. If fill_value is array-like,
    then the i-th element in values will be replaced with the i-th
    element in fill_value.

    The fill_value's type must be the same as that of values, or it
    must be able to be implicitly casted to the array's type.

    This is an alias for :func:`coalesce`.

    Parameters
    ----------
    values : Array, ChunkedArray, or Scalar-like object
        Each null element is replaced with the corresponding value
        from fill_value.
    fill_value : Array, ChunkedArray, or Scalar-like object
        If not same type as values, will attempt to cast.

    Returns
    -------
    result : depends on inputs
        Values with all null elements replaced

    Examples
    --------
    >>> import pyarrow as pa
    >>> arr = pa.array([1, 2, None, 3], type=pa.int8())
    >>> fill_value = pa.scalar(5, type=pa.int8())
    >>> arr.fill_null(fill_value)
    <pyarrow.lib.Int8Array object at ...>
    [
      1,
      2,
      5,
      3
    ]
    >>> arr = pa.array([1, 2, None, 4, None])
    >>> arr.fill_null(pa.array([10, 20, 30, 40, 50]))
    <pyarrow.lib.Int64Array object at ...>
    [
      1,
      2,
      30,
      4,
      50
    ]
    r½   Úcoalesce)	rˆ   rµ   ÚArrayÚChunkedArrayrÂ   rÃ   rp   rÄ   r?   )rx   Ú
fill_valuerR   rR   rS   Ú	fill_nullê  s
   3rÑ   c                C   óR   |du rg }t | tjtjfƒr| d¡ ntdd„ |ƒ}t||ƒ}td| g||ƒS )a¸  
    Select the indices of the top-k ordered elements from array- or table-like
    data.

    This is a specialization for :func:`select_k_unstable`. Output is not
    guaranteed to be stable.

    Parameters
    ----------
    values : Array, ChunkedArray, RecordBatch, or Table
        Data to sort and get top indices from.
    k : int
        The number of `k` elements to keep.
    sort_keys : List-like
        Column key names to order by when input is table-like data.
    memory_pool : MemoryPool, optional
        If not passed, will allocate memory from the default memory pool.

    Returns
    -------
    result : Array
        Indices of the top-k ordered elements

    Examples
    --------
    >>> import pyarrow as pa
    >>> import pyarrow.compute as pc
    >>> arr = pa.array(["a", "b", "c", None, "e", "f"])
    >>> pc.top_k_unstable(arr, k=3)
    <pyarrow.lib.UInt64Array object at ...>
    [
      5,
      4,
      2
    ]
    N)ÚdummyÚ
descendingc                 S   ó   | dfS )NrÔ   rR   ©Zkey_namerR   rR   rS   Ú<lambda>O  ó    z top_k_unstable.<locals>.<lambda>Úselect_k_unstable©rˆ   rµ   rÎ   rÏ   rl   Úmapr0   r?   ©rx   ÚkÚ	sort_keysrŽ   r‰   rR   rR   rS   Útop_k_unstable%  ó   %
rß   c                C   rÒ   )aÏ  
    Select the indices of the bottom-k ordered elements from
    array- or table-like data.

    This is a specialization for :func:`select_k_unstable`. Output is not
    guaranteed to be stable.

    Parameters
    ----------
    values : Array, ChunkedArray, RecordBatch, or Table
        Data to sort and get bottom indices from.
    k : int
        The number of `k` elements to keep.
    sort_keys : List-like
        Column key names to order by when input is table-like data.
    memory_pool : MemoryPool, optional
        If not passed, will allocate memory from the default memory pool.

    Returns
    -------
    result : Array of indices
        Indices of the bottom-k ordered elements

    Examples
    --------
    >>> import pyarrow as pa
    >>> import pyarrow.compute as pc
    >>> arr = pa.array(["a", "b", "c", None, "e", "f"])
    >>> pc.bottom_k_unstable(arr, k=3)
    <pyarrow.lib.UInt64Array object at ...>
    [
      0,
      1,
      2
    ]
    N)rÓ   Ú	ascendingc                 S   rÕ   )Nrá   rR   rÖ   rR   rR   rS   r×   ~  rØ   z#bottom_k_unstable.<locals>.<lambda>rÙ   rÚ   rÜ   rR   rR   rS   Úbottom_k_unstableT  rà   râ   Úsystem)Úinitializerr‰   rŽ   c                C   s   t |d�}tdg ||| d�S )aB  
    Generate numbers in the range [0, 1).

    Generated values are uniformly-distributed, double-precision
    in range [0, 1). Algorithm and seed can be changed via RandomOptions.

    Parameters
    ----------
    n : int
        Number of values to generate, must be greater than or equal to 0
    initializer : int or str
        How to initialize the underlying random generator.
        If an integer is given, it is used as a seed.
        If "system" is given, the random generator is initialized with
        a system-specific source of (hopefully true) randomness.
        Other values are invalid.
    options : pyarrow.compute.RandomOptions, optional
        Alternative way of passing options.
    memory_pool : pyarrow.MemoryPool, optional
        If not passed, will allocate memory from the default memory pool.
    )rä   Úrandom)Úlength)r'   r?   )Únrä   r‰   rŽ   rR   rR   rS   rå   ƒ  s   
rå   c                  G   sl   t | ƒ}|dkr1t| d ttfƒrt | d ¡S t| d tƒr&t | d ¡S tdt	| d ƒ› �ƒ‚t | ¡S )a  Reference a column of the dataset.

    Stores only the field's name. Type and other information is known only when
    the expression is bound to a dataset having an explicit scheme.

    Nested references are allowed by passing multiple names or a tuple of
    names. For example ``('foo', 'bar')`` references the field named "bar"
    inside the field named "foo".

    Parameters
    ----------
    *name_or_index : string, multiple strings, tuple or int
        The name or index of the (possibly nested) field the expression
        references to.

    Returns
    -------
    field_expr : Expression
        Reference to the given field

    Examples
    --------
    >>> import pyarrow.compute as pc
    >>> pc.field("a")
    <pyarrow.compute.Expression a>
    >>> pc.field(1)
    <pyarrow.compute.Expression FieldPath(1)>
    >>> pc.field(("a", "b"))
    <pyarrow.compute.Expression FieldRef.Nested(FieldRef.Name(a) ...
    >>> pc.field("a", "b")
    <pyarrow.compute.Expression FieldRef.Nested(FieldRef.Name(a) ...
    r`   r   zCfield reference should be str, multiple str, tuple or integer, got )
r“   rˆ   ÚstrÚintrI   Ú_fieldÚtupleZ_nested_fieldr‡   rp   )Úname_or_indexrç   rR   rR   rS   Úfield�  s   !
ÿÿ
rí   c                 C   s
   t  | ¡S )aB  Expression representing a scalar value.

    Parameters
    ----------
    value : bool, int, float or string
        Python value of the scalar. Note that only a subset of types are
        currently supported.

    Returns
    -------
    scalar_expr : Expression
        An Expression representing the scalar value
    )rI   Z_scalarr¾   rR   rR   rS   rÃ   Î  s   
rÃ   )NNNN)NNrN   )gZpyarrow._computer   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   ÚcollectionsrJ   ru   ÚtextwraprK   rr   Úpyarrowrµ   rL   Zpyarrow.vendoredrM   rT   rU   r\   r‚   r†   rŒ   r™   r£   rª   r²   r³   rÀ   rË   rÑ   rß   râ   rå   rí   rÃ   rR   rR   rR   rS   Ú<module>   s:   þ* O
S
E&,;//1