U
    f/e                  	   @   s   d dl Zd dlZd dlmZmZmZmZmZm	Z	 d dl
mZ dd Zdd Zdd Zd	d
 Zdd Zdd Zdd Zejdddgdd Zdd Zejdddejejfeefejefgdd Zdd Zejdddgd d! Zd"d# ZdS )$    N)CategoricalCategoricalIndexIndex
MultiIndexNaT
RangeIndexc               	   C   sR   d} t dddg}tddddg}tjt| d	 tj||d
d W 5 Q R X d S )NzIndex are different

Index levels are different
\[left\]:  1, Int64Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: 2, MultiIndex\(\[\('A', 1\),
            \('A', 2\),
            \('B', 3\),
            \('B', 4\)\],
           \)         Ar   r   r	   Br
   r      matchF)exact)r   r   from_tuplespytestraisesAssertionErrortmassert_index_equal)msgidx1idx2 r   M/tmp/pip-unpacked-wheel-tiezk1ph/pandas/tests/util/test_assert_index_equal.py test_index_equal_levels_mismatch   s
    
r    c              	   C   sV   d}t ddddg}t ddddg}tjt|d tj||| d W 5 Q R X d S )NMultiIndex level \[1\] are different

MultiIndex level \[1\] values are different \(25\.0 %\)
\[left\]:  Int64Index\(\[2, 2, 3, 4\], dtype='int64'\)
\[right\]: Int64Index\(\[1, 2, 3, 4\], dtype='int64'\)r   r   r   r   r   check_exactr   r   r   r   r   r   r   r#   r   r   r   r   r   r    test_index_equal_values_mismatch!   s
    r&   c              	   C   sP   d}t dddg}t ddddg}tjt|d tj||| d W 5 Q R X d S )NzIndex are different

Index length are different
\[left\]:  3, Int64Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: 4, Int64Index\(\[1, 2, 3, 4\], dtype='int64'\)r   r	   r
   r   r   r"   r   r   r   r   r   r   r%   r   r   r    test_index_equal_length_mismatch/   s
    r(   c              	   C   sP   d}t dddg}t dddg}tjt|d tj||d| d W 5 Q R X d S )	NzIndex are different

Index classes are different
\[left\]:  Int64Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: Float64Index\(\[1\.0, 2\.0, 3\.0\], dtype='float64'\)r   r	   r
         @r   T)r   r#   r'   r%   r   r   r   test_index_equal_class_mismatch=   s
    r*   c              	   C   sd   t dddg}t dddg}| rPd}tjt|d tj||| d W 5 Q R X ntj||| d d S )Nr   r	   r)   go   @zIndex are different

Index values are different \(33\.33333 %\)
\[left\]:  Float64Index\(\[1.0, 2.0, 3.0], dtype='float64'\)
\[right\]: Float64Index\(\[1.0, 2.0, 3.0000000001\], dtype='float64'\)r   r"   r'   )r#   r   r   r   r   r   r   test_index_equal_values_closeK   s    r+   c              	   C   sv   t dddg}t dddg}| |d}| s2|dk rbd}tjt|d tj||f| W 5 Q R X ntj||f| d S )	Nr   r	   r)   g9m4 @r#   rtolgMb@?zIndex are different

Index values are different \(33\.33333 %\)
\[left\]:  Float64Index\(\[1.0, 2.0, 3.0], dtype='float64'\)
\[right\]: Float64Index\(\[1.0, 2.0, 3.0001\], dtype='float64'\)r   r'   r#   r-   r   r   kwargsr   r   r   r   "test_index_equal_values_less_close\   s    
r0   c              	   C   sX   t dddg}t dddg}| |d}d}tjt|d tj||f| W 5 Q R X d S )Nr   r	   r
   r   r,   zIndex are different

Index values are different \(33\.33333 %\)
\[left\]:  Int64Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: Int64Index\(\[1, 2, 4\], dtype='int64'\)r   r'   r.   r   r   r   test_index_equal_values_too_farn   s    
r1   check_orderTFc              	   C   sl   t dddg}t dddg}d}|rTtjt|d tj||| |dd W 5 Q R X ntj||| |dd d S )	Nr   r	   r
   zIndex are different

Index values are different \(66\.66667 %\)
\[left\]:  Int64Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: Int64Index\(\[3, 2, 1\], dtype='int64'\)r   T)r#   r-   r2   Fr'   )r#   r-   r2   r   r   r   r   r   r   $test_index_equal_value_oder_mismatch}   s&            r3   c              	   C   s`   t ddddg}t ddddg}| |d}d}tjt|d tj||f| W 5 Q R X d S )Nr   r   r   r   r,   r!   r   r$   r.   r   r   r   &test_index_equal_level_values_mismatch   s    
r4   zname1,name2)Nx)r5   r5   c              	   C   s   t dddg| d}t dddg|d}| |ks4| |krBt|| nX| dkrNdn| } |dkr^dn|}d|  d| d	}tjt|d
 t|| W 5 Q R X d S )Nr   r	   r
   )namer5   z'x'zBIndex are different

Attribute "names" are different
\[left\]:  \[z\]
\[right\]: \[z\]r   )r   r   r   r   r   r   )Zname1Zname2r   r   r   r   r   r   test_index_equal_names   s    r7   c              	   C   sr   d}t tddg}t tddgdddgd}| r^tjt|d tj||| d W 5 Q R X ntj||| d d S )NzIndex are different

Attribute "dtype" are different
\[left\]:  CategoricalDtype\(categories=\['a', 'b'\], ordered=False\)
\[right\]: CategoricalDtype\(categories=\['a', 'b', 'c'\], ordered=False\)abc)
categoriesr   )check_categorical)r   r   r   r   r   r   r   )r<   r   r   r   r   r   r   "test_index_equal_category_mismatch   s    r=   r   c              	   C   sl   d}t td}t ttd}| rV|rVtjt|d tj||ddd W 5 Q R X ntj||| |d d S )NzIndex are different

Index classes are different
\[left\]:  RangeIndex\(start=0, stop=10, step=1\)
\[right\]: Int64Index\(\[0, 1, 2, 3, 4, 5, 6, 7, 8, 9\], dtype='int64'\)
   r   T)r<   r   )	r   r   listranger   r   r   r   r   )r<   r   r   ZrcatZicatr   r   r   !test_index_equal_range_categories   s       rA   c                  C   s"   t dddg} tj| | dd d S )NZfoobar*   F)r2   )r   r   r   )idxr   r   r   #test_assert_index_equal_mixed_dtype   s    rE   )Znumpynpr   Zpandasr   r   r   r   r   r   Zpandas._testingZ_testingr   r    r&   r(   r*   r+   r0   r1   markZparametrizer3   r4   nanr7   r=   rA   rE   r   r   r   r   <module>   s,    


