a
    SicX                     @  sn  d dl mZ d dlmZmZ d dlZd dlZd dlm	Z	m
Z
 d dlmZ d dlmZ d dlm  mZ d dlmZ d dlmZmZmZmZmZmZmZ d d	lmZmZ d d
l m!Z! d dl"Z#d dl"m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- d dl.m/Z/ d dl0m1Z1m2Z2m3Z3m4Z4m5Z5 d dl6m7Z7 d dl8m9Z9 d dl:m;Z; d dl<m=Z= de
ddfddddddddZ>dddddZ?d d! Z@dld#dd$d%d&ZAdd"e
d"d"d"ddd'f	d'd'd(d#dd#d#d#ddd)dd*d+d,ZBdmd(dd.d/d0ZCdnd)d)dd2d3d4ZDdd5d6d7ZEdd5d8d9ZFdodd5d;d<ZGdpdd5d>d?ZHdqdd5dAdBZIdrdd5dDdEZJdsdd5dGdHZKdtdIdJZLdudddMdNdOZMd"de
dKddfdddddPdQdRZNd"dd"e
d"dKdKd"d"d"d"dddSfd"dKdTdddddUdVdWZOd"ddd"e
d"dKdKdKd"dKd"d"dddXfddddYdZd[ZPdd5d\d]ZQdd5d^d_ZRdd5d`daZSdd5dbdcZTd#d5dddeZUdSdfdfddgdhdiZVdd5djdkZWdS )v    )annotations)LiteralcastN)	NoDefault
no_default)is_matching_na)SparseIndex)find_stack_level)is_boolis_categorical_dtypeis_extension_array_dtypeis_interval_dtype	is_numberis_numeric_dtypeneeds_i8_conversion)CategoricalDtypePandasDtype)array_equivalent)
Categorical	DataFrameDatetimeIndexIndexIntervalIndex
MultiIndexPeriodIndex
RangeIndexSeriesTimedeltaIndex)take_nd)DatetimeArrayExtensionArrayIntervalArrayPeriodArrayTimedeltaArray)DatetimeLikeArrayMixin)StringDtype)safe_sort_index)pprint_thingequivgh㈵>g:0yE>zbool | Literal['equiv']zbool | int | NoDefaultfloatNone)check_dtypecheck_less_precisertolatolreturnc                 K  s  |t ur&tjdtt d t| }}t| trNt| |fd|||d| nt| t	rvt
| |fd|||d| nt| trt| |fd|||d| nx|rt| rt|rnBt| rt|rn0t| tjst|tjrd}nd}t| ||d tj| |ft|||d	| d
S )a  
    Check that the left and right objects are approximately equal.

    By approximately equal, we refer to objects that are numbers or that
    contain numbers which may be equivalent to specific levels of precision.

    Parameters
    ----------
    left : object
    right : object
    check_dtype : bool or {'equiv'}, default 'equiv'
        Check dtype if both a and b are the same type. If 'equiv' is passed in,
        then `RangeIndex` and `Int64Index` are also considered equivalent
        when doing type checking.
    check_less_precise : bool or int, default False
        Specify comparison precision. 5 digits (False) or 3 digits (True)
        after decimal points are compared. If int, then specify the number
        of digits to compare.

        When comparing two numbers, if the first number has magnitude less
        than 1e-5, we compare the two numbers directly and check whether
        they are equivalent within the specified precision. Otherwise, we
        compare the **ratio** of the second number to the first number and
        check whether it is equivalent to 1 within the specified precision.

        .. deprecated:: 1.1.0
           Use `rtol` and `atol` instead to define relative/absolute
           tolerance, respectively. Similar to :func:`math.isclose`.
    rtol : float, default 1e-5
        Relative tolerance.

        .. versionadded:: 1.1.0
    atol : float, default 1e-8
        Absolute tolerance.

        .. versionadded:: 1.1.0
    The 'check_less_precise' keyword in testing.assert_*_equal is deprecated and will be removed in a future version. You can stop passing 'check_less_precise' to silence this warning.
stacklevelF)check_exactexactr-   r.   )r3   r+   r-   r.   numpy arrayInputobj)r+   r-   r.   N)r   warningswarnFutureWarningr	   _get_tol_from_less_precise
isinstancer   assert_index_equalr   assert_series_equalr   assert_frame_equalr   r
   npndarrayassert_class_equal_testingassert_almost_equalbool)leftrightr+   r,   r-   r.   kwargsr8    rJ   U/var/www/html/django/DPS/env/lib/python3.9/site-packages/pandas/_testing/asserters.pyrE   ?   sv    .





rE   z
bool | int)r,   r/   c                 C  s*   t | tr| rdS dS ndd|    S dS )ax  
    Return the tolerance equivalent to the deprecated `check_less_precise`
    parameter.

    Parameters
    ----------
    check_less_precise : bool or int

    Returns
    -------
    float
        Tolerance to be used as relative/absolute tolerance.

    Examples
    --------
    >>> # Using check_less_precise as a bool:
    >>> _get_tol_from_less_precise(False)
    5e-06
    >>> _get_tol_from_less_precise(True)
    0.0005
    >>> # Using check_less_precise as an int representing the decimal
    >>> # tolerance intended:
    >>> _get_tol_from_less_precise(2)
    0.005
    >>> _get_tol_from_less_precise(8)
    5e-09
    gMb@?gh㈵>g      ?
   N)r=   rF   )r,   rJ   rJ   rK   r<      s
    
r<   c                 C  sZ   |j }t| |s.t| d| dt|  dt||sVt| d| dt| ddS )a  
    Helper method for our assert_* methods that ensures that
    the two objects being compared have the right type before
    proceeding with the comparison.

    Parameters
    ----------
    left : The first object being compared.
    right : The second object being compared.
    cls : The class type to check against.

    Raises
    ------
    AssertionError : Either `left` or `right` is not an instance of `cls`.
    z Expected type z, found z insteadN)__name__r=   AssertionErrortype)rG   rH   clscls_namerJ   rJ   rK   _check_isinstance   s    

rR   TrF   )compare_keysr/   c                 C  s    t | |t tj| ||d d S )N)rS   )rR   dictrD   assert_dict_equal)rG   rH   rS   rJ   rJ   rK   rU      s    rU   r   z
bool | strstr)rG   rH   r4   check_namesr,   r3   check_categoricalcheck_orderr-   r.   r8   r/   c                   s  d}ddd fdd}dd }|t urHtjd	tt d
 t| }}	t| |t || ||
d | j|jkr|
 d}| j d|  }|j d| }t	|
||| t
| t
|kr|
 d}t
|  d|  }t
| d| }t	|
||| |st| } t|}| jdkrtt| } tt|}t| jD ]X}|| |}|||}d| d}t||||||	|d || j| |j| |
d q2|r r| |s4| j|jk}t|rtd|d}t|td t
|  }|
 dt|d d}t	|
|| | n&t}tj| j|j||	||
| |d |rJtd| ||
d t| t sbt|t rrtd| ||
d t| t!st|t!rt"| j|j  rt#| j$st#|j$rt%| j|j|
 dd dS )aj  
    Check that left and right Index are equal.

    Parameters
    ----------
    left : Index
    right : Index
    exact : bool or {'equiv'}, default 'equiv'
        Whether to check the Index class, dtype and inferred_type
        are identical. If 'equiv', then RangeIndex can be substituted for
        Int64Index as well.
    check_names : bool, default True
        Whether to check the names attribute.
    check_less_precise : bool or int, default False
        Specify comparison precision. Only used when check_exact is False.
        5 digits (False) or 3 digits (True) after decimal points are compared.
        If int, then specify the digits to compare.

        .. deprecated:: 1.1.0
           Use `rtol` and `atol` instead to define relative/absolute
           tolerance, respectively. Similar to :func:`math.isclose`.
    check_exact : bool, default True
        Whether to compare number exactly.
    check_categorical : bool, default True
        Whether to compare internal Categorical exactly.
    check_order : bool, default True
        Whether to compare the order of index entries as well as their values.
        If True, both indexes must contain the same elements, in the same order.
        If False, both indexes must contain the same elements, but in any order.

        .. versionadded:: 1.2.0
    rtol : float, default 1e-5
        Relative tolerance. Only used when check_exact is False.

        .. versionadded:: 1.1.0
    atol : float, default 1e-8
        Absolute tolerance. Only used when check_exact is False.

        .. versionadded:: 1.1.0
    obj : str, default 'Index'
        Specify object name being compared, internally used to show appropriate
        assertion message.

    Examples
    --------
    >>> from pandas import testing as tm
    >>> a = pd.Index([1, 2, 3])
    >>> b = pd.Index([1, 2, 3])
    >>> tm.assert_index_equal(a, b)
    Tr   r*   r/   c                   sz   sd S t | ||d td| ||d t| jrft|jrf rbtd| ||d t| j|jd d S td| ||d d S )N)r4   r8   inferred_typer7   dtype)r4   )rC   assert_attr_equalr   r\   r>   
categoriesrG   rH   r8   rX   r4   rJ   rK   _check_types9  s    z(assert_index_equal.<locals>._check_typesc                 S  s:   | j | }| j| }t|j||jd}|j|| j| dS )N)
fill_value)name)levelscodesr   _values	_na_value_shallow_copynames)indexleveluniquelevel_codesfilledrJ   rJ   rK   _get_ilevel_valuesI  s    

z.assert_index_equal.<locals>._get_ilevel_valuesr0   r1   r7   z levels are different, z length are different   zMultiIndex level [])r4   rW   r3   r-   r.   r8   r          Y@ values are different (    %))r-   r.   r+   r8   lobjZrobjri   freq	 categoryN)r   )&r   r9   r:   r;   r	   r<   rR   r   nlevelsraise_assert_detaillenr&   r   r   ranger>   rd   equalsrf   r   fillnarA   sumastypeintroundrF   rD   rE   valuesr]   r=   r   r   assert_interval_array_equalr   r\   assert_categorical_equal)rG   rH   r4   rW   r,   r3   rX   rY   r-   r.   r8   __tracebackhide__ra   ro   msg1msg2Zmsg3rk   ZllevelZrlevelrw   mismatchdiffmsgZ
exact_boolrJ   r`   rK   r>      s    ?






r>   r6   )r4   r/   c                 C  sp   ddl m} d}dd }t| t|kr,dS |dkrLt| |rLt||rLdS | d}t|||| || dS )	z#
    Checks classes are equal.
    r   )NumericIndexTc                 S  s   t | tr| S t| jS )N)r=   r   rO   rM   )xrJ   rJ   rK   
repr_class  s    
z&assert_class_equal.<locals>.repr_classNr(   z classes are different)pandas.core.indexes.numericr   rO   r=   r{   )rG   rH   r4   r8   r   r   r   r   rJ   rJ   rK   rC     s    
rC   
Attributes)attrr8   r/   c           	      C  s   d}t || }t || }||u s*t||r.dS z||k}W n tyP   d}Y n0 |tju |tju A rld}nt|ts~| }|sd|  d}t|||| dS )aO  
    Check attributes are equal. Both objects must have attribute.

    Parameters
    ----------
    attr : str
        Attribute name being compared.
    left : object
    right : object
    obj : str, default 'Attributes'
        Specify object name being compared, internally used to show appropriate
        assertion message
    TNFzAttribute "z" are different)	getattrr   	TypeErrorpdNAr=   rF   allr{   )	r   rG   rH   r8   r   Z	left_attrZ
right_attrresultr   rJ   rJ   rK   r]     s"    



r]   rZ   c                 C  s   dd l m} t| ttjfrX|  D ]0}dtt|j	 }t||j
tfs$J |q$n.dtt| j	 }t| |jttfsJ |d S )Nr   zBone of 'objs' is not a matplotlib Axes instance, type encountered zoobjs is neither an ndarray of Artist instances nor a single ArtistArtist instance, tuple, or dict, 'objs' is a )matplotlib.pyplotpyplotr=   r   rA   rB   ravelreprrO   rM   AxesrT   Artisttuple)objspltelr   rJ   rJ   rK   "assert_is_valid_plot_return_object  s    r   c                 C  s.   t | ttfr| j} t| tt|  dS )z#Assert that the sequence is sorted.N)r=   r   r   r   assert_numpy_array_equalrA   sortarray)seqrJ   rJ   rK   assert_is_sorted  s    r   r   c                 C  s   t | |t t| jts$t|jtr*d}nd}|rht| j|j| d|d t| j|j|| dd nzz| j }|j }W n  t	y   | j|j }}Y n0 t||| d|d t| j
| j|j
|j| d|d td| ||d	 d
S )a}  
    Test that Categoricals are equivalent.

    Parameters
    ----------
    left : Categorical
    right : Categorical
    check_dtype : bool, default True
        Check that integer dtype of the codes are the same.
    check_category_order : bool, default True
        Whether the order of the categories should be compared, which
        implies identical integer codes.  If False, only the resulting
        values are compared.  The ordered attribute is
        checked regardless.
    obj : str, default 'Categorical'
        Specify object name being compared, internally used to show appropriate
        assertion message.
    r(   Tz.categories)r8   r4   z.codesr+   r8   z.valuesorderedr7   N)rR   r   r=   r^   r   r>   r   re   sort_valuesr   taker]   )rG   rH   r+   check_category_orderr8   r4   lcrcrJ   rJ   rK   r     s4    
r   r!   c                 C  sz   t | |t i }| jjjdv r&d|d< t| j|jfd| di| t| j|jfd| di| td| ||d dS )	a  
    Test that two IntervalArrays are equivalent.

    Parameters
    ----------
    left, right : IntervalArray
        The IntervalArrays to compare.
    exact : bool or {'equiv'}, default 'equiv'
        Whether to check the Index class, dtype and inferred_type
        are identical. If 'equiv', then RangeIndex can be substituted for
        Int64Index as well.
    obj : str, default 'IntervalArray'
        Specify object name being compared, internally used to show appropriate
        assertion message
    )mMF
check_freqr8   z.leftclosedr7   N)rR   r!   _leftr\   kindassert_equal_rightr]   )rG   rH   r4   r8   rI   rJ   rJ   rK   r   H  s      r   r"   c                 C  s8   t | |t t| j|j| dd td| ||d d S )N._datar7   rx   )rR   r"   r   _datar]   r_   rJ   rJ   rK   assert_period_array_equalg  s    r   r   c                 C  sP   d}t | |t t| j|j| dd |r<td| ||d td| ||d d S )NTr   r7   rx   tz)rR   r   r   r   r]   rG   rH   r8   r   r   rJ   rJ   rK   assert_datetime_array_equaln  s    r   r#   c                 C  s@   d}t | |t t| j|j| dd |r<td| ||d d S )NTr   r7   rx   )rR   r#   r   r   r]   r   rJ   rJ   rK   assert_timedelta_array_equalz  s
    r   c                 C  s   d}|  d| }t |tjr0|dt| 7 }t |tjrFt|}n&t |tsdt |tsdt |trlt|}t |tjrt|}n&t |tst |tst |trt|}|d| d| 7 }|d ur|d| 7 }t|d S )NTz are different

z

[index]: z

[left]:  z

[right]: z	
[diff]: )	r=   rA   rB   r'   r   r   r%   r   rN   )r8   messagerG   rH   r   index_valuesr   r   rJ   rJ   rK   r{     s@    

r{   Fr5   )r+   r/   c                   s   d}t | |d t| |tj dd }	|	| }
|	|}|dkrd|
|urtt|
 dt| n*|dkr|
|u rtt|
 dt|  fd	d
}t| |ds|| || |rt| tjrt|tjrtd| |d dS )a+  
    Check that 'np.ndarray' is equivalent.

    Parameters
    ----------
    left, right : numpy.ndarray or iterable
        The two arrays to be compared.
    strict_nan : bool, default False
        If True, consider NaN and None to be different.
    check_dtype : bool, default True
        Check dtype if both a and b are np.ndarray.
    err_msg : str, default None
        If provided, used as assertion message.
    check_same : None|'copy'|'same', default None
        Ensure left and right refer/do not refer to the same memory area.
    obj : str, default 'numpy array'
        Specify object name being compared, internally used to show appropriate
        assertion message.
    index_values : numpy.ndarray, default None
        optional index (shared by both left and right), used in output.
    Tr7   c                 S  s   t | dd d ur| jS | S )Nbase)r   r   r7   rJ   rJ   rK   	_get_base  s    z+assert_numpy_array_equal.<locals>._get_basesamez is not copyz is c                   s   |d u r| j |j kr,t d| j |j  d}t| |D ]\}}t||ds:|d7 }q:|d | j } dt|d d}t|| | d	 t|d S )
Nz shapes are differentr   
strict_nanrq   rs   rt   ru   rv   r   )shaper{   zipr   sizerA   r   rN   )rG   rH   err_msgr   Zleft_arrZ	right_arrr   r   r8   r   rJ   rK   _raise  s    
z(assert_numpy_array_equal.<locals>._raiser   r\   N)	rC   rR   rA   rB   rN   r   r   r=   r]   )rG   rH   r   r+   r   
check_samer8   r   r   r   Z	left_baseZ
right_baser   rJ   r   rK   r     s$    r   )r+   r-   r.   r/   c              	   C  s,  |t ur&tjdtt d t| }}t| ts8J dt|tsJJ d|r^td| |dd t| t	rt|t	rt
|t
| krtt| jt|j|d d	S t|  }t| }	t||	d
|d | |  jtd}
||	  jtd}|rt|
|d|d ntj|
|t|||d|d d	S )a  
    Check that left and right ExtensionArrays are equal.

    Parameters
    ----------
    left, right : ExtensionArray
        The two arrays to compare.
    check_dtype : bool, default True
        Whether to check if the ExtensionArray dtypes are identical.
    index_values : numpy.ndarray, default None
        Optional index (shared by both left and right), used in output.
    check_less_precise : bool or int, default False
        Specify comparison precision. Only used when check_exact is False.
        5 digits (False) or 3 digits (True) after decimal points are compared.
        If int, then specify the digits to compare.

        .. deprecated:: 1.1.0
           Use `rtol` and `atol` instead to define relative/absolute
           tolerance, respectively. Similar to :func:`math.isclose`.
    check_exact : bool, default False
        Whether to compare number exactly.
    rtol : float, default 1e-5
        Relative tolerance. Only used when check_exact is False.

        .. versionadded:: 1.1.0
    atol : float, default 1e-8
        Absolute tolerance. Only used when check_exact is False.

        .. versionadded:: 1.1.0

    Notes
    -----
    Missing values are checked separately from valid values.
    A mask of missing values is computed for each and checked to match.
    The remaining all-valid values are cast to object dtype and checked.

    Examples
    --------
    >>> from pandas import testing as tm
    >>> a = pd.Series([1, 2, 3, 4])
    >>> b, c = a.array, a.array
    >>> tm.assert_extension_array_equal(b, c)
    r0   r1   zleft is not an ExtensionArrayzright is not an ExtensionArrayr\   r    r7   r   NzExtensionArray NA mask)r8   r   )r\   )r+   r-   r.   r8   r   )r   r9   r:   r;   r	   r<   r=   r    r]   r$   rO   r   rA   asarrayasi8isnato_numpyobjectrD   rE   rF   )rG   rH   r+   r   r,   r3   r-   r.   Zleft_naZright_naZ
left_validZright_validrJ   rJ   rK   assert_extension_array_equal  sR    5r   r   )check_index
check_like)r+   check_index_typer,   r/   c                C  s
  d}|s|rt d|tur:tjdtt d t| }}t| |t |rXt	| ||d t
| t
|krt
|  d| j }t
| d|j }t|d|| |r| j|jksJ t| j dt|j |rt| j|j||||	| ||| d	d

 |r| || } }|rPt| jttfrP| j}|j}|j|jksPJ |j|jf|rt| jtrzt|jtrz|	szntd| |d| d |rt| jrt|jr| j}|j}t|trt|trt|||t| jd nt|||t|t| jd n|rft | js,t |jrft!| j"t!|jsd| j d|j d}t#|nNt$| jrt$|jrt%| j&|j& n$t| jtst|jtrt'j(| j|j||t)|t|t| jd nt*| jrt*|jrt| j|j|||t| jd nt+| j|js4t+|j| jrRt| j|j|t| jd nbt | jrt |jrt| j|j|t| jd n,t'j(| j|j||t)|t|t| jd |rtd| ||d |	rt| jtst|jtrt,| j|j| d|
d dS )a  
    Check that left and right Series are equal.

    Parameters
    ----------
    left : Series
    right : Series
    check_dtype : bool, default True
        Whether to check the Series dtype is identical.
    check_index_type : bool or {'equiv'}, default 'equiv'
        Whether to check the Index class, dtype and inferred_type
        are identical.
    check_series_type : bool, default True
         Whether to check the Series class is identical.
    check_less_precise : bool or int, default False
        Specify comparison precision. Only used when check_exact is False.
        5 digits (False) or 3 digits (True) after decimal points are compared.
        If int, then specify the digits to compare.

        When comparing two numbers, if the first number has magnitude less
        than 1e-5, we compare the two numbers directly and check whether
        they are equivalent within the specified precision. Otherwise, we
        compare the **ratio** of the second number to the first number and
        check whether it is equivalent to 1 within the specified precision.

        .. deprecated:: 1.1.0
           Use `rtol` and `atol` instead to define relative/absolute
           tolerance, respectively. Similar to :func:`math.isclose`.
    check_names : bool, default True
        Whether to check the Series and Index names attribute.
    check_exact : bool, default False
        Whether to compare number exactly.
    check_datetimelike_compat : bool, default False
        Compare datetime-like which is comparable ignoring dtype.
    check_categorical : bool, default True
        Whether to compare internal Categorical exactly.
    check_category_order : bool, default True
        Whether to compare category order of internal Categoricals.

        .. versionadded:: 1.0.2
    check_freq : bool, default True
        Whether to check the `freq` attribute on a DatetimeIndex or TimedeltaIndex.

        .. versionadded:: 1.1.0
    check_flags : bool, default True
        Whether to check the `flags` attribute.

        .. versionadded:: 1.2.0

    rtol : float, default 1e-5
        Relative tolerance. Only used when check_exact is False.

        .. versionadded:: 1.1.0
    atol : float, default 1e-8
        Absolute tolerance. Only used when check_exact is False.

        .. versionadded:: 1.1.0
    obj : str, default 'Series'
        Specify object name being compared, internally used to show appropriate
        assertion message.
    check_index : bool, default True
        Whether to check index equivalence. If False, then compare only values.

        .. versionadded:: 1.3.0
    check_like : bool, default False
        If True, ignore the order of the index. Must be False if check_index is False.
        Note: same labels must be with the same data.

        .. versionadded:: 1.5.0

    Examples
    --------
    >>> from pandas import testing as tm
    >>> a = pd.Series([1, 2, 3, 4])
    >>> b = pd.Series([1, 2, 3, 4])
    >>> tm.assert_series_equal(a, b)
    Tz0check_like must be False if check_index is Falser0   r1   r7   rp   zSeries length are different != .indexr4   rW   r3   rX   rY   r-   r.   r8   r\   zAttributes of )r+   r   )r+   r8   r   z[datetimelike_compat=True] z is not equal to .)r-   r.   r+   r8   r   )r-   r.   r+   r   rc   ry   )r8   r   N)-
ValueErrorr   r9   r:   r;   r	   r<   rR   r   rC   r|   rj   r{   flagsr   r>   reindex_liker=   r   r   rx   r\   r   r]   r   rf   r    r   rA   r   r   rV   r   r   r~   rN   r   r   r   rD   rE   rF   r   0is_extension_array_dtype_and_needs_i8_conversionr   )rG   rH   r+   r   Zcheck_series_typer,   rW   r3   check_datetimelike_compatrX   r   r   check_flagsr-   r.   r8   r   r   r   r   r   lidxridxleft_valuesright_valuesr   rJ   rJ   rK   r?   c  s   b*




	

	



r?   r   )r+   r   r/   c                 C  s  d}|t ur*tjdtt d t| }}t| |t |rLt| t	|sLJ | j
|j
kr|t|| dt| j
 t|j
  |r| j|jksJ t| j dt|j t| j|j|||	|| ||| dd
 t| j|j|||	|| ||| dd
 |r| || } }|r| }|  }ttt| t|  D ]:}||v sXJ ||v sfJ t|| || ||d	 qFnht| jD ]\\}}| j|d
d}|j|d
d}t|||||	||
||| d| d| d||ddd qdS )a~  
    Check that left and right DataFrame are equal.

    This function is intended to compare two DataFrames and output any
    differences. It is mostly intended for use in unit tests.
    Additional parameters allow varying the strictness of the
    equality checks performed.

    Parameters
    ----------
    left : DataFrame
        First DataFrame to compare.
    right : DataFrame
        Second DataFrame to compare.
    check_dtype : bool, default True
        Whether to check the DataFrame dtype is identical.
    check_index_type : bool or {'equiv'}, default 'equiv'
        Whether to check the Index class, dtype and inferred_type
        are identical.
    check_column_type : bool or {'equiv'}, default 'equiv'
        Whether to check the columns class, dtype and inferred_type
        are identical. Is passed as the ``exact`` argument of
        :func:`assert_index_equal`.
    check_frame_type : bool, default True
        Whether to check the DataFrame class is identical.
    check_less_precise : bool or int, default False
        Specify comparison precision. Only used when check_exact is False.
        5 digits (False) or 3 digits (True) after decimal points are compared.
        If int, then specify the digits to compare.

        When comparing two numbers, if the first number has magnitude less
        than 1e-5, we compare the two numbers directly and check whether
        they are equivalent within the specified precision. Otherwise, we
        compare the **ratio** of the second number to the first number and
        check whether it is equivalent to 1 within the specified precision.

        .. deprecated:: 1.1.0
           Use `rtol` and `atol` instead to define relative/absolute
           tolerance, respectively. Similar to :func:`math.isclose`.
    check_names : bool, default True
        Whether to check that the `names` attribute for both the `index`
        and `column` attributes of the DataFrame is identical.
    by_blocks : bool, default False
        Specify how to compare internal data. If False, compare by columns.
        If True, compare by blocks.
    check_exact : bool, default False
        Whether to compare number exactly.
    check_datetimelike_compat : bool, default False
        Compare datetime-like which is comparable ignoring dtype.
    check_categorical : bool, default True
        Whether to compare internal Categorical exactly.
    check_like : bool, default False
        If True, ignore the order of index & columns.
        Note: index labels must match their respective rows
        (same as in columns) - same labels must be with the same data.
    check_freq : bool, default True
        Whether to check the `freq` attribute on a DatetimeIndex or TimedeltaIndex.

        .. versionadded:: 1.1.0
    check_flags : bool, default True
        Whether to check the `flags` attribute.
    rtol : float, default 1e-5
        Relative tolerance. Only used when check_exact is False.

        .. versionadded:: 1.1.0
    atol : float, default 1e-8
        Absolute tolerance. Only used when check_exact is False.

        .. versionadded:: 1.1.0
    obj : str, default 'DataFrame'
        Specify object name being compared, internally used to show appropriate
        assertion message.

    See Also
    --------
    assert_series_equal : Equivalent method for asserting Series equality.
    DataFrame.equals : Check DataFrame equality.

    Examples
    --------
    This example shows comparing two DataFrames that are equal
    but with columns of differing dtypes.

    >>> from pandas.testing import assert_frame_equal
    >>> df1 = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
    >>> df2 = pd.DataFrame({'a': [1, 2], 'b': [3.0, 4.0]})

    df1 equals itself.

    >>> assert_frame_equal(df1, df1)

    df1 differs from df2 as column 'b' is of a different type.

    >>> assert_frame_equal(df1, df2)
    Traceback (most recent call last):
    ...
    AssertionError: Attributes of DataFrame.iloc[:, 1] (column name="b") are different

    Attribute "dtype" are different
    [left]:  int64
    [right]: float64

    Ignore differing dtypes in columns with check_dtype.

    >>> assert_frame_equal(df1, df2, check_dtype=False)
    Tr0   r1   z shape mismatchr   r   r   z.columnsr   rq   )axisz	.iloc[:, z] (column name="z")F)r+   r   r3   rW   r   rX   r   r8   r-   r.   r   r   N)r   r9   r:   r;   r	   r<   rR   r   r=   rO   r   r{   r   r   r>   rj   columnsr   _to_dict_of_blockslistsetkeysr@   	enumerate_ixsr?   )rG   rH   r+   r   Zcheck_column_typeZcheck_frame_typer,   rW   Z	by_blocksr3   r   rX   r   r   r   r-   r.   r8   r   ZrblocksZlblocksr\   icolZlcolZrcolrJ   rJ   rK   r@   o  s    ~*$r@   c                 K  s  d}t | trNt| |fi | t | ttfrJ| j|jksJJ | j|jfn<t | trnt| |fi | nt | trt	| |fi | nt | t
rt| |fi | nt | trt| |fi | nt | trt| |fi | nt | trt| |fi | nt | tr&t| |fi | ndt | tjrHt| |fi | nBt | trr|i ksbJ | |ksJ n|i ksJ t| | dS )aC  
    Wrapper for tm.assert_*_equal to dispatch to the appropriate test function.

    Parameters
    ----------
    left, right : Index, Series, DataFrame, ExtensionArray, or np.ndarray
        The two items to be compared.
    **kwargs
        All keyword arguments are passed through to the underlying assert method.
    TN)r=   r   r>   r   r   rx   r   r?   r   r@   r!   r   r"   r   r   r   r#   r   r    r   rA   rB   r   rV   rE   )rG   rH   rI   r   rJ   rJ   rK   r   Q  s4    
 




r   c                 C  s   t | |tjj t| j|j t| jts.J t|jts>J | j}|j}|	|sdt
dd|| n td| | td| | t|  |  dS )z
    Check that the left and right SparseArray are equal.

    Parameters
    ----------
    left : SparseArray
    right : SparseArray
    zSparseArray.indexzindex are not equalrb   r\   N)rR   r   arraysSparseArrayr   	sp_valuesr=   sp_indexr   r~   r{   r]   to_dense)rG   rH   
left_indexright_indexrJ   rJ   rK   assert_sp_array_equalz  s    	
r   c                 C  s(   | D ]}||v sJ dt | qd S )NzDid not contain item: )r   )iterableZdickrJ   rJ   rK   assert_contains_all  s    r   c                 K  s\   t | |D ]L\}}t||fi | dtt| dtt| d}||us
J |q
dS )z
    iter1, iter2: iterables that produce elements
    comparable with assert_almost_equal

    Checks that the elements are equal, but not
    the same object. (Does not check that items
    in sequences are also not the same object)
    zExpected object z and object z8 to be different objects, but they were the same object.N)r   rE   r   rO   )Ziter1Ziter2Z
eql_kwargsZelem1Zelem2r   rJ   rJ   rK   assert_copy  s
    	 r   c                 C  s   t | ot|S )z
    Checks that we have the combination of an ExtensionArraydtype and
    a dtype that should be converted to int64

    Returns
    -------
    bool

    Related to issue #37609
    )r   r   )Z
left_dtypeZright_dtyperJ   rJ   rK   r     s    r   slice)serl_slci_slcr/   c                 C  s6   | j | }t| j| | | j s2t| | | dS )z_
    Check that ser.iloc[i_slc] matches ser.loc[l_slc] and, if applicable,
    ser[l_slc].
    N)ilocr?   locrj   
is_integer)r   r   r   expectedrJ   rJ   rK   !assert_indexing_slices_equivalent  s    

r  c                 C  sF   | j D ]:}t| |d}|du r,|du s@J q|t||dksJ qdS )z:
    Check that ._metadata attributes are equivalent.
    N)	_metadatar   )rG   rH   r   valrJ   rJ   rK   assert_metadata_equivalent  s
    
r  )T)Tr6   )r   )TTr   )r(   r!   )r"   )r   T)r#   T)NN)FTNNr5   N)X
__future__r   typingr   r   r9   numpyrA   pandas._libs.libr   r   pandas._libs.missingr   pandas._libs.sparser   Zpandas._libs.testing_libstestingrD   pandas.util._exceptionsr	   pandas.core.dtypes.commonr
   r   r   r   r   r   r   pandas.core.dtypes.dtypesr   r   pandas.core.dtypes.missingr   pandasr   r   r   r   r   r   r   r   r   r   r   pandas.core.algorithmsr   pandas.core.arraysr   r    r!   r"   r#   Zpandas.core.arrays.datetimeliker$   pandas.core.arrays.string_r%   pandas.core.indexes.apir&   pandas.io.formats.printingr'   rE   r<   rR   rU   r>   rC   r]   r   r   r   r   r   r   r   r{   r   r   r?   r@   r   r   r   r   r   r  r  rJ   rJ   rJ   rK   <module>   s   $	0o(	& ;'	 :   

)      Sl   c)!