a
    Pf'                  	   @   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   s`   d} t g d}tg d}tjt| d  tj||dd W d    n1 sR0    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"   b/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/tests/util/test_assert_index_equal.py test_index_equal_levels_mismatch   s
    
r$   c                 C   sb   d}t g d}t g d}tjt|d  tj||| d W d    n1 sT0    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    n1 sP0    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   sf   d}t g d}t g dtjd}tjt|d" tj||d| d W d    n1 sX0    Y  d S )NzcIndex are different

Attribute "inferred_type" are different
\[left\]:  integer
\[right\]: floatingr	   dtyper   Tr   r(   )r   npZfloat64r   r   r   r   r   r*   r"   r"   r#   )test_int_float_index_equal_class_mismatchF   s
    r4   c                 C   s`   d}t g d}ttd}tjt|d" tj||d| d W d    n1 sR0    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
    r6   c                 C   st   t g d}t g d}| r`d}tjt|d  tj||| d W d    qp1 sT0    Y  n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    0r8   c                 C   s   t g d}t g d}| |d}| s.|dk rvd}tjt|d$ tj||fi | W d    q1 sj0    Y  ntj||fi | d S )Nr7   )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    
4r=   c                 C   sl   t g d}t g d}| |d}d}tjt|d$ tj||fi | W d    n1 s^0    Y  d S )Nr	   )r
   r   r   r9   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}|rdtjt|d$ tj||| |dd W d    qx1 sX0    Y  n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    
&
r@   c                 C   sp   t g d}t g d}| |d}d}tjt|d$ tj||fi | W d    n1 sb0    Y  d S )Nr&   r   r9   r%   r   r)   r;   r"   r"   r#   &test_index_equal_level_values_mismatch   s    
rA   zname1,name2)Nx)rB   rB   c                 C   s   t g d| d}t g d|d}| |ks0| |u r>t|| nl| dkrJdn| } |dkrZdn|}d|  d| d}tjt|d t|| W d    n1 s0    Y  d S )	Nr	   namerB   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    rE   c                 C   s   |r
d}nd}d| d| d}t tddg}t tddgg dd	}| rtjt|d
  tj||| d W d    q1 s0    Y  n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)rH   rI   c)
categoriesr   check_categorical)r   r   r   r   r   r   r   )rM   Zusing_infer_stringr1   r   r    r!   r"   r"   r#   "test_index_equal_category_mismatch   s    0rN   c                 C   s   d}t td}t ttd}| rj|rjtjt|d" tj||ddd W d    q|1 s^0    Y  n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)rM   r   )	r   r   listr5   r   r   r   r   r   )rM   r   r   ZrcatZicatr"   r"   r#   !test_index_equal_range_categories   s    2rQ   c                  C   s`   d} t ttdg}t ttg}tjt| d t	|| W d    n1 sR0    Y  d S )NzaIndex are different

Attribute "inferred_type" are different
\[left\]:  mixed
\[right\]: datetimeZnatr   )
r   r   r3   Z
datetime64r   r   r   r   r   r   r   r"   r"   r#   0test_assert_index_equal_different_inferred_types   s
    rR   c                  C   sd   t ddgdd} t ddgdd}tjtdd" tj| |dd	d
 W d    n1 sV0    Y  d S )Nr
   r   rH   rC   rI   z"names" are differentr   FT)r?   check_namesr,   r    r!   r"   r"   r#   9test_assert_index_equal_different_names_check_order_false  s    rU   c                  C   s    t g d} tj| | dd d S )N)Zfoobar*   Fr?   r   r   r   )idxr"   r"   r#   #test_assert_index_equal_mixed_dtype  s    r[   c                 C   s4   t ddg| d}t ddg| d}tj||dd d S )Nr
   r   r0   FrX   rY   )Zany_numeric_ea_dtyper    r!   r"   r"   r#   ,test_assert_index_equal_ea_dtype_order_false  s    r\   c                  C   s4   t ddgdd} t ddgdd}tj| |dd d S )Nr
   r   rG   r0   FrX   rY   rT   r"   r"   r#   /test_assert_index_equal_object_ints_order_false!  s    r]   rM   rS   c                 C   sd   t ddgdd}t dtgdd}tjtdd" tj||| |d W d    n1 sV0    Y  d S )Nr
   r   ZInt64r0   z50.0 %r   )rS   rM   )r   r   r   r   r   r   r   )rS   rM   r    r!   r"   r"   r#   *test_assert_ea_index_equal_non_matching_na(  s    r^   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}| rtjt	dd  t
j||| d W d    q1 sx0    Y  nt
j||| d d S )Nr
   r   r0   z%^MultiIndex level \[0\] are differentr   rL   )r   Zfrom_arraysr   r3   arrayZuint64Zint64r   r   r   r   r   )rM   r    r!   r"   r"   r#   /test_assert_multi_index_dtype_check_categorical4  s      0r`   )&numpyr3   r   Zpandasr   r   r   r   r   r   r   Zpandas._testingZ_testingr   r$   r+   r-   markZparametrizer/   r4   r6   r8   r=   r>   r@   rA   nanrE   rN   rQ   rR   rU   r[   r\   r]   r^   r`   r"   r"   r"   r#   <module>   sD   $	




