o
    hK                     @   s0   d dl ZeejZdd Zdd Zdd ZdS )    Nc                  G   sN   t | dkr
tdtdd | D }tdd | D }dt t|d | S )a>  
    Get a relative tolerance for a set of arrays.

    Parameters
    ----------
    *arrays: tuple
        Set of `numpy.ndarray` to get the tolerance for.

    Returns
    -------
    float
        Relative tolerance for the set of arrays.

    Raises
    ------
    ValueError
        If no array is provided.
    r   z$At least one array must be provided.c                 s   s    | ]}|j V  qd S )N)size.0array r   P/var/www/vscode/kcb/lib/python3.10/site-packages/scipy/_lib/cobyqa/utils/math.py	<genexpr>   s    z!get_arrays_tol.<locals>.<genexpr>c                 s   s.    | ]}t jt |t | d dV  qdS )      ?)initialN)npmaxabsisfiniter   r   r   r   r      s
    
g      $@r	   )len
ValueErrorr   EPS)arraysr   weightr   r   r   get_arrays_tol   s   r   c                 C   s,   t t | t} | jdkrt|| S )a'  
    Preprocess a 1-dimensional array.

    Parameters
    ----------
    x : array_like
        Array to be preprocessed.
    message : str
        Error message if `x` cannot be interpreter as a 1-dimensional array.

    Returns
    -------
    `numpy.ndarray`
        Preprocessed array.
       )r   
atleast_1dsqueezeastypefloatndimr   xmessager   r   r   exact_1d_array$   s   
r   c                 C   s&   t | t} | jdkrt|| S )a'  
    Preprocess a 2-dimensional array.

    Parameters
    ----------
    x : array_like
        Array to be preprocessed.
    message : str
        Error message if `x` cannot be interpreter as a 2-dimensional array.

    Returns
    -------
    `numpy.ndarray`
        Preprocessed array.
       )r   
atleast_2dr   r   r   r   r   r   r   r   exact_2d_array:   s   
r!   )	numpyr   finfor   epsr   r   r   r!   r   r   r   r   <module>   s
    