o
    ŀg:                  
   @   s   d dl Zd dlZd dlZd dlmZmZmZ d dlm	Z
 dd Zdd Zdd Zejd	ed
ededgdd Zejded
eddfededfededfededfed
edfgdd Zejdddidg diddigdd Zejdd d!gejdg d"ejd#g d$d%d& Zejd'ed(d)gdd*gd+ed(d)gd,d-gd+d.fejdd*gd/d0gd(d)gd1d2d3gd+jejd,d-gd/d0gd(d)gd1d2d3gd+jd4fgd5d6 Zejd7d8d9gd:d; Zejd<d8d9gd=d> Zd?d@ ZdAdB ZdCdD ZdEdF ZdGdH ZdIdJ Z dKdL Z!dMdN Z"dOdP Z#dQdR Z$dSdT Z%dUdV Z&dWdX Z'dYdZ Z(d[d\ Z)ejdd]d^gd_d` Z*ejddadbgdcdd Z+ejdde,gejded8d9gejdfd
dggdhdi Z-djdk Z.dldm Z/dS )n    N)Categorical	DataFrameSeriesc                 K   s,   t j| |fi | t j|| fi | dS )a&  
    Check that two Series equal.

    This check is performed commutatively.

    Parameters
    ----------
    a : Series
        The first Series to compare.
    b : Series
        The second Series to compare.
    kwargs : dict
        The arguments passed to `tm.assert_series_equal`.
    N)tmassert_series_equalabkwargs r   ^/var/www/html/myenv/lib/python3.10/site-packages/pandas/tests/util/test_assert_series_equal.py_assert_series_equal_both   s   r   c                 K   s@   zt j| |fi | d}tj|d W dS  ty   Y dS w )a  
    Check that two Series are not equal.

    Parameters
    ----------
    a : Series
        The first Series to compare.
    b : Series
        The second Series to compare.
    kwargs : dict
        The arguments passed to `tm.assert_series_equal`.
    z7The two Series were equal when they shouldn't have been)msgN)r   r   pytestfailAssertionError)r   r	   r
   r   r   r   r   _assert_not_series_equal    s   r   c                 K   s(   t | |fi | t || fi | dS )a.  
    Check that two Series are not equal.

    This check is performed commutatively.

    Parameters
    ----------
    a : Series
        The first Series to compare.
    b : Series
        The second Series to compare.
    kwargs : dict
        The arguments passed to `tm.assert_series_equal`.
    N)r   r   r   r   r   _assert_not_series_equal_both6   s   r   data   abcu   áàäc                 C   s   t t| t|  d S N)r   r   )r   r   r   r   test_series_equalI   s   r   zdata1,data2      xyzu   éèës   aaac                 C   s   t t| t| d S r   )r   r   )data1data2r   r   r   $test_series_not_equal_value_mismatchN   s   r   r
   dtypefloat64indexr      r   namefooc                 C   s.   t d}t|}t|fi | }t|| d S )Nr   )ranger   r   )r
   r   s1s2r   r   r   'test_series_not_equal_metadata_mismatch\   s   	r)   )g|Pk?g9]?)gV-?g??)float32r    Float32decimals)r   r   r#   r      
   c                 C   s   d|  }t | g|d}t |g|d}|dv s#|dkrGt| | dkrGd}tjt|d tj|||d W d    d S 1 s@w   Y  d S t|||d d S )	Nr.   r   )r-   r.   r   gMb@?zSeries values are differentmatchrtol)r   absr   raisesr   r   r   r   )r   r   r   r,   r3   r'   r(   r   r   r   r   test_less_precisel   s   
 "r6   z	s1,s2,msgl1l2r#   r!   g      ?g       @zSeries\.index are differentg @      ?r   r	   cr   r	   z$MultiIndex level \[0\] are differentc                 C   sl   d|i}|r*t jt|d tj| |fi | W d    d S 1 s#w   Y  d S tj| |fi | d S )Ncheck_index_typer0   )r   r5   r   r   r   )r'   r(   r   r=   r
   r   r   r   test_series_equal_index_dtype|   s   "r>   
check_likeTFc                 C   s   t g dg dd}t g dg dd}| s8tjtdd tj||| d W d    d S 1 s1w   Y  d S t||| d d S )	Nr   r#   r   r;   r9   )r   r#   r   r<   r	   r   Series.index are differentr0   )r?   r   r   r5   r   r   r   r   )r?   r'   r(   r   r   r    test_series_equal_order_mismatch      "rD   check_indexc                 C   s   t g dg dd}t g dg dd}| r8tjtdd tj||| d W d    d S 1 s1w   Y  d S t||| d d S )Nr@   r;   r9   rA   rB   r0   )rF   rC   )rF   r'   r(   r   r   r    test_series_equal_index_mismatch   rE   rG   c                  C   sZ   t td} t td}tjtdd tj| |ddd W d    d S 1 s&w   Y  d S )Nr/   z0check_like must be False if check_index is Falser0   FT)rF   r?   )r   objectr   r5   
ValueErrorr   r   leftrightr   r   r   %test_series_invalid_param_combination   s   

"rM   c                 C   `   d}t g d}t g d}tjt|d tj||| d W d    d S 1 s)w   Y  d S )NzSeries are different

Series length are different
\[left\]:  3, RangeIndex\(start=0, stop=3, step=1\)
\[right\]: 4, RangeIndex\(start=0, stop=4, step=1\)r@   )r   r#   r   r   r0   r2   r   r   r5   r   r   r   r3   r   r'   r(   r   r   r   !test_series_equal_length_mismatch   s   "rQ   c                 C   rN   )NzSeries are different

Series values are different \(33\.33333 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \[1, 2, 3\]
\[right\]: \[1, 2, 4\]r@   r"   r0   r2   rO   rP   r   r   r   )test_series_equal_numeric_values_mismatch   s   "rR   c                 C   sr   |rd}nd}t tg d}t tg d}tjt|d tj||| d W d    d S 1 s2w   Y  d S )NzSeries are different

Series values are different \(66\.66667 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \['a', 'b', 'c'\]
Categories \(3, string\): \[a, b, c\]
\[right\]: \['a', 'c', 'b'\]
Categories \(3, string\): \[a, b, c\]zSeries are different

Series values are different \(66\.66667 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \['a', 'b', 'c'\]
Categories \(3, object\): \['a', 'b', 'c'\]
\[right\]: \['a', 'c', 'b'\]
Categories \(3, object\): \['a', 'b', 'c'\]r;   )r   r<   r	   r0   r2   )r   r   r   r5   r   r   r   )r3   using_infer_stringr   r'   r(   r   r   r   -test_series_equal_categorical_values_mismatch   s   		"rT   c                 C   sp   d}t tjdddd}t tjdddd}tjt|d tj||| d W d    d S 1 s1w   Y  d S )	NzSeries are different

Series values are different \(100.0 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \[1514764800000000000, 1514851200000000000, 1514937600000000000\]
\[right\]: \[1549065600000000000, 1549152000000000000, 1549238400000000000\]z
2018-01-01r   D)periodsfreqz
2019-02-02r0   r2   )r   pd
date_ranger   r5   r   r   r   rP   r   r   r   *test_series_equal_datetime_values_mismatch   s   "rZ   c                 C   s   |rd}nd}d| d| d}t tddg}t tddgtdd	}| rHtjt|d
 tj||| d W d    d S 1 sAw   Y  d S t||| d d S )NstringrH   zAttributes of Series 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\)r   r	   r   )
categoriesr0   )check_categorical)	r   r   listr   r5   r   r   r   r   )r]   rS   r   r   r'   r(   r   r   r   &test_series_equal_categorical_mismatch  s   "r_   c                  C   sx   t tjg ddd} | t}d}tj| |dd tjt	|d tj| |dd W d    d S 1 s5w   Y  d S )	Nr@   Int64r/   zjAttributes of Series are different

Attribute "dtype" are different
\[left\]:  Int64
\[right\]: int[32|64]Fcheck_dtyper0   T)
r   rX   arrayastypeintr   r   r   r5   r   rK   rL   r   r   r   r   1test_assert_series_equal_extension_dtype_mismatch     
"rg   c                  C   sx   t tddgdd} | t}d}tj| |dd tjt	|d tj| |d	d W d    d S 1 s5w   Y  d S )
Nr   r   intervalr/   zyAttributes of Series are different

Attribute "dtype" are different
\[left\]:  interval\[int64, right\]
\[right\]: objectFra   r0   T)
r   rX   Intervalrd   rH   r   r   r   r5   r   rf   r   r   r   0test_assert_series_equal_interval_dtype_mismatch+  rh   rk   c                  C   s   G dd dt } t ddg}t ddg}| ddg}tj||dd tj||dd tj||dd tj||dd tjtdd	 tj||dd W d    n1 sTw   Y  tjtdd	 tj||dd W d    d S 1 stw   Y  d S )
Nc                   @   s   e Zd ZdS )z/test_series_equal_series_type.<locals>.MySeriesN)__name__
__module____qualname__r   r   r   r   MySeries=  s    ro   r   r#   F)check_series_typeTzSeries classes are differentr0   r   r   r   r   r5   r   )ro   r'   r(   s3r   r   r   test_series_equal_series_type<  s   "rs   c                  C   s   t ddg} t ddg}t ddg}tj| |dd tj|| dd d}tjt|d tj| |dd W d    n1 s>w   Y  d}tjt|d tj|| dd W d    d S 1 s`w   Y  d S )Nr   r	   Tcheck_exactzzSeries are different

Series values are different \(100\.0 %\)
\[index\]: \[0, 1\]
\[left\]:  \[a, b\]
\[right\]: \[b, a\]r0   zzSeries are different

Series values are different \(100\.0 %\)
\[index\]: \[0, 1\]
\[left\]:  \[b, a\]
\[right\]: \[a, b\]rq   )r'   r(   rr   r   r   r   r   &test_series_equal_exact_for_nonnumericQ  s   "rv   c                  C   4   t g ddd} t g ddd}tj| |dd d S )Nr@   r`   r/   Int32Fra   r   r   r   rJ   r   r   r   8test_assert_series_equal_ignore_extension_dtype_mismatchm     rz   c                  C   rw   )Nr@   r`   r/   int64Fra   ry   rJ   r   r   r   Dtest_assert_series_equal_ignore_extension_dtype_mismatch_cross_classt  r{   r}   c                  C   s   t dg} t dgjdd}t| |  t|| tj| |dd tj|| dd tjtdd t| | W d    n1 sBw   Y  tjtdd t| | W d    d S 1 s`w   Y  d S )Nr   F)allows_duplicate_labels)check_flagsz<Flagsr0   )r   	set_flagsr   r   r   r5   r   rJ   r   r   r   test_allows_duplicate_labels{  s   
"r   c                 C   s<   t | g}t||  t|}t||jdd d S )NT)deep)r   r   r   copyrX   Indexassert_index_equal)nulls_fixtureseridxr   r   r   %test_assert_series_equal_identical_na  s   

r   c                  C   sp   t dddtddgg} t dddtddgg}t| |  tj| | dd t| | tj| |dd d S )Nr   g=ۊ?g߷>g	ﰴ9?g?Trt   )r   nprc   r   r   )xyr   r   r   %test_identical_nested_series_is_equal  s$   
r   
datetime64timedelta64c                 C   s  t g d|  d}||  d}tjtdd t|| W d    n1 s,w   Y  tj||dd |t g d|  d8 }tjtd	d t|| W d    n1 s_w   Y  tjtd	d tj||dd W d    d S 1 sw   Y  d S )
N)iC i   iK3Ez[s]z[ms]z"Attributes of Series are differentr0   Fra   )r   r   r   Series are different)r   rd   r   r5   r   r   r   )r   ser_sser_msr   r   r   %test_check_dtype_false_different_reso  s   "r   r`   r|   c                 C   s\   t dg| d}t dg| d}tjtdd t|| W d    d S 1 s'w   Y  d S )Nl   ?&l, r/   l   ?&l, r   r0   rO   )r   rK   rL   r   r   r   test_large_unequal_ints  s
   "r   ru   valg      @c                 C   s<   t dd| g|d}t tdd| g}tj||d|d d S )Nr   r#   r/   F)rb   ru   )r   rX   rc   r   r   )r   ru   r   rK   rL   r   r   r    test_ea_and_numpy_no_dtype_check  s   r   c                  C   sd   t g d} t g d}tj| |dd tj|  | dd tj| dj|djdd d S )N)Q      y   &   J   H   r   r      r   r      r   r   )r   	   r   r   r   r   r   r   r   r   r   r   r   r   r:   r2   r`   )r   r   r   assert_frame_equalto_frameassert_extension_array_equalrd   valuesrJ   r   r   r    test_assert_series_equal_int_tol  s   
r   c                  C   sZ   t tjdtdg d} t tjdtdtddd}t| | t|  |  d S )N   r/   )r   g?g?g333333?g?r   r   r   )	r   r   zerosre   linspacer   r   r   r   )ser1ser2r   r   r   ,test_assert_series_equal_index_exact_default  s   r   )0numpyr   r   pandasrX   r   r   r   pandas._testing_testingr   r   r   r   markparametrizer&   r^   r   r   r)   r6   from_recordsr<   r>   rD   rG   rM   rQ   rR   rT   rZ   r_   rg   rk   rs   rv   rz   r}   r   r   r   r   r   rH   r   r   r   r   r   r   r   <module>   s    








	


