a
    DBìjì9  ã                
   @   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   úi/mnt/bigstor/www/usecases/.venv/lib/python3.9/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 n ty:   Y n0 dS )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   ÚpytestZ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é   é   Z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   ÚnameZ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š¿?g—9]›¿?)gV-²�¿?gÉå?¤¿?)Zfloat32r   ZFloat32Údecimals)r   r   r!   r   é   é
   c                 C   sœ   d|  }t | g|d�}t |g|d�}|dv sF|dkrŠt| | ƒdkrŠd}tjt|d��  tj|||d� W d   ƒ q˜1 s~0    Y  nt|||d� d S )	Nr)   ©r   )r(   r)   r   gü©ñÒMb@?zSeries values are different©Úmatch©Úrtol)r   Úabsr   Úraisesr   r   r   r   )r   r   r   r'   r.   r$   r%   r   r   r   r   Útest_less_precisel   s    
 0r1   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   sh   d|i}|rPt jt|d��$ tj| |fi |¤Ž W d   ƒ qd1 sD0    Y  ntj| |fi |¤Ž d S )NÚcheck_index_typer+   )r   r0   r   r   r   )r$   r%   r   r8   r
   r   r   r   Útest_series_equal_index_dtype|   s
    4r9   Ú
check_likeTFc                 C   s~   t g d¢g d¢d�}t g d¢g d¢d�}| sltjtdd��  tj||| d� W d   ƒ qz1 s`0    Y  nt||| d� d S )	N©r   r!   r   r6   r4   )r   r!   r   ©r7   r	   r   úSeries.index are differentr+   )r:   ©r   r   r0   r   r   r   r   )r:   r$   r%   r   r   r   Ú test_series_equal_order_mismatch›   s    0r?   Úcheck_indexc                 C   s~   t g d¢g d¢d�}t g d¢g d¢d�}| rltjtdd��  tj||| d� W d   ƒ qz1 s`0    Y  nt||| d� d S )Nr;   r6   r4   r<   r=   r+   )r@   r>   )r@   r$   r%   r   r   r   Ú test_series_equal_index_mismatch§   s    0rA   c                  C   sX   t td�} t td�}tjtdd��" tj| |ddd� W d   ƒ n1 sJ0    Y  d S )Nr*   z0check_like must be False if check_index is Falser+   FT)r@   r:   )r   Úobjectr   r0   Ú
ValueErrorr   r   ©ÚleftÚrightr   r   r   Ú%test_series_invalid_param_combination³   s    

ÿrG   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 )Nz™Series 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   r+   r-   ©r   r   r0   r   r   r   ©r.   r   r$   r%   r   r   r   Ú!test_series_equal_length_mismatch¼   s
    rJ   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 )Nz†Series are different

Series values are different \(33\.33333 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \[1, 2, 3\]
\[right\]: \[1, 2, 4\]r;   r    r+   r-   rH   rI   r   r   r   Ú)test_series_equal_numeric_values_mismatchÊ   s
    rK   c                 C   s€   |rdnd}d|› d|› d�}t tg d¢ƒƒ}t tg d¢ƒƒ}tjt|d��  tj||| d	� W d   ƒ n1 sr0    Y  d S )
NÚstrrB   z†Series are different

Series values are different \(66\.66667 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \['a', 'b', 'c'\]
Categories \(3, zC\): \['a', 'b', 'c'\]
\[right\]: \['a', 'c', 'b'\]
Categories \(3, z\): \['a', 'b', 'c'\]r6   )r   r7   r	   r+   r-   )r   r   r   r0   r   r   r   )r.   Úusing_infer_stringr   r   r$   r%   r   r   r   Ú-test_series_equal_categorical_values_mismatchÙ   s    ûû	rN   c                 C   sn   d}t tjdddd�ƒ}t tjdddd�ƒ}tjt|d��  tj||| d� W d   ƒ n1 s`0    Y  d S )	NzîSeries 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)ZperiodsÚfreqz
2019-02-02r+   r-   )r   ÚpdZ
date_ranger   r0   r   r   r   rI   r   r   r   Ú*test_series_equal_datetime_values_mismatchë   s
    rR   c                 C   sž   |r
d}nd}d|› d|› d�}t tddgƒƒ}t tddgtdƒd	�ƒ}| rŒtjt|d
��  tj||| d� W d   ƒ qš1 s€0    Y  nt||| d� d S )NrL   rB   zšAttributes 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   )Ú
categoriesr+   )Úcheck_categorical)	r   r   Úlistr   r0   r   r   r   r   )rT   rM   r   r   r$   r%   r   r   r   Ú&test_series_equal_categorical_mismatchú   s    üü0rV   c                  C   sv   t tjg d¢dd�ƒ} |  t¡}d}tj| |dd� tjt	|d��  tj| |dd� W d   ƒ n1 sh0    Y  d S )	Nr;   ÚInt64r*   zjAttributes of Series are different

Attribute "dtype" are different
\[left\]:  Int64
\[right\]: int[32|64]F©Úcheck_dtyper+   T)
r   rQ   ÚarrayÚastypeÚintr   r   r   r0   r   ©rE   rF   r   r   r   r   Ú1test_assert_series_equal_extension_dtype_mismatch  s    
r^   c                  C   sv   t t dd¡gdd�} |  t¡}d}tj| |dd� tjt	|d��  tj| |d	d� W d   ƒ n1 sh0    Y  d S )
Nr   r   Úintervalr*   zyAttributes of Series are different

Attribute "dtype" are different
\[left\]:  interval\[int64, right\]
\[right\]: objectFrX   r+   T)
r   rQ   ZIntervalr[   rB   r   r   r   r0   r   r]   r   r   r   Ú0test_assert_series_equal_interval_dtype_mismatch"  s    
r`   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 s¨0    Y  tjtdd	��  tj||dd� W d   ƒ n1 sæ0    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   ÚMySeries4  s   rd   r   r!   F)Zcheck_series_typeTzSeries classes are differentr+   ©r   r   r   r   r0   r   )rd   r$   r%   Ús3r   r   r   Útest_series_equal_series_type3  s    .rg   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|0    Y  d}tjt|d��  tj|| dd� W d   ƒ n1 s¾0    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\]r+   zzSeries are different

Series values are different \(100\.0 %\)
\[index\]: \[0, 1\]
\[left\]:  \[b, a\]
\[right\]: \[a, b\]re   )r$   r%   rf   r   r   r   r   Ú&test_series_equal_exact_for_nonnumericH  s    .rj   c                  C   s4   t g d¢dd�} t g d¢dd�}tj| |dd� d S )Nr;   rW   r*   ZInt32FrX   ©r   r   r   rD   r   r   r   Ú8test_assert_series_equal_ignore_extension_dtype_mismatchd  s    rl   c                  C   s4   t g d¢dd�} t g d¢dd�}tj| |dd� d S )Nr;   rW   r*   Úint64FrX   rk   rD   r   r   r   ÚDtest_assert_series_equal_ignore_extension_dtype_mismatch_cross_classk  s    rn   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 s„0    Y  tjtdd�� t | |¡ W d   ƒ n1 s¾0    Y  d S )Nr   F)Zallows_duplicate_labels)Zcheck_flagsz<Flagsr+   )r   Z	set_flagsr   r   r   r0   r   rD   r   r   r   Útest_allows_duplicate_labelsr  s    
*ro   c                 C   s<   t | gƒ}t || ¡ ¡ t |¡}t ||jdd�¡ d S )NT)Údeep)r   r   r   ÚcopyrQ   ÚIndexZassert_index_equal)Znulls_fixtureZserÚidxr   r   r   Ú%test_assert_series_equal_identical_na�  s    

rt   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ÓÂ‹ýÚ?Trh   )r   ÚnprZ   r   r   )ÚxÚyr   r   r   Ú%test_identical_nested_series_is_equal‹  s$    üÿüÿ
rx   Z
datetime64Ztimedelta64c                 C   s
  t g d¢ƒ | › d�¡}| | › d�¡}tjtdd�� t ||¡ W d   ƒ n1 sX0    Y  tj||dd� |t g d¢ƒ | › d�¡8 }tjtd	d�� t ||¡ W d   ƒ n1 s¾0    Y  tjtd	d��  tj||dd� W d   ƒ n1 sü0    Y  d S )
N)iC i …  iK3Ez[s]z[ms]z"Attributes of Series are differentr+   FrX   )r   r   r   úSeries are different)r   r[   r   r0   r   r   r   )r   Zser_sZser_msr   r   r   Ú%test_check_dtype_false_different_reso¥  s    **rz   rW   rm   c                 C   sZ   t dg| d�}t dg| d�}tjtdd�� t ||¡ W d   ƒ n1 sL0    Y  d S )Nl   ¸Œ?&l, r*   l   ×Œ?&l, ry   r+   rH   )r   rE   rF   r   r   r   Útest_large_unequal_ints·  s    r{   ri   Úvalg      @c                 C   s<   t dd| g|d�}t t dd| g¡ƒ}tj||d|d� d S )Nr   r!   r*   F)rY   ri   )r   rQ   rZ   r   r   )r|   ri   r   rE   rF   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ƒ   r5   r-   rW   )r   r   r   Úassert_frame_equalÚto_frameZassert_extension_array_equalr[   ÚvaluesrD   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   ru   Zzerosr\   Zlinspacer   r   r‡   rˆ   )Zser1Zser2r   r   r   Ú,test_assert_series_equal_index_exact_defaultÖ  s    rŒ   )0Únumpyru   r   ZpandasrQ   r   r   r   Zpandas._testingZ_testingr   r   r   r   ÚmarkZparametrizer#   rU   r   r   r&   r1   Zfrom_recordsr7   r9   r?   rA   rG   rJ   rK   rN   rR   rV   r^   r`   rg   rj   rl   rn   ro   rt   rx   rz   r{   rB   r}   rŠ   rŒ   r   r   r   r   Ú<module>   sš   
ûþ


ýþ
ýÿÿùøþ

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