HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/pandas/compat/numpy/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/pandas/compat/numpy/__pycache__/function.cpython-36.pyc
3

���h_4�@s�UdZddlmZddlmZddlmZmZmZm	Z	ddl
mZm
Z
ddlmZmZddlmZddlmZmZmZGd	d
�d
�Zedd�Zeed
ddd�Zeedddd�Zdd�Zdd�Zdd�Ze�Zddaed<ded<ded<ee�ed�k�rded<eedddd�Z e�Z!d !dbe!d<de!d<ee!dddd�Z"d!d"�Z#edd�Z$ee%ef$ee$d#dd$d�Z&d%d&�Z'e�Z(d'(de(d(<de(d)<ee(ddd*�Z)ee(d+ddd�Z*d,d-�Z+e�Z,d.,de,d(<de,d)<d/e,d0<ee,d1ddd�Z-ee,d2ddd�Z.edd/d3�Z/ee/d4d5�Z0eddd/d6�Z1ee1d7ddd�Z2ee1d8ddd�Z3ed9d:�Z4ee%e%f4ee4d;ddd�Z5edd<�Z6ee%ef6ee6d=ddd�Z7edd�Z8ee%ef8ee8d>ddd�Z9e�Z:d:dce:d<de:d<de:d<ee:d?d4d@�Z;e�Z<dA<de<d(<de<d)<e<j=�Z>de>d<d/e>d0<de>dB<e<j=�Z?de?d<d/e?d0<de?dB<e<j=�Z@d/e@dC<d/e@d0<d/e<d0<ee<d4d5�ZAee>dDddd�ZBee?dEddd�ZCee<dFddd�ZDee@dGddd�ZEe�ZFd.FdeFd(<deFd)<d/eFd0<eeFd4d5�ZGe�ZHdHHdeHd)<dIeHdJ<eeHdKd4d@�ZIdLdM�ZJeddN�ZKeeKdOddd�ZLddP�dQdR�ZMddP�dSdT�ZNddP�dUdV�ZOddddP�dWdX�ZPdeZQe%dd[�d\d]�ZReeSdd^�d_d`�ZTdS)fa�
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.
�)�OrderedDict)�LooseVersion)�Any�Dict�Optional�Union)�__version__�ndarray)�is_bool�
is_integer)�UnsupportedFunctionCall)�
validate_args�validate_args_and_kwargs�validate_kwargsc@s6eZdZdeed�dd�Zd	eedd�dd�ZdS)
�CompatValidatorN)�methodcCs||_||_||_||_dS)N)�fnamer�defaults�max_fname_arg_count)�selfrrrr�r�>/tmp/pip-build-5_djhm0z/pandas/pandas/compat/numpy/function.py�__init__$szCompatValidator.__init__)r�returncCs�|s|r�|dkr|jn|}|dkr(|jn|}|dkr:|jn|}|dkrXt||||j�nD|dkrpt|||j�n,|dkr�t|||||j�ntd|�d���dS)N�args�kwargs�bothzinvalid validation method '�')rrrr
rrr�
ValueError)rrrrrrrrr�__call__0szCompatValidator.__call__)NNN)NNN)�__name__�
__module__�__qualname__r�strrrrrrrr#srN)�outZargminr�)rrrZargmaxcCs(t|t�s|dkr |f|}d}||fS)NT)�
isinstancer	)�skipnarrrr�process_skipnaVs
r(cCst||�\}}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
    )r(�validate_argmin)r'rrrrr�validate_argmin_with_skipna^s
r*cCst||�\}}t||�|S)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
    )r(�validate_argmax)r'rrrrr�validate_argmax_with_skipnaks
r,z+OrderedDict[str, Optional[Union[int, str]]]�axisZ	quicksort�kind�orderz1.17.0Zargsort)rrrzOrderedDict[str, Optional[int]]cCs0t|�s|dkr|f|}d}t||dd�|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_kind)Z	ascendingrrrrr�validate_argsort_with_ascending�s

r2Zclipr0cCs&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_clip)r-rrrrr�validate_clip_with_axis�s



r4zOrderedDict[str, Any]�dtyper$)rrZcumsumcCs(t|�s|f|}d}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
�validate_cum_func)r'rr�namerrr�validate_cum_func_with_skipna�s

r8z OrderedDict[str, Optional[bool]]F�keepdims�all�any)r$r9r)r)r-r$r9�min�max�C)r/Zreshape)r-�repeat�round�sort)rrzOrderedDict[str, Optional[Any]]�initialZoverwrite_input�sum�prod�meanZmedianzOrderedDict[str, Optional[str]]�raise�modeZtakecCs4t|t�s|dkr |f|}d}t||ddd�|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
    NTr0r)rr)r&r	�
validate_take)�convertrrrrr�validate_take_with_convert(s

rJ)ZaxesZ	transpose)rcCsFd}d|�d�}t|�dkr$t|��x|D]}||kr*t|��q*WdS)Nr-r5r$z9numpy operations are not valid with window objects. Use .z() directly instead r)r-r5r$)�lenr)r7rr�
numpy_args�msg�argrrr�validate_window_func=s
rOcCsFd}d|�d�}t|�dkr$t|��x|D]}||kr*t|��q*WdS)Nr-r5r$zFnumpy operations are not valid with window objects. Use .rolling(...).z() instead r)r-r5r$)rKr)r7rrrLrMrNrrr�validate_rolling_funcLs
rPcCsFd}d|�d�}t|�dkr$t|��x|D]}||kr*t|��q*WdS)Nr-r5r$zHnumpy operations are not valid with window objects. Use .expanding(...).z() instead r)r-r5r$)rKr)r7rrrLrMrNrrr�validate_expanding_func[s
rQcCsD|dkrg}t|�t|�}t|�t|�dkr@td|�d���dS)z�
    'args' and 'kwargs' should be empty, except for allowed
    kwargs because all of
    their necessary parameters are explicitly listed in
    the function signature
    Nrz?numpy operations are not valid with groupby. Use .groupby(...).z
() instead)�setrKr)r7rr�allowedrrr�validate_groupby_funcjsrT�std�var)rrcCs:t|�t|�dkr6|tkr.td|�d���ntd��dS)z�
    'args' and 'kwargs' should be empty because all of
    their necessary parameters are explicitly listed in
    the function signature
    rzAnumpy operations are not valid with resample. Use .resample(...).z
() insteadztoo many arguments passed inN)rK�RESAMPLER_NUMPY_OPSr�	TypeError)rrrrrr�validate_resampler_func�s
rY)r-rcCs@d}|dkrdS||ks,|dkr<||dkr<td|�d���dS)z�
    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

    Raises
    ------
    ValueError
    r%Nrz4`axis` must be fewer than the number of dimensions (�))r)r-�ndimrrr�validate_minmax_axis�s

r\���r]r])N)r<r=rCrDrErUrV)U�__doc__�collectionsrZdistutils.versionrZtypingrrrrZnumpyrZ_np_versionr	Zpandas._libs.libr
rZ
pandas.errorsrZpandas.util._validatorsr
rrr�dictZARGMINMAX_DEFAULTSr)r+r(r*r,ZARGSORT_DEFAULTSZvalidate_argsortZARGSORT_DEFAULTS_KINDr1r2Z
CLIP_DEFAULTSr#r3r4ZCUM_FUNC_DEFAULTSr6Zvalidate_cumsumr8ZALLANY_DEFAULTSZvalidate_allZvalidate_anyZLOGICAL_FUNC_DEFAULTSZvalidate_logical_funcZMINMAX_DEFAULTSZvalidate_minZvalidate_maxZRESHAPE_DEFAULTSZvalidate_reshapeZREPEAT_DEFAULTSZvalidate_repeatZROUND_DEFAULTSZvalidate_roundZ
SORT_DEFAULTSZ
validate_sortZSTAT_FUNC_DEFAULTS�copyZSUM_DEFAULTSZ
PROD_DEFAULTSZMEDIAN_DEFAULTSZvalidate_stat_funcZvalidate_sumZ
validate_prodZ
validate_meanZvalidate_medianZSTAT_DDOF_FUNC_DEFAULTSZvalidate_stat_ddof_funcZ
TAKE_DEFAULTSrHrJZTRANSPOSE_DEFAULTSZvalidate_transposerOrPrQrTrWrY�intr\rrrr�<module>s�*