3
Ud"              	   @   sV  d dl Z d dlZd dlmZ d dlj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jdddgdd Ze jjdeddddgiedddddgifedddgdddgdeddddgifgdd Ze j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d0d1 Zd2d3 Zd4d5 Zd6d7 Ze jjd ed8d9d:gd;d<d=gd>ed8d9d:gd;d<d?gd>d@fed8d9d:gd;d<d=gd>ed$d$d$gdAdAdAgd>dBfgdCdD ZdEdF ZdGdH Ze jjdIdJdKgdLdM ZdS )N    N)	DataFrameTF)paramsc             C   s   | j S )N)param)request r   ]/var/www/html/virt/lib64/python3.6/site-packages/pandas/tests/util/test_assert_frame_equal.pyby_blocks_fixture   s    r   r   ZSeriesc             C   s   | j S )N)r   )r   r   r   r   obj_fixture   s    r	   c             K   s$   t j| |f| t j|| f| 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   s2   d}t jt|d tj| |f| W dQ R X 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| t || f| 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   r   r   _assert_not_frame_equal_both7   s    r   
check_likec             C   s   t dddgdddgddd	d
gd}t dddgdddgdd
d	dgd}| s| d}tjt|d tj||| |d W d Q R X nt||| |d d S )N                  )ABr   r   c)indexz.index are different)r   )r   obj)r   r   r   r   r
   r   r   )r   r	   df1df2r   r   r   r   #test_frame_equal_row_order_mismatchJ   s    $$
r%   zdf1,df2r   r   r   r   r   r   r   )r   r   c             C   s8   | d}t jt|d tj| ||d W d Q R X d S )Nz are different)r   )r"   )r   r   r   r
   r   )r#   r$   r	   r   r   r   r   test_frame_equal_shape_mismatchW   s    
r&   zdf1,df2,msgl1l2)r   r    r   )r!   g      ?g       @zDataFrame\.index are differentg @g      ?)r   r   r    r   z$MultiIndex level \[0\] are differentc          
   C   sN   t |d}|r:tjt|d tj| |f| W d Q R X ntj| |f| d S )N)check_index_type)r   )dictr   r   r   r
   r   )r#   r$   r   r)   r   r   r   r   %test_frame_equal_index_dtype_mismatche   s
    
r+   c          
   C   s   ddg}t |d}t |d}t| d}|d jd|d< | rld}tjt|d tj||f| W d Q R X ntj||f| d S )NZcol1Zcol2)columns)check_dtypeint64z)Attributes of DataFrame\..* are different)r   )r   r*   astyper   r   r   r
   r   )r-   r,   r#   r$   r   r   r   r   r   test_empty_dtypes   s    


r0   c             C   s   |  d|  d}t dddgdddgd	d
ddgd}t dddgdddgd	d
ddgd}tjt|d tj||| d W d Q R X 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   r   r   r   r    )r!   d)r   )r"   )r   r   r   r   r
   r   )r	   r   r#   r$   r   r   r   test_frame_equal_index_mismatch   s
    $$r2   c             C   s   |  d|  d}t dddgdddgd	d
ddgd}t dddgdddgdd
ddgd}tjt|d tj||| d W d Q R X 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   r   r   r    )r!   )r   r   )r   )r"   )r   r   r   r   r
   r   )r	   r   r#   r$   r   r   r   !test_frame_equal_columns_mismatch   s
    $$r3   c             C   sx   |}| d| d}t dddgdddgd	}t dddgddd
gd	}tjt|d tj||| |d W d Q R X 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   )r   r      )r   )	by_blocksr"   )r   r   r   r   r
   r   )r   r	   r"   r   r#   r$   r   r   r   test_frame_equal_block_mismatch   s    r6      á   à   ä   é   è   ë)r   Eu   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̊\]eu   {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   s<   |j |d}tjt|d tj| |||d W d Q R X d S )N)r"   )r   )r5   r"   )formatr   r   r   r
   r   )r#   r$   r   r   r	   r   r   r   test_frame_equal_unicode   s    r@   c              C   sb   t ddddgidd} | jt}d}tj| |dd	 tjt|d
 tj| |dd	 W d Q R X d S )Nr   r   r   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   r/   intr
   r   r   r   r   )leftrightr   r   r   r   0test_assert_frame_equal_extension_dtype_mismatch   s    
rF   c              C   sf   t dtjddgidd} | jt}d}tj| |dd tjt	|d	 tj| |d
d W d Q R X d S )Nr   r   r   interval)rB   zAttributes of DataFrame\.iloc\[:, 0\] \(column name="a"\) are different

Attribute "dtype" are different
\[left\]:  interval\[int64\]
\[right\]: objectF)r-   )r   T)
r   pdZIntervalr/   objectr
   r   r   r   r   )rD   rE   r   r   r   r   /test_assert_frame_equal_interval_dtype_mismatch   s    
rJ   right_dtypeZInt32r.   c             C   sD   t jddddgidd}t jddddgi| d}tj||dd d S )	Nr   r   r   r   rA   )rB   F)r-   )rH   r   r
   r   )rK   rD   rE   r   r   r   7test_assert_frame_equal_ignore_extension_dtype_mismatch	  s    rL   )r   ZpandasrH   r   Zpandas._testingZ_testingr
   Zfixturer   r	   r   r   r   markZparametrizer%   r&   Zfrom_recordsr+   r0   r2   r3   r6   r@   rF   rJ   rL   r   r   r   r   <module>   sL   
$8
  