B
    q\|                 @   sv   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 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npZisnanZallclose)abr   r    r   1lib/python3.7/site-packages/astropy/utils/diff.pyr      s
    c          	   C   s  t | tjrt |tjr| j|jkrX|td| tt| jt|j||d d dS tt	| |k}|jd }xV|dd D ]F}|
 }|td|| t| t| |t| ||d d qW |dkr|td	|d | dS |dkS t| }t|}	||	krTd
}
d}d}t | tjrBt| } t|}nt| } t|}ntt|jt|	jd }|d d
 }
d|j d |d }d|	j d |d }t | t}t |t}|r|r|st | tjrt| nt| } |r|r|st |tjrt|nt|}d}xt|  | D ]r}|d dkr`d}||dd  }n,|d dkrd}||dd  }n|
| }|td|d| q8W |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 : obj
        File-like object to write to.
        The default is ``sys.stdout``, which writes to terminal.

    indent_width : int
        Character column(s) to indent.

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

    z  Different array shapes:
r   )fileobjindent_widthFr   N   z  at {!r}:
z  ...and at {:d} more indices.
 za>zb>(z) T-+z  {}

)r   r   Zndarrayshapewriter   r   strZ	transposewheretolistformattupletypenumbersNumberreprmaxlen__name__rjustdifflibZndiff
splitlinesrstrip)r   r   r   r   Zdiff_indicesZ	num_diffsidxZlidxZtypeaZtypebZlnpadZsign_aZsign_bZpaddingZis_a_strZis_b_strZ	identicalliner   r   r   r   .   sr    





h㈵>:0yE>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 arrays
        Indices where the two arrays differ.

    g        )r   allZisfiniteZmaZfix_invaliddatar   abs)r   r   r   r   r   r   r   r      s    )r
   r
   )r0   r1   )r+   	functoolssysr$   Znumpyr   Zmiscr   __all__partialr   r   stdoutr   r   r   r   r   r   <module>   s   
_