U
    c"                  	   @   s|  d dl Zd dlZd dlmZ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ejd	d
dgdd Zejddddgdgeddgg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.d/ Z d0d1 Z!d2d3 Z"ejd4dd
gejd5dd
gd6d7 Z#dS )8    N)NA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-g7fro6k3/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_mismatch0   s
    r*   r   Fequivc                 C   s*   t dddg}td}tj||| d d S )Nr   r	   r
   r   r   )r   r   r   r   )r   r   r   r    r    r!   test_index_equal_class>   s    r,   zidx_values, msg_strr	   r
         @z5Float64Index\(\[1\.0, 2\.0, 3\.0\], dtype='float64'\)r   z%RangeIndex\(start=0, stop=3, step=1\)c              	   C   sP   d| }t dddg}t |}tjt|d tj||d| d W 5 Q R X d S )NzpIndex are different

Index classes are different
\[left\]:  Int64Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: r	   r
   r   r   T)r   r%   r)   )r%   Z
idx_valuesZmsg_strr   r   r   r    r    r!   test_index_equal_class_mismatchF   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_close[   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%   r1   r   r   kwargsr   r    r    r!   "test_index_equal_values_less_closel   s    
r4   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   r0   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)   r2   r    r    r!   test_index_equal_values_too_far~   s    
r5   check_orderTc              	   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%   r1   r6   Fr)   )r%   r1   r6   r   r   r   r    r    r!   $test_index_equal_value_oder_mismatch   s&            r7   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   r0   r#   r   r&   r2   r    r    r!   &test_index_equal_level_values_mismatch   s    
r8   zname1,name2)Nx)r9   r9   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   namer9   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    r<   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   )rA   r   r   r   r    r    r!   "test_index_equal_category_mismatch   s    rB   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)rA   r   )	r   r   listranger   r   r   r   r   )rA   r   r   ZrcatZicatr    r    r!   !test_index_equal_range_categories   s       rF   c               	   C   sP   t ddgdd} t ddgdd}tjtdd tj| |dd	d
 W 5 Q R X d S )Nr	   r   r=   r:   r>   z"names" are differentr   FT)r6   check_namesr)   r   r   r    r    r!   9test_assert_index_equal_different_names_check_order_false   s    rI   c                  C   s"   t dddg} tj| | dd d S )NZfoobar*   Fr6   r   r   r   )idxr    r    r!   #test_assert_index_equal_mixed_dtype   s    rO   c                 C   s4   t ddg| d}t ddg| d}tj||dd d S )Nr	   r   ZdtypeFrL   rM   )Zany_numeric_ea_dtyper   r   r    r    r!   ,test_assert_index_equal_ea_dtype_order_false   s    rQ   c                  C   s4   t ddgdd} t ddgdd}tj| |dd d S )Nr	   r   objectrP   FrL   rM   rH   r    r    r!   /test_assert_index_equal_object_ints_order_false  s    rS   rA   rG   c              	   C   sP   t ddgdd}t dtgdd}tjtdd tj||| |d W 5 Q R X d S )Nr	   r
   ZInt64rP   z50.0 %r   )rG   rA   )r   r   r   r   r   r   r   )rG   rA   r   r   r    r    r!   *test_assert_ea_index_equal_non_matching_na  s       rT   )$Znumpynpr   Zpandasr   r   r   r   r   r   r   Zpandas._testingZ_testingr   r"   r(   r*   markZparametrizer,   rE   r.   r/   r4   r5   r7   r8   nanr<   rB   rF   rI   rO   rQ   rS   rT   r    r    r    r!   <module>   sH   $	





