U
    e»{jÄ  ã                   @   sz   d dl Z d dlZd dlZd dlZd dlZddlmZ ddddgZej	edd	�Z
ddd„Zejd d
d
fdd„Zddd„ZdS )é    Né   )ÚindentÚfixed_width_indentÚdiff_valuesÚreport_diff_valuesÚwhere_not_allcloseé   )Úwidthç        c                 C   sL   t | tƒr@t |tƒr@t | ¡r,t |¡r,dS tj| |||d� S | |kS dS )a¹  
    Diff two scalar values. If both values are floats, they are compared to
    within the given absolute and relative tolerance.

    Parameters
    ----------
    a, b : int, float, str
        Scalar values to compare.

    rtol, atol : float
        Relative and absolute tolerances as accepted by
        :func:`numpy.allclose`.

    Returns
    -------
    is_different : bool
        `True` if they are different, else `False`.

    F©ÚrtolÚatolN)Ú
isinstanceÚfloatÚnpÚisnanZallclose©ÚaÚbr   r   © r   úQ/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/utils/diff.pyr      s
    c              	   C   sò  t | tjƒ�r@t |tjƒ�r@| j|jkr\| td|ƒ¡ tt| jƒt|jƒ||d d� dS t | j	tj
¡r”t |j	tj
¡r”t t| |||d�¡}nt t | |k¡¡}|jd }|dd… D ]L}| ¡ }	| td	|	›d
�|ƒ¡ t| t|ƒ |t|ƒ ||d ||d� q¾|dk�r8| td|d d›d�|ƒ¡ dS |dkS t| ƒ}
t|ƒ}|
|k�r˜d}d}d}t | tjƒ�r†t| ƒ} t|ƒ}nt| ƒ} t|ƒ}nÊtt|
jƒt|jƒƒd }|d d }d|
j d  |¡d }d|j d  |¡d }t | tƒ}t |tƒ}|�r|�r"|�s*t | tjƒ�r*t| ƒnt| ƒ} |�r>|�rR|�sZt |tjƒ�rZt|ƒnt|ƒ}d}t |  ¡ | ¡ ¡D ]r}|d dk�r¢d}||dd…  }n,|d dk�rÆd}||dd…  }n|| }| td | d¡¡|ƒ¡ �qz|S )a}  
    Write a diff report between two values to the specified file-like object.

    Parameters
    ----------
    a, b
        Values to compare. Anything that can be turned into strings
        and compared using :py:mod:`difflib` should work.

    fileobj : object
        File-like object to write to.
        The default is ``sys.stdout``, which writes to terminal.

    indent_width : int
        Character column(s) to indent.

    rtol, atol : float
        Relative and absolute tolerances as accepted by
        :func:`numpy.allclose`.

    Returns
    -------
    identical : bool
        `True` if no diff, else `False`.

    z  Different array shapes:
r   )ÚfileobjÚindent_widthFr   r   Né   z  at z:
)r   r   r   r   z  ...and at Údz more indices.
ú za>zb>ú(z) Tú-ú+z  {}
Ú
)r   r   ZndarrayÚshapeÚwriter   r   ÚstrZ
issubdtypeZdtypeZfloatingZ	transposer   ÚwhereÚtolistÚtupleÚtypeÚnumbersÚNumberÚreprÚmaxÚlenÚ__name__ÚrjustÚdifflibZndiffÚ
splitlinesÚformatÚrstrip)r   r   r   r   r   r   Zdiff_indicesZ	num_diffsÚidxZlidxZtypeaZtypebZlnpadZsign_aZsign_bÚpaddingZis_a_strZis_b_strZ	identicalÚliner   r   r   r   2   s¬    ÿü 


ú	
 ÿÿ




þþý
ýúþþý
ýú	ÿçñhãˆµøä>ç:Œ0âŽyE>c                 C   s€   t  t  | ¡¡st j | ¡j} t  t  |¡¡s<t j |¡j}|dkrZ|dkrZt  | |k¡S t  t  | | ¡||t  |¡  k¡S )a®  
    A version of :func:`numpy.allclose` that returns the indices
    where the two arrays differ, instead of just a boolean value.

    Parameters
    ----------
    a, b : array-like
        Input arrays to compare.

    rtol, atol : float
        Relative and absolute tolerances as accepted by
        :func:`numpy.allclose`.

    Returns
    -------
    idx : tuple of array
        Indices where the two arrays differ.

    r
   )r   ÚallÚisfiniteÚmaZfix_invalidÚdatar#   Úabsr   r   r   r   r   ¯   s    )r
   r
   )r5   r6   )r.   Ú	functoolsr'   ÚsysÚnumpyr   Úmiscr   Ú__all__Úpartialr   r   Ústdoutr   r   r   r   r   r   Ú<module>   s   ü	
}