o
    Ö­jK  ã                   @   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   úY/var/www/html/CropPilot/venv/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
    