o
    i/                  
   @   s  d dl Z d dlZd dlmZ d dlmZ e jddgddd Ze jdd	gdd
d Z	dd Z
dd Zdd Ze jdddgdd Ze jdedg diedg difeg dg ddedg difgdd Ze jdejddgd d!gd"d#gd$ejd%d&gd d!gd"d#gd$d'fejddgd(d)gd d!gd*d#d+gd$ejd%d&gd(d)gd d!gd*d#d+gd$d,fgd-d. Zd/d0 Ze jdddgd1d2 Ze jdddgd3d4 Zd5d6 Ze jdeg d7g d8d9eg d7g d:d9d;feg d7g d8d9eg d<g d=d9d>fgd?d@ ZdAdB ZdCdD Ze jdEdFdGgdHdI Ze jdJg dKdLdM ZdNdO ZdPdQ ZdRdS Ze jdTdUdVgdWdX ZdYdZ Z d[d\ Z!d]d^ Z"dS )_    N)	DataFrameTF)paramsc                 C      | j S Nparamrequest r
   d/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/pandas/tests/util/test_assert_frame_equal.pyby_blocks_fixture      r   r   Seriesc                 C   r   r   r   r   r
   r
   r   obj_fixture   r   r   c                 K   s,   t j| |fi | t j|| fi | dS )a4  
    Check that two DataFrame equal.

    This check is performed commutatively.

    Parameters
    ----------
    a : DataFrame
        The first DataFrame to compare.
    b : DataFrame
        The second DataFrame to compare.
    kwargs : dict
        The arguments passed to `tm.assert_frame_equal`.
    N)tmassert_frame_equalabkwargsr
   r
   r   _assert_frame_equal_both   s   r   c                 K   sL   d}t jt|d tj| |fi | W d   dS 1 sw   Y  dS )a  
    Check that two DataFrame are not equal.

    Parameters
    ----------
    a : DataFrame
        The first DataFrame to compare.
    b : DataFrame
        The second DataFrame to compare.
    kwargs : dict
        The arguments passed to `tm.assert_frame_equal`.
    z;The two DataFrames were equal when they shouldn't have beenmatchNpytestraisesAssertionErrorr   r   )r   r   r   msgr
   r
   r   _assert_not_frame_equal%   s   "r   c                 K   s(   t | |fi | t || fi | dS )a<  
    Check that two DataFrame are not equal.

    This check is performed commutatively.

    Parameters
    ----------
    a : DataFrame
        The first DataFrame to compare.
    b : DataFrame
        The second DataFrame to compare.
    kwargs : dict
        The arguments passed to `tm.assert_frame_equal`.
    N)r   r   r
   r
   r   _assert_not_frame_equal_both7   s   r   
check_likec                 C   s   t g dg ddg dd}t g dg ddg dd}| sH| d	}tjt|d
 tj||| |d W d    d S 1 sAw   Y  d S t||| |d d S )N                  ABr   r   cindex)r$   r#   r"   )r(   r'   r&   r-   r   r   z.index are differentr   r    obj)r   r   r   r   r   r   r   )r    r   df1df2r   r
   r
   r   #test_frame_equal_row_order_mismatchJ   s   
"r5   zdf1,df2r*   r!   )r"   r#   r$   r&   r%   r)   c                 C   sN   | d}t jt|d tj| ||d W d    d S 1 s w   Y  d S )Nz are differentr   r2   r   )r3   r4   r   r   r
   r
   r   test_frame_equal_shape_mismatchW   s   
"r7   zdf1,df2,msgr"   r#   l1l2)r   r-   r   r.   g      ?g       @zDataFrame\.index are differentg @g      ?r,   r   z$MultiIndex level \[0\] are differentc                 C   sl   d|i}|r*t jt|d tj| |fi | W d    d S 1 s#w   Y  d S tj| |fi | d S )Ncheck_index_typer   r   )r3   r4   r   r:   r   r
   r
   r   %test_frame_equal_index_dtype_mismatche   s   "r;   c                 C   s   ddg}t |d}t |d}d| i}|d d|d< | rCd}tjt|d tj||fi | W d    d S 1 s<w   Y  d S tj||fi | d S )Ncol1col2)columnscheck_dtypeint64z)Attributes of DataFrame\..* are differentr   )r   astyper   r   r   r   r   )r?   r>   r3   r4   r   r   r
   r
   r   test_empty_dtypes   s   

"rB   c                 C   s   | d| d}t g dg ddg dd}t g dg ddg dd}tjt|d	 tj||| |d
 W d    d S 1 sBw   Y  d S )Nz\.index are different

z\.index values are different \(33\.33333 %\)
\[left\]:  Index\(\['a', 'b', 'c'\], dtype='object'\)
\[right\]: Index\(\['a', 'b', 'd'\], dtype='object'\)r!   r%   r)   r,   r.   )r   r   dr   r1   r   r   r   r   r   r   r    r   r   r3   r4   r
   r
   r   test_frame_equal_index_mismatch      "rF   c                 C   s   | d| d}t g dg ddg dd}t g dg ddg dd}tjt|d	 tj||| |d
 W d    d S 1 sBw   Y  d S )Nz\.columns are different

z\.columns values are different \(50\.0 %\)
\[left\]:  Index\(\['A', 'B'\], dtype='object'\)
\[right\]: Index\(\['A', 'b'\], dtype='object'\)r!   r%   r)   r,   r.   )r*   r   r   r1   rD   rE   r
   r
   r   !test_frame_equal_columns_mismatch   rG   rH   c                 C   s   |}| d| d}t g dg dd}t g dg dd}tjt|d tj||| |d W d    d S 1 s<w   Y  d S )	Nz2\.iloc\[:, 1\] \(column name="B"\) are different

z\.iloc\[:, 1\] \(column name="B"\) values are different \(33\.33333 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \[4, 5, 6\]
\[right\]: \[4, 5, 7\]r!   r%   r)   )r&   r'      r   	by_blocksr2   rD   )r   r   r2   r   r3   r4   r
   r
   r   test_frame_equal_block_mismatch   s   "rL   )   á   à   ä)   é   è   ë)r*   E)rP   rQ   u   e̊u   {obj}\.iloc\[:, 1\] \(column name="E"\) are different

{obj}\.iloc\[:, 1\] \(column name="E"\) values are different \(33\.33333 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \[é, è, ë\]
\[right\]: \[é, è, e̊\])r   r   r   )erT   rT   u   {obj}\.iloc\[:, 0\] \(column name="A"\) are different

{obj}\.iloc\[:, 0\] \(column name="A"\) values are different \(100\.0 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \[á, à, ä\]
\[right\]: \[a, a, a\]c                 C   sR   |j |d}tjt|d tj| |||d W d    d S 1 s"w   Y  d S )Nr6   r   rJ   )formatr   r   r   r   r   )r3   r4   r   r   r   r
   r
   r   test_frame_equal_unicode   s   "rV   c                  C   sv   t dg didd} | t}d}tj| |dd tjt|d tj| |d	d W d    d S 1 s4w   Y  d S )
Nr   r!   Int64dtypezAttributes of DataFrame\.iloc\[:, 0\] \(column name="a"\) are different

Attribute "dtype" are different
\[left\]:  Int64
\[right\]: int[32|64]Fr?   r   T)r   rA   intr   r   r   r   r   leftrightr   r
   r
   r   0test_assert_frame_equal_extension_dtype_mismatch   s   
"r_   c                  C   s|   t dtddgidd} | t}d}tj| |dd tjt	|d	 tj| |d
d W d    d S 1 s7w   Y  d S )Nr   r   r"   intervalrX   zAttributes of DataFrame\.iloc\[:, 0\] \(column name="a"\) are different

Attribute "dtype" are different
\[left\]:  interval\[int64, right\]
\[right\]: objectFrZ   r   T)
r   pdIntervalrA   objectr   r   r   r   r   r\   r
   r
   r   /test_assert_frame_equal_interval_dtype_mismatch   s   
"rd   right_dtypeInt32r@   c                 C   s<   t dg didd}t dg di| d}tj||dd d S )Nr   r!   rW   rX   FrZ   r   r   r   )re   r]   r^   r
   r
   r   7test_assert_frame_equal_ignore_extension_dtype_mismatch  s   rh   rY   )ztimedelta64[ns]zdatetime64[ns, UTC]z	Period[D]c                 C   s0   t dg i| d}t dg i}tj||dd d S )Nr   rX   FrZ   rg   )rY   r3   r4   r
   r
   r   4test_assert_frame_equal_datetime_like_dtype_mismatch  s   	ri   c                  C   s   t  } t  jdd}t| |  t|| tj| |dd tj|| dd tjtdd t| | W d    n1 s>w   Y  tjtdd t| | W d    d S 1 s\w   Y  d S )NF)allows_duplicate_labelscheck_flagsz<Flagsr   )r   	set_flagsr   r   r   r   r   r]   r^   r
   r
   r   test_allows_duplicate_labels!  s   "ro   c                  C   s0   t g dgg dg dd} tj| | dd d S )N)r   r"   r#   )foobar*   )r"   testr#   )r>   r/   Tr    rg   )dfr
   r
   r   +test_assert_frame_equal_columns_mixed_dtype0  s   rv   c                 C   s$   | ddg|d}t j||dd d S )Nr"   r#   rX   T)check_exact)r   assert_equal)frame_or_seriesany_numeric_ea_dtyper2   r
   r
   r    test_frame_equal_extension_dtype6  s   r{   indexer)r   r"   )r"   r   c                 C   s   |df}| ddg||d  d}| ddg||d  d}d}t jt|d tj||dd	d
 W d    d S 1 s:w   Y  d S )Nr@   r"   r#   r   rX   zI(Series|DataFrame.iloc\[:, 0\] \(column name="0"\) classes) are differentr   TF)rw   r?   )r   r   r   r   rx   )ry   rz   r|   dtypesobj1obj2r   r
   r
   r   test_frame_equal_mixed_dtypes<  s   "r   c                  C   sn   t tjg ddd} t tjddddd}tjtdd tj| |d	d
 W d    d S 1 s0w   Y  d S )Nrc   rX   r.   r   r"   )startstopstepzDataFrame.index are differentr   Trt   )	r   ra   Index
RangeIndexr   r   r   r   r   )r3   r4   r
   r
   r   4test_assert_frame_equal_check_like_different_indexesF  s
   "r   c                  C   s   t ddgddgg} d| j_t ddgddgg}d|j_tj| |dd tjtdd	 tj| |dd W d    d S 1 s?w   Y  d S )
Nr"   r#   r$   r&   FTrk   rj   r   )r   flagsrj   r   r   r   r   r   rn   r
   r
   r   0test_assert_frame_equal_checking_allow_dups_flagN  s   "r   c               	   C   s   t dgdgdggtjtg dtg dgd} t dgdgdggtjtg dtg dgd}tj| |dd d S )	Nr"   r#   r$   r,   r.   r0   Trt   )r   ra   
MultiIndexfrom_arraysCategoricalr   r   rn   r
   r
   r   3test_assert_frame_equal_check_like_categorical_midx[  s"   		r   )#r   pandasra   r   pandas._testing_testingr   fixturer   r   r   r   r   markparametrizer5   r7   from_recordsr;   rB   rF   rH   rL   rV   r_   rd   rh   ri   ro   rv   r{   r   r   r   r   r
   r
   r
   r   <module>   s    


$









	