Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/util/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/util/__pycache__/_validators.cpython-312.pyc

�

Mٜg�7��<�dZddlmZddlmZmZddlmZmZddl	Z
ddlmZddl
mZmZedee�Zed	eed�Zdd
�Zdd�Zdd�Zdd
�Zdd�Z		dd�Z		d									dd�Zddd�Zdd�Zed d��Zed!d��Z				d"d�Zd#d�Zd$d�Zd%d�Z dd�Z!y)&zV
Module that contains many useful utilities
for validating data or function arguments
�)�annotations)�Iterable�Sequence)�TypeVar�overloadN)�lib)�is_bool�
is_integer�BoolishT�BoolishNoneTc
���|dkrtd��t|�t|�kDr<t|�|z}t|�|z}|dk(rdnd}t|�d|�d|�d|�d	���y
)z�
    Checks whether 'args' has length of at most 'compat_args'. Raises
    a TypeError if that is not the case, similar to in Python when a
    function is called with too many arguments.
    rz*'max_fname_arg_count' must be non-negative��argument�	argumentsz() takes at most � z (z given)N)�
ValueError�len�	TypeError)�fname�args�max_fname_arg_count�compat_args�
max_arg_count�actual_arg_countrs       �B/usr/local/lib/python3.12/site-packages/pandas/util/_validators.py�_check_arg_lengthrs����Q���E�F�F�
�4�y�3�{�#�#��K�(�+>�>�
��t�9�':�:��!.�!�!3�:�����g�&�}�o�Q�x�j�A� �!��
*�
�	
�$�c���|D]H}	||}||}|�|�|�|�d}n||k(}t|�std��	|r�8td|�d|�d���y#t$r
||||u}Y�,wxYw)z�
    Check that the keys in `arg_val_dict` are mapped to their
    default values as specified in `compat_args`.

    Note that this function is to be called only when it has been
    checked that arg_val_dict.keys() is a subset of compat_args
    NFz'match' is not a booleanzthe 'z=' parameter is not supported in the pandas implementation of z())r	r)r�arg_val_dictr�key�v1�v2�matchs       r�_check_for_default_valuesr$1s�����	:��c�"�B��S�!�B���2�:�2�:�"�.����b����5�>� �!;�<�<�"�����u�0�05�w�b�:��
�1��(�	:� ��%��S�)9�9�E�	:�s�0A�A%�$A%c�d�t||||�tt||��}t|||�y)a
    Checks whether the length of the `*args` argument passed into a function
    has at most `len(compat_args)` arguments and whether or not all of these
    elements in `args` are set to their default values.

    Parameters
    ----------
    fname : str
        The name of the function being passed the `*args` parameter
    args : tuple
        The `*args` parameter passed into a function
    max_fname_arg_count : int
        The maximum number of arguments that the function `fname`
        can accept, excluding those in `args`. Used for displaying
        appropriate error messages. Must be non-negative.
    compat_args : dict
        A dictionary of keys and their associated default values.
        In order to accommodate buggy behaviour in some versions of `numpy`,
        where a signature displayed keyword arguments but then passed those
        arguments **positionally** internally when calling downstream
        implementations, a dict ensures that the original
        order of the keyword arguments is enforced.

    Raises
    ------
    TypeError
        If `args` contains more values than there are `compat_args`
    ValueError
        If `args` contains values that do not correspond to those
        of the default values specified in `compat_args`
    N)r�dict�zipr$)rrrr�kwargss     r�
validate_argsr)Ws3��@�e�T�#6��D�
�#�k�4�(�
)�F��e�V�[�9rc��t|�t|�z
}|r%tt|��}t|�d|�d���y)z}
    Checks whether 'kwargs' contains any keys that are not
    in 'compat_args' and raises a TypeError if there is one.
    z'() got an unexpected keyword argument '�'N)�set�next�iterr)rr(r�diff�bad_args     r�_check_for_invalid_keysr1�sG���v�;��[�)�)�D���t�D�z�"���5�'�!H��	�QR�S�T�T�rc�X�|j�}t|||�t|||�y)a�
    Checks whether parameters passed to the **kwargs argument in a
    function `fname` are valid parameters as specified in `*compat_args`
    and whether or not they are set to their default values.

    Parameters
    ----------
    fname : str
        The name of the function being passed the `**kwargs` parameter
    kwargs : dict
        The `**kwargs` parameter passed into `fname`
    compat_args: dict
        A dictionary of keys that `kwargs` is allowed to have and their
        associated default values

    Raises
    ------
    TypeError if `kwargs` contains keys not in `compat_args`
    ValueError if `kwargs` contains keys in `compat_args` that do not
    map to the default values specified in `compat_args`
    N)�copyr1r$)rr(r�kwdss    r�validate_kwargsr5�s'��,�;�;�=�D��E�6�;�7��e�T�;�7rc���t||t|j��z||�tt	||��}|D]}||vs�t|�d|�d���|j
|�t|||�y)a�
    Checks whether parameters passed to the *args and **kwargs argument in a
    function `fname` are valid parameters as specified in `*compat_args`
    and whether or not they are set to their default values.

    Parameters
    ----------
    fname: str
        The name of the function being passed the `**kwargs` parameter
    args: tuple
        The `*args` parameter passed into a function
    kwargs: dict
        The `**kwargs` parameter passed into `fname`
    max_fname_arg_count: int
        The minimum number of arguments that the function `fname`
        requires, excluding those in `args`. Used for displaying
        appropriate error messages. Must be non-negative.
    compat_args: dict
        A dictionary of keys that `kwargs` is allowed to
        have and their associated default values.

    Raises
    ------
    TypeError if `args` contains more values than there are
    `compat_args` OR `kwargs` contains keys not in `compat_args`
    ValueError if `args` contains values not at the default value (`None`)
    `kwargs` contains keys in `compat_args` that do not map to the default
    value as specified in `compat_args`

    See Also
    --------
    validate_args : Purely args validation.
    validate_kwargs : Purely kwargs validation.

    z-() got multiple values for keyword argument 'r+N)r�tuple�valuesr&r'r�updater5)rrr(rr�	args_dictr s       r�validate_args_and_kwargsr;�s���P�
�t�e�F�M�M�O�,�,�.A�;���S��d�+�,�I����&�=���'�F�s�e�1�M��
���M�M�)���E�6�;�/rc��t|�}|r|xs|du}|r|xst|t�}|s%td|�dt	|�j
�d���|S)aR
    Ensure that argument passed in arg_name can be interpreted as boolean.

    Parameters
    ----------
    value : bool
        Value to be validated.
    arg_name : str
        Name of the argument. To be reflected in the error message.
    none_allowed : bool, default True
        Whether to consider None to be a valid boolean.
    int_allowed : bool, default False
        Whether to consider integer value to be a valid boolean.

    Returns
    -------
    value
        The same value as input.

    Raises
    ------
    ValueError
        If the value is not a valid boolean.
    NzFor argument "z$" expected type bool, received type �.)r	�
isinstance�intr�type�__name__)�value�arg_name�none_allowed�int_allowed�
good_values     r�validate_bool_kwargrG�sl��<���J���2�E�T�M�
���9�:�e�S�#9�
����X�J�'���K�(�(�)��
,�
�	
��Lrc��ddlm}|�
|�td��|�|�||�}||fS|�@|�>|r8t|tt
f�r"t
dt|�j�d���||fS|�
|�td��||fS)a$
    Validate the keyword arguments to 'fillna'.

    This checks that exactly one of 'value' and 'method' is specified.
    If 'method' is specified, this validates that it's a valid method.

    Parameters
    ----------
    value, method : object
        The 'value' and 'method' keyword arguments for 'fillna'.
    validate_scalar_dict_value : bool, default True
        Whether to validate that 'value' is a scalar or dict. Specifically,
        validate that it is not a list or tuple.

    Returns
    -------
    value, method : object
    r)�clean_fill_methodz(Must specify a fill 'value' or 'method'.z>"value" parameter must be a scalar or dict, but you passed a "�"z)Cannot specify both 'value' and 'method'.)	�pandas.core.missingrIrr>�listr7rr@rA)rB�method�validate_scalar_dict_valuerIs    r�validate_fillna_kwargsrOs���&6��}����C�D�D��}��+�"�6�*���&�=��
�	�v�~�%�*�U�T�5�M�*J��!�!%�e��!5�!5� 6�a�9��
��&�=��
�	�v�1��D�E�E��&�=�rc���tj|�}d}|jdk(r$d|cxkrdkst|��t|��|St	d�|D��st|��|S)a�
    Validate percentiles (used by describe and quantile).

    This function checks if the given float or iterable of floats is a valid percentile
    otherwise raises a ValueError.

    Parameters
    ----------
    q: float or iterable of floats
        A single percentile or an iterable of percentiles.

    Returns
    -------
    ndarray
        An ndarray of the percentiles if valid.

    Raises
    ------
    ValueError if percentiles are not in given interval([0, 1]).
    z0percentiles should all be in the interval [0, 1]rrc3�<K�|]}d|cxkxrdknc���y�w)rrN�)�.0�qss  r�	<genexpr>z&validate_percentile.<locals>.<genexpr>Ss����0�%�B�1��<�a�<�<�%�s�)�np�asarray�ndimr�all)�q�q_arr�msgs   r�validate_percentiler]6sm��*
�J�J�q�M�E�=�C��z�z�Q���E��Q���S�/�!���S�/�!��L��0�%�0�0��S�/�!��Lrc��y�NrR��	ascendings r�validate_ascendingrbX���rc��yr_rRr`s rrbrb]rcrc��ddd�}t|t�s
t|dfi|��S|D�cgc]}t|dfi|����c}Scc}w)z8Validate ``ascending`` kwargs for ``sort_index`` method.FT)rDrEra)r>rrG)rar(�items   rrbrbbsO��$�D�
9�F��i��*�"�9�k�D�V�D�D�IR�S�����k�<�V�<��S�S��Ss�>c�`�d}d}|�d}d}||fS|dk(rd}||fS|dk(rd}||fStd��)a%
    Check that the `closed` argument is among [None, "left", "right"]

    Parameters
    ----------
    closed : {None, "left", "right"}

    Returns
    -------
    left_closed : bool
    right_closed : bool

    Raises
    ------
    ValueError : if argument is not among valid values
    FT�left�rightz/Closed has to be either 'left', 'right' or None)r)�closed�left_closed�right_closeds   r�validate_endpointsrmmsp��"�K��L�
�~�������$�$�
�6�	�����$�$�
�7�	�����$�$��J�K�Krc�p�d}t|t�rddddd�j|�}|�td��|S)aD
    Check that the `inclusive` argument is among {"both", "neither", "left", "right"}.

    Parameters
    ----------
    inclusive : {"both", "neither", "left", "right"}

    Returns
    -------
    left_right_inclusive : tuple[bool, bool]

    Raises
    ------
    ValueError : if argument is not among valid values
    N)TT�TF)FT)FF)�bothrhri�neitherz?Inclusive has to be either 'both', 'neither', 'left' or 'right')r>�str�getr)�	inclusive�left_right_inclusives  r�validate_inclusiverv�sU�� 6:���)�S�!� �!�"�%�	 
�
�#�i�.�	��#��M�
�	
� �rc��t|�std|�d|����|dkr||z
}d|cxkr|ksntd|�d|����|S)z�
    Check that we have an integer between -length and length, inclusive.

    Standardize negative loc to within [0, length].

    The exceptions we raise on failure match np.insert.
    z loc must be an integer between -z and r)r
r�
IndexError)�loc�lengths  r�validate_insert_locr{�s_���c�?��:�6�(�%��x�P�Q�Q�
�Q�w��v�
�����v���;�F�8�5���Q�R�R��Jrc�P�|tjur|dvrtd|�d���yy)N)�numpy_nullable�pyarrowzdtype_backend z= is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.)r�
no_defaultr)�
dtype_backends r�check_dtype_backendr��s?���C�N�N�*�� =�=�� ���0)�*��
�>�+r)�return�Nonero)
rBrrCrrrD�boolrEr�r�r)T)rNr�)rZzfloat | Iterable[float]r�z
np.ndarray)rarr�r)razSequence[BoolishT]r�zlist[BoolishT])razbool | int | Sequence[BoolishT]r�zbool | int | list[BoolishT])rj�
str | Noner��tuple[bool, bool])rtr�r�r�)ryr?rzr?r�r?)"�__doc__�
__future__r�collections.abcrr�typingrr�numpyrV�pandas._libsr�pandas.core.dtypes.commonr	r
r�r?rrrr$r)r1r5r;rGrOr]rbrmrvr{r�rRrr�<module>r�s���#���
���
�:�t�S�)���~�t�S�$�7��
�(#�L&:�R
U�8�670�	�70�z��	*��*��*��*��	*�
�*�Z$�N�D
��
��
��
��T�.�T� �T�%�B �D�$r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists