Sindbad~EG File Manager
�
Mٜg�7 � �< � d Z ddlmZ ddlmZmZ ddlmZmZ ddl Z
ddlmZ ddl
mZmZ edee� Z ed 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
�� � |dk rt d� �t |� t |� kD r<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.
r z*'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_countr s �B/usr/local/lib/python3.12/site-packages/pandas/util/_validators.py�_check_arg_lengthr s� � � �Q���E�F�F�
�4�y�3�{�#�#��K�(�+>�>�
��t�9�':�:��!.�!�!3�:�����g�&�}�o�Q�x�j� A� �!��
*�
�
� $� c �� � |D ]H } || }|| }|�|�|�|�d}n||k( }t |� st d� � |r�8t d|� d| � d�� � y# t $ r
|| || u }Y �,w xY w)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$ 1 s� � � �� :��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 | |||� t t ||� � }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$ )r r r r �kwargss r �
validate_argsr) W s3 � �@ �e�T�#6��D�
�#�k�4�(�
)�F��e�V�[�9r c � � t |� t |� z
}|r%t t |� � }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 )r r( r �diff�bad_args r �_check_for_invalid_keysr1 � sG � � �v�;��[�)�)�D���t�D�z�"���5�'�!H�� �QR�S�T�T� r c �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)�copyr1 r$ )r r( r �kwdss r �validate_kwargsr5 � s'