o
    ŀg'                  	   @   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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)d* Z d+d, Z!d-d. Z"d/d0 Z#ejd1dd
gejd2dd
gd3d4 Z$ejd1dd
gd5d6 Z%dS )7    N)NACategoricalCategoricalIndexIndex
MultiIndexNaT
RangeIndexc                  C   sb   d} t g d}tg d}tjt| d tj||dd W d    d S 1 s*w   Y  d S )NzIndex are different

Index levels are different
\[left\]:  1, Index\(\[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"   ]/var/www/html/myenv/lib/python3.10/site-packages/pandas/tests/util/test_assert_index_equal.py test_index_equal_levels_mismatch   s   
"r$   c                 C   sd   d}t g d}t g d}tjt|d tj||| d W d    d S 1 s+w   Y  d S )NMultiIndex level \[1\] are different

MultiIndex level \[1\] values are different \(25\.0 %\)
\[left\]:  Index\(\[2, 2, 3, 4\], dtype='int64'\)
\[right\]: Index\(\[1, 2, 3, 4\], dtype='int64'\)r   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   s`   d}t g d}t g d}tjt|d tj||| d W d    d S 1 s)w   Y  d S )NzIndex are different

Index length are different
\[left\]:  3, Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: 4, Index\(\[1, 2, 3, 4\], dtype='int64'\)r	   )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 g d}td}tj||| d d S )N)r   r
   r   r   r   )r   r   r   r   )r   r    r!   r"   r"   r#   test_index_equal_class>   s   r/   c                 C   sh   d}t g d}t g dtjd}tjt|d tj||d| d W d    d S 1 s-w   Y  d S )NzcIndex are different

Attribute "inferred_type" are different
\[left\]:  integer
\[right\]: floatingr	   dtyper   Tr   r(   )r   npfloat64r   r   r   r   r   r*   r"   r"   r#   )test_int_float_index_equal_class_mismatchF   s   "r5   c                 C   sb   d}t g d}ttd}tjt|d tj||d| d W d    d S 1 s*w   Y  d S )NzkIndex are different

Index classes are different
\[left\]:  Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: r	   r   r   Tr2   )r   r   ranger   r   r   r   r   r*   r"   r"   r#   %test_range_index_equal_class_mismatchT   s   "r7   c                 C   sx   t g d}t g d}| r2d}tjt|d tj||| d W d    d S 1 s+w   Y  d S tj||| d d S )Nr
   r   g      @)r
   r   go   @zIndex are different

Index values are different \(33\.33333 %\)
\[left\]:  Index\(\[1.0, 2.0, 3.0], dtype='float64'\)
\[right\]: Index\(\[1.0, 2.0, 3.0000000001\], dtype='float64'\)r   r'   r,   )r(   r    r!   r   r"   r"   r#   test_index_equal_values_closeb   s   "r9   c                 C   s   t g d}t g d}| |d}| s|dk r=d}tjt|d tj||fi | W d    d S 1 s6w   Y  d S tj||fi | d S )Nr8   )r
   r   g9m4 @r(   rtolgMb@?zIndex are different

Index values are different \(33\.33333 %\)
\[left\]:  Index\(\[1.0, 2.0, 3.0], dtype='float64'\)
\[right\]: Index\(\[1.0, 2.0, 3.0001\], dtype='float64'\)r   r,   r(   r;   r    r!   kwargsr   r"   r"   r#   "test_index_equal_values_less_closes   s   
"r>   c                 C   sn   t g d}t g d}| |d}d}tjt|d tj||fi | W d    d S 1 s0w   Y  d S )Nr	   )r
   r   r   r:   zIndex are different

Index values are different \(33\.33333 %\)
\[left\]:  Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: Index\(\[1, 2, 4\], dtype='int64'\)r   r,   r<   r"   r"   r#   test_index_equal_values_too_far   s   
"r?   check_orderTc                 C   s   t g d}t g d}d}|r4tjt|d tj||| |dd W d    d S 1 s-w   Y  d S tj||| |dd d S )Nr	   )r   r   r
   zIndex are different

Index values are different \(66\.66667 %\)
\[left\]:  Index\(\[1, 2, 3\], dtype='int64'\)
\[right\]: Index\(\[3, 2, 1\], dtype='int64'\)r   T)r(   r;   r@   Fr,   )r(   r;   r@   r    r!   r   r"   r"   r#   %test_index_equal_value_order_mismatch   s   
"

rA   c                 C   sr   t g d}t g d}| |d}d}tjt|d tj||fi | W d    d S 1 s2w   Y  d S )Nr&   r   r:   r%   r   r)   r<   r"   r"   r#   &test_index_equal_level_values_mismatch   s   
"rB   zname1,name2)Nx)rC   rC   c                 C   s   t g d| d}t g d|d}| |ks| |u r t|| d S | dkr&dn| } |dkr.dn|}d|  d| d}tjt|d t|| W d    d S 1 sRw   Y  d S )	Nr	   namerC   z'x'zBIndex are different

Attribute "names" are different
\[left\]:  \[z\]
\[right\]: \[z\]r   )r   r   r   r   r   r   )name1name2r    r!   r   r"   r"   r#   test_index_equal_names   s   "rH   c                 C   s   |rd}nd}d| d| d}t tddg}t tddgg dd	}| rHtjt|d
 tj||| d W d    d S 1 sAw   Y  d S tj||| d d S )NstringobjectzIndex are different

Attribute "dtype" are different
\[left\]:  CategoricalDtype\(categories=\['a', 'b'\], ordered=False, categories_dtype=z^\)
\[right\]: CategoricalDtype\(categories=\['a', 'b', 'c'\], ordered=False, categories_dtype=z\)ab)rK   rL   c)
categoriesr   check_categorical)r   r   r   r   r   r   r   )rP   using_infer_stringr1   r   r    r!   r"   r"   r#   "test_index_equal_category_mismatch   s   "rR   c                 C   s   d}t td}t ttd}| r7|r7tjt|d tj||ddd W d    d S 1 s0w   Y  d S tj||| |d d S )NzIndex are different

Index classes are different
\[left\]:  RangeIndex\(start=0, stop=10, step=1\)
\[right\]: Index\(\[0, 1, 2, 3, 4, 5, 6, 7, 8, 9\], dtype='int64'\)
   r   T)rP   r   )	r   r   listr6   r   r   r   r   r   )rP   r   r   rcaticatr"   r"   r#   !test_index_equal_range_categories   s   "
rW   c                  C   sb   d} t ttdg}t ttg}tjt| d t	|| W d    d S 1 s*w   Y  d S )NzaIndex are different

Attribute "inferred_type" are different
\[left\]:  mixed
\[right\]: datetimenatr   )
r   r   r3   
datetime64r   r   r   r   r   r   r   r"   r"   r#   0test_assert_index_equal_different_inferred_types   s   "rZ   c                  C   sf   t ddgdd} t ddgdd}tjtdd tj| |dd	d
 W d    d S 1 s,w   Y  d S )Nr
   r   rK   rD   rL   z"names" are differentr   FT)r@   check_namesr,   r    r!   r"   r"   r#   9test_assert_index_equal_different_names_check_order_false  s
   "r]   c                  C   s    t g d} tj| | dd d S )N)foobar*   Fr@   r   r   r   )idxr"   r"   r#   #test_assert_index_equal_mixed_dtype  s   rd   c                 C   s4   t ddg| d}t ddg| d}tj||dd d S )Nr
   r   r0   Fra   rb   )any_numeric_ea_dtyper    r!   r"   r"   r#   ,test_assert_index_equal_ea_dtype_order_false     rf   c                  C   s4   t ddgdd} t ddgdd}tj| |dd d S )Nr
   r   rJ   r0   Fra   rb   r\   r"   r"   r#   /test_assert_index_equal_object_ints_order_false!  rg   rh   rP   r[   c                 C   sf   t ddgdd}t dtgdd}tjtdd tj||| |d W d    d S 1 s,w   Y  d S )Nr
   r   Int64r0   z50.0 %r   )r[   rP   )r   r   r   r   r   r   r   )r[   rP   r    r!   r"   r"   r#   *test_assert_ea_index_equal_non_matching_na(  s   "rj   c                 C   s   t ttjddgtjdg}t ttjddgtjdg}| rDtjt	dd t
j||| d W d    d S 1 s=w   Y  d S t
j||| d d S )Nr
   r   r0   z%^MultiIndex level \[0\] are differentr   rO   )r   from_arraysr   r3   arrayuint64int64r   r   r   r   r   )rP   r    r!   r"   r"   r#   /test_assert_multi_index_dtype_check_categorical4  s     "ro   )&numpyr3   r   pandasr   r   r   r   r   r   r   pandas._testing_testingr   r$   r+   r-   markparametrizer/   r5   r7   r9   r>   r?   rA   rB   nanrH   rR   rW   rZ   r]   rd   rf   rh   rj   ro   r"   r"   r"   r#   <module>   sF    $	




