o
    _~#g3                     @  s  U d Z ddlmZ ddlmZmZmZmZmZ ddl	Z
ddl	mZ ddlmZmZ ddlmZ ddlmZmZmZ erIdd	lmZmZ ed
edZG dd dZddiZeeddddZeeddddZd{ddZd|ddZd|ddZi Z de!d< d e d!< d"e d#< de d$< de d#< de d%< ee d&ddd'Z"i Z#d(e!d)< d e#d!< de#d$< de#d%< ee#d&ddd'Z$d}d,d-Z%ddiZ&d.e!d/< ee&d0dd1dZ'ed~d4d5Z(edd6d5Z(dd9d5Z(i Z)d.e!d:< de)d;< de)d< ee)ddd<Z*ee)d=dddZ+dd>d?Z,i Z-d@e!dA< de-d;< de-d< dBe-dC< de-d!< ee-dDdddZ.ee-dEdddZ/ddBdFZ0ee0dGdHZ1ddddBdIZ2ee2dJdddZ3ee2dKdddZ4d$dLiZ5dMe!dN< ee5dOdddZ6d!diZ7d.e!dP< ee7dQdddZ8ddiZ9d.e!dR< ee9dSdddZ:i Z;de!dT< d e;d!< d"e;d#< de;d$< ee;dUdGdVZ<i Z=dWe!dX< de=d;< de=d< e=> Z?de?d!< dBe?dC< de?dY< e?> Z@e?> ZAe=> ZBdBeBdZ< dBeBdC< dBe=dC< ee=dGdHZCee?d[dddZDee@d\dddZEeeAd]dddZFeeBd^dddZGi ZHd@e!d_< deHd;< deHd< dBeHdC< eeHdGdHZIi ZJd`e!da< deJd< dbeJdc< eeJdddGdVZKddgdhZLdidiZMeeMdjdddZNdddmdnZOdoZPddqdrZQdddvdwZReGeFe3e4eDeEdxZSddydzZTdS )a  
For compatibility with numpy libraries, pandas functions or methods have to
accept '*args' and '**kwargs' parameters to accommodate numpy arguments that
are not actually used or respected in the pandas implementation.

To ensure that users do not abuse these parameters, validation is performed in
'validators.py' to make sure that any extra parameters passed correspond ONLY
to those in the numpy signature. Part of that validation includes whether or
not the user attempted to pass in non-default values for these extraneous
parameters. As we want to discourage users from relying on these parameters
when calling the pandas implementation, we want them only to pass in the
default values for these parameters.

This module provides a set of commonly used default arguments for functions and
methods that are spread throughout the codebase. This module will make it
easier to adjust to future upstream changes in the analogous numpy signatures.
    )annotations)TYPE_CHECKINGAnyTypeVarcastoverloadN)ndarray)is_bool
is_integer)UnsupportedFunctionCall)validate_argsvalidate_args_and_kwargsvalidate_kwargs)AxisAxisInt	AxisNoneTc                   @  s0   e Zd Z			d
dddZ			d
ddd	ZdS )CompatValidatorNmethod
str | NonereturnNonec                 C  s   || _ || _|| _|| _d S N)fnamer   defaultsmax_fname_arg_count)selfr   r   r   r    r   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pandas/compat/numpy/function.py__init__4   s   
zCompatValidator.__init__c                 C  s   |s|sd S |d u r| j n|}|d u r| jn|}|d u r| jn|}|dkr/t|||| j d S |dkr<t||| j d S |dkrKt||||| j d S td| d)Nargskwargsbothzinvalid validation method '')r   r   r   r   r   r   r   
ValueError)r   r   r    r   r   r   r   r   r   __call__@   s"   zCompatValidator.__call__)NNN)r   r   r   r   )__name__
__module____qualname__r   r$   r   r   r   r   r   3   s    r   outargminr!      )r   r   r   argmaxskipnabool | ndarray | Noner   tuple[bool, Any]c                 C  s(   t | ts	| d u r| f| }d} | |fS )NT)
isinstancer   )r,   r   r   r   r   process_skipnah   s   
r0   boolc                 C     t | |\} }t|| | S )a  
    If 'Series.argmin' is called via the 'numpy' library, the third parameter
    in its signature is 'out', which takes either an ndarray or 'None', so
    check if the 'skipna' parameter is either an instance of ndarray or is
    None, since 'skipna' itself should be a boolean
    )r0   validate_argminr,   r   r    r   r   r   validate_argmin_with_skipnap      
r5   c                 C  r2   )a  
    If 'Series.argmax' is called via the 'numpy' library, the third parameter
    in its signature is 'out', which takes either an ndarray or 'None', so
    check if the 'skipna' parameter is either an instance of ndarray or is
    None, since 'skipna' itself should be a boolean
    )r0   validate_argmaxr4   r   r   r   validate_argmax_with_skipna|   r6   r8   zdict[str, int | str | None]ARGSORT_DEFAULTSaxis	quicksortkindorderstableargsort)r   r   r   zdict[str, int | None]ARGSORT_DEFAULTS_KIND	ascendingbool | int | Nonec                 C  s:   t | s| du r| f| }d} t||dd tt| } | S )a!  
    If 'Categorical.argsort' is called via the 'numpy' library, the first
    parameter in its signature is 'axis', which takes either an integer or
    'None', so check if the 'ascending' parameter has either integer type or is
    None, since 'ascending' itself should be a boolean
    NT   )r   )r
   validate_argsort_kindr   r1   )rB   r   r    r   r   r   validate_argsort_with_ascending   s   

rF   zdict[str, Any]CLIP_DEFAULTScliprD   r   r   c                 C     d S r   r   r;   r   r    r   r   r   validate_clip_with_axis      rK   c                 C  rI   r   r   rJ   r   r   r   rK      rL   ndarray | AxisNoneTAxisNoneT | Nonec                 C  s&   t | tr| f| }d} t|| | S )a  
    If 'NDFrame.clip' is called via the numpy library, the third parameter in
    its signature is 'out', which can takes an ndarray, so check if the 'axis'
    parameter is an instance of ndarray, since 'axis' itself should either be
    an integer or None
    N)r/   r   validate_cliprJ   r   r   r   rK      s
   
	

CUM_FUNC_DEFAULTSdtype)r   r   cumsumc                 C  s>   t | s| f| }d} n
t| tjrt| } t|||d | S )z
    If this function is called via the 'numpy' library, the third parameter in
    its signature is 'dtype', which takes either a 'numpy' dtype or 'None', so
    check if the 'skipna' parameter is a boolean or not
    Tr   )r	   r/   npbool_r1   validate_cum_func)r,   r   r    namer   r   r   validate_cum_func_with_skipna   s   
rX   zdict[str, bool | None]ALLANY_DEFAULTSFkeepdimsallany)r(   rZ   r    )r   )r;   rQ   r(   rZ   minmaxCzdict[str, str]RESHAPE_DEFAULTSreshapeREPEAT_DEFAULTSrepeatROUND_DEFAULTSroundSORT_DEFAULTSsort)r   r   zdict[str, Any | None]STAT_FUNC_DEFAULTSinitialoverwrite_inputsumprodmeanmedianSTAT_DDOF_FUNC_DEFAULTSzdict[str, str | None]TAKE_DEFAULTSraisemodetakeconvertndarray | bool | Nonec                 C  s4   t | ts	| du r| f| }d} t||ddd | S )z
    If this function is called via the 'numpy' library, the third parameter in
    its signature is 'axis', which takes either an ndarray or 'None', so check
    if the 'convert' parameter is either an instance of ndarray or is None
    NTrD   r!   )r   r   )r/   r   validate_take)rt   r   r    r   r   r   validate_take_with_convertH  s
   
rw   axes	transposerW   strc                 C  sD   |du rg }t |t | }t|t| dkr td|  ddS )z
    'args' and 'kwargs' should be empty, except for allowed kwargs because all
    of their necessary parameters are explicitly listed in the function
    signature
    Nr   z?numpy operations are not valid with groupby. Use .groupby(...).
() instead)setlenr   )rW   r   r    allowedr   r   r   validate_groupby_func\  s   r   )r]   r^   rk   rl   rm   stdvarr   c                 C  s8   t |t | dkr| tv rtd|  dtddS )z
    'args' and 'kwargs' should be empty because all of their necessary
    parameters are explicitly listed in the function signature
    r   zAnumpy operations are not valid with resample. Use .resample(...).r{   ztoo many arguments passed inN)r}   RESAMPLER_NUMPY_OPSr   	TypeError)r   r   r    r   r   r   validate_resampler_funcq  s   r   AxisInt | Nonendimintc                 C  s@   | du rdS | |ks| dk r||  dk rt d| ddS dS )a  
    Ensure that the axis argument passed to min, max, argmin, or argmax is zero
    or None, as otherwise it will be incorrectly ignored.

    Parameters
    ----------
    axis : int or None
    ndim : int, default 1

    Raises
    ------
    ValueError
    Nr   z4`axis` must be fewer than the number of dimensions ())r#   )r;   r   r   r   r   validate_minmax_axis  s
   r   )rn   rm   r]   r^   rk   rl   c                 C  s(   | t vrt||| dS t |  }|||S )NrS   )_validation_funcsvalidate_stat_func)r   r   r    validation_funcr   r   r   validate_func  s   
r   )r,   r-   r   r.   )r,   r-   r   r1   )rB   rC   r   r1   )r;   r   r   r   )r;   r   r   r   )r;   rM   r   rN   )r,   r1   r   r1   )rt   ru   r   r1   r   )rW   rz   r   r   )r   rz   r   r   )r*   )r;   r   r   r   r   r   )r   r   )U__doc__
__future__r   typingr   r   r   r   r   numpyrT   r   pandas._libs.libr	   r
   pandas.errorsr   pandas.util._validatorsr   r   r   pandas._typingr   r   r   r   ARGMINMAX_DEFAULTSr3   r7   r0   r5   r8   r9   __annotations__validate_argsortrA   rE   rF   rG   rO   rK   rP   rV   validate_cumsumrX   rY   validate_allvalidate_anyLOGICAL_FUNC_DEFAULTSvalidate_logical_funcMINMAX_DEFAULTSvalidate_minvalidate_maxr`   validate_reshaperb   validate_repeatrd   validate_roundrf   validate_sortrh   copySUM_DEFAULTSPROD_DEFAULTSMEAN_DEFAULTSMEDIAN_DEFAULTSr   validate_sumvalidate_prodvalidate_meanvalidate_medianro   validate_stat_ddof_funcrp   rv   rw   TRANSPOSE_DEFAULTSvalidate_transposer   r   r   r   r   r   r   r   r   r   <module>   s&   ,









