
    Eg:                        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 Zd Zd Zej                            d ed           ed           ed	          g          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             Zej                            dddidg diddig          d             Zej                            dddg          ej                            dg d          ej                            dg d          d                                     Zej                            d  ed!d"gdd#g$           ed!d"gd%d&g$          d'f ej        dd#gd(d)gd!d"gd*d+d,g$          j         ej        d%d&gd(d)gd!d"gd*d+d,g$          j        d-fg          d.             Zej                            d/d0d1g          d2             Zej                            d3d0d1g          d4             Zd5 Zd6 Zd7 Zd8 Zd9 Zd: Z d; Z!d< Z"d= Z#d> Z$d? Z%d@ Z&dA Z'dB Z(dC Z)ej                            ddDdEg          dF             Z*ej                            ddGdHg          dI             Z+ej                            dde,g          ej                            dJd0d1g          ej                            dKddLg          dM                                     Z-dN Z.dO Z/dS )P    N)Categorical	DataFrameSeriesc                 R    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kwargss      _/var/www/sysmax/venv/lib/python3.11/site-packages/pandas/tests/util/test_assert_series_equal.py_assert_series_equal_bothr      s@     1a**6***1a**6*****    c                 ~    	 t          j        | |fi | d}t          j        |           dS # t          $ r Y dS w xY 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   s       r   _assert_not_series_equalr       sb    
q!..v...G   s   *. 
<<c                 >    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	   s      r   _assert_not_series_equal_bothr   6   s:     Q,,V,,,Q,,V,,,,,r   data   abcu   áàäc                 Z    t          t          |           t          |                      d S N)r   r   )r   s    r   test_series_equalr   I   s$    fTllF4LL99999r   zdata1,data2      xyzu   éèës   aaac                 Z    t          t          |           t          |                     d S r   )r   r   )data1data2s     r   $test_series_not_equal_value_mismatchr$   N   s&     "&--?????r   r   dtypefloat64indexr      r   namefooc                 |    t          d          }t          |          }t          |fi | }t          ||           d S )Nr   )ranger   r   )r   r   s1s2s       r   'test_series_not_equal_metadata_mismatchr0   \   sE     88D	B					B!"b)))))r   )g|Pk?g9]?)gV-?g??)float32r&   Float32decimals)r   r   r)   r      
   c                 \   d| z  }t          | g|          }t          |g|          }|dv s|dk    ret          | |z
            dk    rOd}t          j        t          |          5  t          j        |||           d d d            d S # 1 swxY w Y   d S t          |||           d S )	Nr5   r%   )r4   r5   r   gMb@?zSeries values are differentmatchrtol)r   absr   raisesr   r   r   r   )r"   r#   r%   r3   r;   r.   r/   r   s           r   test_less_preciser>   l   s    y=D	u	%	%	%B	u	%	%	%B7x1}}UU]1C1Cv1M1M+]>555 	6 	6"2r5555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	""bt444444s   (BBBz	s1,s2,msgl1l2r)   r'   g      ?g       @zSeries\.index are differentg @      ?r
   r   cr
   r   z$MultiIndex level \[0\] are differentc                     d|i}|rIt          j        t          |          5  t          j        | |fi | d d d            d S # 1 swxY w Y   d S t          j        | |fi | d S )Ncheck_index_typer8   )r   r=   r   r   r   )r.   r/   r   rF   r   s        r   test_series_equal_index_dtyperG   |   s    , !"23F 1]>555 	5 	5"2r44V444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	r20000000s   AA
A
check_likeTFc                    t          g dg d          }t          g dg d          }| sMt          j        t          d          5  t	          j        |||            d d d            d S # 1 swxY w Y   d S t          |||            d S )	Nr   r)   r   rC   rA   )r   r)   r   rD   r   r
   Series.index are differentr8   )rH   r   r   r=   r   r   r   r   )rH   r.   r/   s      r    test_series_equal_order_mismatchrN      s   					1	1	1B					1	1	1B A]>1MNNN 	B 	B"2rjAAAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	""bZ@@@@@@   A--A14A1check_indexc                    t          g dg d          }t          g dg d          }| rMt          j        t          d          5  t	          j        |||            d d d            d S # 1 swxY w Y   d S t          |||            d S )NrJ   rC   rA   rK   rL   r8   )rP   rM   )rP   r.   r/   s      r    test_series_equal_index_mismatchrR      s   					1	1	1B					1	1	1B C]>1MNNN 	D 	D"2r{CCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	""bkBBBBBBrO   c                      t          t                    } t          t                    }t          j        t          d          5  t          j        | |dd           d d d            d S # 1 swxY w Y   d S )Nr7   z0check_like must be False if check_index is Falser8   FT)rP   rH   )r   objectr   r=   
ValueErrorr   r   leftrights     r   %test_series_invalid_param_combinationrY      s    D   E	L
 
 
 P P 	tU$OOOOP P P P P P P P P P P P P P P P P Ps   A,,A03A0c                     d}t          g d          }t          g d          }t          j        t          |          5  t	          j        |||            d d d            d S # 1 swxY 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\)rJ   )r   r)   r   r   r8   r:   r   r   r=   r   r   r   r;   r   r.   r/   s       r   !test_series_equal_length_mismatchr]      s    ;C 
					B			B	~S	1	1	1 2 2
r2D11112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2    A%%A),A)c                     d}t          g d          }t          g d          }t          j        t          |          5  t	          j        |||            d d d            d S # 1 swxY w Y   d S )NzSeries are different

Series values are different \(33\.33333 %\)
\[index\]: \[0, 1, 2\]
\[left\]:  \[1, 2, 3\]
\[right\]: \[1, 2, 4\]rJ   r(   r8   r:   r[   r\   s       r   )test_series_equal_numeric_values_mismatchr`      s    C 
					B						B	~S	1	1	1 2 2
r2D11112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2r^   c                 "   |rd}nd}t          t          g d                    }t          t          g d                    }t          j        t          |          5  t          j        |||            d d d            d S # 1 swxY w 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'\]rC   )r
   rD   r   r8   r:   )r   r   r   r=   r   r   r   )r;   using_infer_stringr   r.   r/   s        r   -test_series_equal_categorical_values_mismatchrc      s     3-3 
OOO,,	-	-B	OOO,,	-	-B	~S	1	1	1 2 2
r2D11112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2s   BBBc                 0   d}t          t          j        ddd                    }t          t          j        ddd                    }t          j        t
          |          5  t          j        |||            d d d            d S # 1 swxY w 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-02r8   r:   )r   pd
date_ranger   r=   r   r   r   r\   s       r   *test_series_equal_datetime_values_mismatchrj      s    TC 
lAC@@@	A	AB	lAC@@@	A	AB	~S	1	1	1 2 2
r2D11112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2s   &BBBc                 ~   |rd}nd}d| d| d}t          t          ddg                    }t          t          ddgt          d          	                    }| rMt          j        t
          |
          5  t          j        |||            d d d            d S # 1 swxY w Y   d S t          |||            d S )NstringrT   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   )
categoriesr8   )check_categorical)	r   r   listr   r=   r   r   r   r   )rn   rb   r%   r   r.   r/   s         r   &test_series_equal_categorical_mismatchrp     sL    . 	. . "'. . .C 
S#J''	(	(B	S#J4;;???	@	@B O]>555 	P 	P"2r=NOOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	""b<MNNNNNNs   9BB"%B"c                  L   t          t          j        g dd                    } |                     t                    }d}t          j        | |d           t          j        t          |          5  t          j        | |d           d d d            d S # 1 swxY w Y   d S )	NrJ   Int64r7   zjAttributes of Series are different

Attribute "dtype" are different
\[left\]:  Int64
\[right\]: int[32|64]Fcheck_dtyper8   T)
r   rh   arrayastypeintr   r   r   r=   r   rW   rX   r   s      r   1test_assert_series_equal_extension_dtype_mismatchry     s    "(999G44455DKKEC 4E::::	~S	1	1	1 > >
tU====> > > > > > > > > > > > > > > > > >   4BB Bc                  L   t          t          j        dd          gd          } |                     t                    }d}t          j        | |d           t          j        t          |          5  t          j        | |d	           d d d            d S # 1 swxY w Y   d S )
Nr   r   intervalr7   zyAttributes of Series are different

Attribute "dtype" are different
\[left\]:  interval\[int64, right\]
\[right\]: objectFrs   r8   T)
r   rh   Intervalrv   rT   r   r   r   r=   r   rx   s      r   0test_assert_series_equal_interval_dtype_mismatchr~   +  s    2;q!$$%Z888DKKEC 4E::::	~S	1	1	1 > >
tU====> > > > > > > > > > > > > > > > > >rz   c                  l    G d dt                     } t          ddg          }t          ddg          } | ddg          }t          j        ||d           t          j        ||d           t          j        ||d           t          j        ||d           t          j        t
          d	          5  t          j        ||d           d d d            n# 1 swxY w Y   t          j        t
          d	          5  t          j        ||d           d d d            d S # 1 swxY w Y   d S )
Nc                       e Zd ZdS )/test_series_equal_series_type.<locals>.MySeriesN)__name__
__module____qualname__ r   r   MySeriesr   =  s        r   r   r   r)   F)check_series_typeTzSeries classes are differentr8   r   r   r   r   r=   r   )r   r.   r/   s3s       r   test_series_equal_series_typer   <  s       6    
AB	AB	1a&		B2rU;;;;2rT::::2rU;;;;2rU;;;;	~-K	L	L	L ? ?
r2>>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
~-K	L	L	L ? ?
r2>>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?s$   :CC"%C"D))D-0D-c                     t          ddg          } t          ddg          }t          ddg          }t          j        | |d           t          j        || d           d}t          j        t
          |          5  t          j        | |d           d d d            n# 1 swxY w Y   d}t          j        t
          |          5  t          j        || d           d d d            d S # 1 swxY 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\]r8   zzSeries are different

Series values are different \(100\.0 %\)
\[index\]: \[0, 1\]
\[left\]:  \[b, a\]
\[right\]: \[a, b\]r   )r.   r/   r   r   s       r   &test_series_equal_exact_for_nonnumericr   Q  s   	c
		B	c
		B	c
		B2rt44442rt4444C 
~S	1	1	1 9 9
r2488889 9 9 9 9 9 9 9 9 9 9 9 9 9 9C 
~S	1	1	1 9 9
r2488889 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9s$   ?B##B'*B'C00C47C4c                      t          g dd          } t          g dd          }t          j        | |d           d S )NrJ   rr   r7   Int32Frs   r   r   r   rV   s     r   8test_assert_series_equal_ignore_extension_dtype_mismatchr   m  L    )))7+++D999G,,,E4E::::::r   c                      t          g dd          } t          g dd          }t          j        | |d           d S )NrJ   rr   r7   int64Frs   r   rV   s     r   Dtest_assert_series_equal_ignore_extension_dtype_mismatch_cross_classr   t  r   r   c                  @   t          dg          } t          dg                              d          }t          j        | |            t          j        ||           t          j        | |d           t          j        || d           t	          j        t          d          5  t          j        | |           d d d            n# 1 swxY w Y   t	          j        t          d          5  t          j        | |           d d d            d S # 1 swxY w Y   d S )Nr   F)allows_duplicate_labels)check_flagsz<Flagsr8   )r   	set_flagsr   r   r   r=   r   rV   s     r   test_allows_duplicate_labelsr   {  s   1#;;DA3KK!!%!@@E4&&&5%(((4E::::5$E::::	~X	6	6	6 , ,
tU+++, , , , , , , , , , , , , , , 
~X	6	6	6 , ,
tU+++, , , , , , , , , , , , , , , , , ,s$   (C

CC0DDDc                     t          | g          }t          j        ||                                           t	          j        |          }t          j        ||                    d                     d S )NT)deep)r   r   r   copyrh   Indexassert_index_equal)nulls_fixtureseridxs      r   %test_assert_series_equal_identical_nar     sb    
-
!
!C3

+++ (3--C#sxxTx2233333r   c            	      R   t          dddt          j        ddg          g          } t          dddt          j        ddg          g          }t          j        | |            t          j        | | d           t          j        | |           t          j        | |d           d S )Nr   g=ۊ?g߷>g	ﰴ9?g?Tr   )r   npru   r   r   )xys     r   %test_identical_nested_series_is_equalr     s    H(*<=>>		
	 	A 	H(*<=>>		
	 	A 1a   1aT22221a   1aT222222r   
datetime64timedelta64c                    t          g d                              |  d          }|                    |  d          }t          j        t          d          5  t          j        ||           d d d            n# 1 swxY w Y   t          j        ||d           |t          g d                              |  d          z  }t          j        t          d	          5  t          j        ||           d d d            n# 1 swxY w Y   t          j        t          d	          5  t          j        ||d           d d d            d S # 1 swxY w Y   d S )
N)iC i   iK3Ez[s]z[ms]z"Attributes of Series are differentr8   Frs   )r   r   r   Series are different)r   rv   r   r=   r   r   r   )r%   ser_sser_mss      r   %test_check_dtype_false_different_resor     s)    ///00775FFE\\U...))F	~-Q	R	R	R . .
uf---. . . . . . . . . . . . . . .65e<<<<
fYYY&&%~~~666F	~-C	D	D	D . .
uf---. . . . . . . . . . . . . . . 
~-C	D	D	D A A
uf%@@@@A A A A A A A A A A A A A A A A A As6   A==BB$DD
D
,EEErr   r   c                     t          dg|           }t          dg|           }t          j        t          d          5  t	          j        ||           d d d            d S # 1 swxY w Y   d S )Nl   ?&l, r7   l   ?&l, r   r8   r[   )r%   rW   rX   s      r   test_large_unequal_intsr     s     #$E222D$%U333E	~-C	D	D	D , ,
tU+++, , , , , , , , , , , , , , , , , ,s    A##A'*A'r   valg      @c                     t          dd| g|          }t          t          j        dd| g                    }t          j        ||d|           d S )Nr   r)   r7   F)rt   r   )r   rh   ru   r   r   )r   r   r%   rW   rX   s        r    test_ea_and_numpy_no_dtype_checkr     sY    
 1a+U+++D28Q3K(())E4E{SSSSSSr   c                  |   t          g d          } t          g d          }t          j        | |d           t          j        |                                 |                                d           t          j        |                     d          j        |                    d          j        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   rB   r:   rr   )r   r   r   assert_frame_equalto_frameassert_extension_array_equalrv   valuesrV   s     r    test_assert_series_equal_int_tolr     s    MMMNNDJJJKKE4S1111$--//5>>+;+;#FFFF#G#U\\'%:%:%A     r   c                  r   t          t          j        dt                    g d          } t          t          j        dt                    t          j        ddd                    }t          j        | |           t          j        |                                 |                                           d S )N   r7   )r   g?g?g333333?g?r   r   r   )	r   r   zerosrw   linspacer   r   r   r   )ser1ser2s     r   ,test_assert_series_equal_index_exact_defaultr     s    "(1C(((*D*D*DEED"(1C((("+aA*>*>??D4&&&$--//4==??;;;;;r   )0numpyr   r   pandasrh   r   r   r   pandas._testing_testingr   r   r   r   markparametrizer-   ro   r   r$   r0   r>   from_recordsrD   rG   rN   rR   rY   r]   r`   rc   rj   rp   ry   r~   r   r   r   r   r   r   r   r   r   rT   r   r   r   r   r   r   <module>r      s                    
      + + +&  ,- - -& %%((DDKKh!HII: : JI: 	q55A;;	edd5kk"	hh(	hf&	q5588	 	@ @	 	@ 	)	)))	 * * * );=M(NOO"C"C"CDD%8%8%899
5 
5 :9 ED PO
5  FD$<1v...FD$<Sz222*	
 #I"!fC:T4LAA#s  "I"CjSztEEcSVZ  4	
 *1 1+ *1 e}55A A 65A u66C C 76CP P P2 2 22 2 22 2 262 2 2O O O.> > >"> > >"? ? ?*9 9 98; ; ;; ; ;, , ,4 4 43 3 34 <"?@@A A A@A" 7G"455, , 65, 4.11u66C))T T *) 76 21T	 	 	< < < < <r   