
    OwgB                         d dl m Z mZ d dlZd dlZd dlmZ d dlZd dlm	Z	m
Z
mZmZmZmZmZmZ d dlmZ  G d d      Z G d d      Zy)	    )datetime	timedeltaN)using_pyarrow_string_dtype)Categorical	DataFrameIndexSeries
date_rangeoption_contextperiod_rangetimedelta_rangec                      e Zd Zd Zd Zd Zd Zd Zej                  j                  dddg      d	        Zd
 Zd Zd Zd Zej                  j                  dg d      d        Zd Zej                  j                  dddg      d        Zej                  j'                   e       d      d        Zej                  j                  dddgddgg      d        Zd Zd  Zd! Zd" Zd# Zd$ Zd% Zd& Zd' Zd( Z d) Z!d* Z"y)+TestSeriesReprc                     t         j                  j                  t        dd      t        dd      gdd g      }t	        d|      }t        |      }d}||k(  sJ y )	N         r   )namesg      ?indexz0   
2  3    1.5
dtype: float64)pd
MultiIndexfrom_productranger	   repr)selfmiserresexpecteds        W/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/series/test_formats.pytest_multilevel_name_print_0z+TestSeriesRepr.test_multilevel_name_print_0   sX     ]]''q!eAqk(B1d)'TS#3i6h    c                     |}t        t        t        |            |d      }g d}dj                  |      }t	        |      |k(  sJ y )Nsthr   name)zfirst  secondzfoo    one       0z       two       1z       three     2zbar    one       3z       two       4zbaz    two       5z       three     6zqux    one       7z       two       8z       three     9zName: sth, dtype: int64
)r	   r   lenjoinr   )r   %lexsorted_two_level_string_multiindexr   r   r    s        r!   test_multilevel_name_printz)TestSeriesRepr.test_multilevel_name_print$   sG    5U3u:&e%@
 99X&CyH$$$r#   c                 v    t        g d      }d|_        dt        |      v sJ d |_        dt        |      vsJ y )N)r      r   test
Name: testName:)r	   r'   r   r   ss     r!   test_small_name_printingz'TestSeriesRepr.test_small_name_printing8   s>    9tAw&&&d1g%%%r#   c                     t        t        d            }d|_        dt        |      v sJ d |_        dt        |      vsJ y )N  r/   r0   r1   )r	   r   r'   r   r2   s     r!   test_big_name_printingz%TestSeriesRepr.test_big_name_printingB   sB    5;tAw&&&d1g%%%r#   c                 Z    t        t        dd      dt              }dt        |      v sJ y )N2001010120020101r/   )r   r'   dtyper0   )r	   r
   objectr   r2   s     r!   test_empty_name_printingz'TestSeriesRepr.test_empty_name_printingL   s*    J
;&PVWtAw&&&r#   args )r   c           	          t        t        t        j                  j	                  d      j                  d      t        j                  dg|              y )Nr   r6   r   )strr	   nprandomdefault_rngstandard_normalarange)r   r>   s     r!   test_float_rangezTestSeriesRepr.test_float_rangeP   s@    		%%a(88>ii,t,	
r#   c                 6    t        t        t                     y )Nr;   )rB   r	   r<   r   s    r!   test_empty_objectz TestSeriesRepr.test_empty_objectY   s    F !r#   c                     t        |       t        |j                  t                     t        j                  |dd t        |       y )N      )rB   astypeintrC   nan)r   string_seriess     r!   test_stringzTestSeriesRepr.test_string]   s7    MM  %&  VVaMr#   c                     t        |       y N)rB   )r   object_seriess     r!   test_objectzTestSeriesRepr.test_objecte   s
    Mr#   c                 b    t        |       |j                  d      }d |d d d<   t        |       y )NOr   )rB   rP   r   )r   datetime_seriesotss      r!   test_datetimezTestSeriesRepr.test_datetimeh   s.    O$$S)CaCS	r#   r'   ) r.   g333333?foou   αβγ7loooooooooooooooooooooooooooooooooooooooooooooooooooongr_   barbaz)r.   r   )r_   r.   gffffff@)   αu   βu   γ)rd   rb   c                 (    ||_         t        |       y rV   )r'   r   )r   r'   rS   s      r!   test_various_namesz!TestSeriesRepr.test_various_nameso   s    $ "]r#   c                     t        t        j                  j                  d      j	                  d      t        j
                  d      d      }t        |       y )Nr   r6   ra   r&   )r	   rC   rD   rE   rF   rG   r   )r   biggies     r!   test_tuple_namezTestSeriesRepr.test_tuple_name   s@    II!!!$44T:))D/&

 	Vr#   argd     c                     t        t        j                  j                  d      j	                  |      d      }t        |      }d|v sJ y )Nr   r   r'   zName: 0)r	   rC   rD   rE   rF   r   )r   rj   r   rep_strs       r!   test_tidy_repr_name_0z$TestSeriesRepr.test_tidy_repr_name_0   sA     RYY**1-==cBKs)G###r#   z%TODO: investigate why this is failing)reasonc                 ~    t        dgddg      }dt        |      vsJ dt        |      vsJ dt        |      vsJ y )Nza
	bza
	dza
	f)r'   r   	za
)r	   r   )r   r   s     r!   test_newlinezTestSeriesRepr.test_newline   sL     j\
:,G49$$$49$$$DI%%%r#   zname, expectedr_   z#Series([], Name: foo, dtype: int64)NzSeries([], dtype: int64)c                 \    t        g t        j                  |      }t        |      |k(  sJ y )N)r;   r'   )r	   rC   int64r   )r   r'   r    r3   s       r!   test_empty_int64zTestSeriesRepr.test_empty_int64   s(     2RXXD1Aw("""r#   c           
         t        t        d      D cg c]9  }t        t        j                  j                  d      j                  d            ; c}      }t        |       |j                         }|j                  dk(  sJ y c c}w )NrN   r   )r   r   r^   )
r	   r   r   rC   rD   rE   rF   r   
readouterrerr)r   capsysir3   captureds        r!   test_repr_bool_failsz#TestSeriesRepr.test_repr_bool_fails   su     q "))//2BB6JK
 	Q$$&||r!!!s   >Bc                     t        g dt        j                  d            }t        |       d|_        t        |       y )Nr.   r   r   r   rn   )   אr   )r	   rC   rw   r   r'   r2   s     r!   !test_repr_name_iterable_indexablez0TestSeriesRepr.test_repr_name_iterable_indexable   s-    9288A;/ 	Q Qr#   c                     t        dd       5  t        t        t        d                   d d d        y # 1 sw Y   y xY w)Ndisplay.max_rowsrl   )r   rB   r	   r   rK   s    r!   test_repr_max_rowsz!TestSeriesRepr.test_repr_max_rows   s3    .5 	%uT{#$	% 	% 	%s   4=c                     t        dgd      }t        |       t        dgdz        }t        |       t        dgdz        }d|_        t        |       y )Nr   u   בrn   u   σ
   r6   title1)r	   rB   r   r'   )r   dfr   ser2s       r!    test_unicode_string_with_unicodez/TestSeriesRepr.test_unicode_string_with_unicode   sM    XJX.BhZ"_%S	xj4'(	T
r#   c                     t        dgd      }d}t        j                  t        |      5  t	        |       d d d        y # 1 sw Y   y xY w)Nabcrn   z2^'str' object cannot be interpreted as an integer$match)r	   pytestraises	TypeErrorbytes)r   r   msgs      r!   test_str_to_bytes_raisesz'TestSeriesRepr.test_str_to_bytes_raises   s?    UG%(B]]9C0 	"I	 	 	s   AA
c           
         t        t        d      D cg c]  }t        ddd      t        |      z    c}t              }t        t        j                  j                  d      j                  t        |            |      }t        |       t        t        j                  dt        j                        t        dd      	      }t        |      j                         d
   j!                  d      sJ |j"                  t        j                  j                  d      j%                  dt        |      dz
  d         }t        |      j                         d
    y c c}w )Nr6     r.   rJ   r      z
2020-01-01periodsr   r@   zFreq:r   i  )r   r   r   r   r<   r	   rC   rD   rE   rF   r)   r   rG   float64r
   
splitlines
startswithilocintegers)r   r}   r   tsts2s        r!   !test_timeseries_repr_object_dtypez0TestSeriesRepr.test_timeseries_repr_object_dtype   s   :?+FQXdAq!IaL0Ff
 BII))!,<<SZH%PRIIb

+:lTV3W
 Bx""$R(33G<<<ggbii++A.773r7Q;LMS	r" Gs    Ec                     t        j                  d       d}t        dd dd      5  t        g d      }||j	                         k(  sJ 	 d d d        j	                         J y # 1 sw Y   xY w)Njinja2zj\begin{tabular}{ll}
\toprule
 & 0 \\
\midrule
0 & $\alpha$ \\
1 & b \\
2 & c \\
\bottomrule
\end{tabular}
zstyler.format.escapezstyler.render.reprlatex)z$\alpha$bc)r   importorskipr   r	   _repr_latex_)r   resultr3   s      r!   test_latex_reprzTestSeriesRepr.test_latex_repr   sw    H%	 "D*>
 	. ./AQ^^----		. ~~'''	. 	.s   #A%%A.c                 |    t        dt        j                  g      }t        ddg|      }d}t	        |      |k(  sJ y )Nr.   r   r   z1.0    1
NaN    2
dtype: int64)r   rC   rR   r	   r   )r   r}   r3   exps       r!   !test_index_repr_in_frame_with_nanz0TestSeriesRepr.test_index_repr_in_frame_with_nan   s9    1bff+Aq6#4Aw#~~r#   c                     t        ddd      }d}t        j                  t        |      5  |j	                          d d d        t        d|      }t        |       y # 1 sw Y   "xY w)	Nz1/1/1850z1/1/1950zYE-DEC)freqz"DatetimeIndex.format is deprecatedr   r.   r   )r
   tmassert_produces_warningFutureWarningformatr	   r   )r   rngr   r   s       r!   test_format_pre_1900_datesz)TestSeriesRepr.test_format_pre_1900_dates  sV    Zh?2''SA 	JJL	AS!R	 	s   AA'c                 ~    t        dddt        j                  j                  gd      }t	        |      }d}||k(  sJ y )Nr   r6   r   zM8[ns]rJ   z0   1970-01-01 00:00:00.000000
1   1970-01-01 00:00:00.000001
2   1970-01-01 00:00:00.000002
3                          NaT
dtype: datetime64[ns])r	   r   NaT_valuer   )r   seriesr   r    s       r!   test_series_repr_natz#TestSeriesRepr.test_series_repr_nat	  sB    D$6hGf$ 	 !!!r#   c                 f    t        dg      j                  t              }d}t        |      |k(  sJ y )Ng      ?z0    1.0
dtype: object)r	   rP   r<   r   )r   r   r    s      r!   test_float_reprzTestSeriesRepr.test_float_repr  s1     cUm""6*,CyH$$$r#   c                     t        g ddd t        j                  t        j                  g      }t        |      }d}||k(  sJ y )Nr.   r   r   r   Tz4True    1
None    2
NaN     3
NaT     4
dtype: int64)r	   rC   rR   r   r   r   )r   r   r   r    s       r!   test_different_null_objectsz*TestSeriesRepr.test_different_null_objects  s;    \D$#?@cM!!!r#   )#__name__
__module____qualname__r"   r,   r4   r7   r=   r   markparametrizerH   rL   rT   rX   r]   rf   ri   rp   xfailr   ru   rx   r   r   r   r   r   r   r   r   r   r   r   r   r?   r#   r!   r   r      s[   %(&&' [[Vb']3
 4
" [[	
 ! 
 [[US$K0$ 1$ [["$-T  && [[9:-.	
##
"%
	#(("%"r#   r   c                   H    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)TestCategoricalReprc                      G d d      }t        t        d      D cg c]	  } |        c}      }t        |      }|j                         }t	        |       t        |       y c c}w )Nc                        e Zd ZdZdZdefdZy)ATestCategoricalRepr.test_categorical_repr_unicode.<locals>.Countyu   San SebastiánPRreturnc                 :    | j                   dz   | j                  z   S )Nz, )r'   staterK   s    r!   __repr__zJTestCategoricalRepr.test_categorical_repr_unicode.<locals>.County.__repr__-  s    yy4'$**44r#   N)r   r   r   r'   r   rB   r   r?   r#   r!   Countyr   )  s    #DE5# 5r#   r   =   )r   r   r   	to_seriesr   rB   )r   r   _catidxr   s         r!   test_categorical_repr_unicodez1TestCategoricalRepr.test_categorical_repr_unicode&  sP    	5 	5 U2Y76878CjmmoS	C 8s   A$c                    t        t        g d            }d}||j                         k(  sJ t        t        ddgdz              }|rd}nd}t        dd	      5  |t	        |      k(  sJ 	 d d d        t        d
      }t        t        ddg|d            }|rd}nd}||j                         k(  sJ y # 1 sw Y   JxY w)Nr   zO0    1
1    2
2    3
3    4
dtype: category
Categories (4, int64): [1, 2, 3, 4]ar      zb0     a
1     b
     ..
48    a
49    b
Length: 50, dtype: category
Categories (2, string): [a, b]zf0     a
1     b
     ..
48    a
49    b
Length: 50, dtype: category
Categories (2, object): ['a', 'b']r   rN   abcdefghijklmnopqrstuvwxyzT)
categoriesorderedzX0    a
1    b
dtype: category
Categories (26, string): [a < b < c < d ... w < x < y < z]zh0    a
1    b
dtype: category
Categories (26, object): ['a' < 'b' < 'c' < 'd' ... 'w' < 'x' < 'y' < 'z'])r	   r   __str__r   r   list)r   using_infer_stringr   r   levss        r!   test_categorical_reprz)TestCategoricalRepr.test_categorical_repr7  s    ;|,-C 	
 aiik!!!;SzB/0N R  .2 	"$q'>!>	" 01;SzdDIJM )  aiik!!!%	" 	"s   B55B>c                     t        t        g d            }d}t        |      |k(  sJ t        t        t        j                  d                  }dt        j
                  t               d}t        |      |k(  sJ y )Nr   zE0    1
1    2
2    3
dtype: category
Categories (3, int64): [1, 2, 3]r   f0    0
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
dtype: category
Categories (10, z ): [0, 1, 2, 3, ..., 6, 7, 8, 9]r	   r   r   rC   rG   r;   rQ   r   r3   r   s      r!   test_categorical_series_reprz0TestCategoricalRepr.test_categorical_series_reprc  sr    ;y)*$ Aw#~~;ryy}-. #?C Aw#~~r#   c                    t        t        g dd            }d}t        |      |k(  sJ t        t        t        j                  d      d            }dt        j
                  t               d}t        |      |k(  sJ y )Nr   Tr   zG0    1
1    2
2    3
dtype: category
Categories (3, int64): [1 < 2 < 3]r   r   z$): [0 < 1 < 2 < 3 ... 6 < 7 < 8 < 9]r   r   s      r!   $test_categorical_series_repr_orderedz8TestCategoricalRepr.test_categorical_series_repr_ordered}  sv    ;y$78& Aw#~~;ryy}d;< #CG Aw#~~r#   c                     t        ddd      }t        t        |            }d}t        |      |k(  sJ t        dddd      }t        t        |            }d}t        |      |k(  sJ y )	N2011-01-01 09:00hrN   r   r   a2  0   2011-01-01 09:00:00
1   2011-01-01 10:00:00
2   2011-01-01 11:00:00
3   2011-01-01 12:00:00
4   2011-01-01 13:00:00
dtype: category
Categories (5, datetime64[ns]): [2011-01-01 09:00:00, 2011-01-01 10:00:00, 2011-01-01 11:00:00,
                                 2011-01-01 12:00:00, 2011-01-01 13:00:00]
US/Easternr   r   tza  0   2011-01-01 09:00:00-05:00
1   2011-01-01 10:00:00-05:00
2   2011-01-01 11:00:00-05:00
3   2011-01-01 12:00:00-05:00
4   2011-01-01 13:00:00-05:00
dtype: category
Categories (5, datetime64[ns, US/Eastern]): [2011-01-01 09:00:00-05:00, 2011-01-01 10:00:00-05:00,
                                             2011-01-01 11:00:00-05:00, 2011-01-01 12:00:00-05:00,
                                             2011-01-01 13:00:00-05:00]r
   r	   r   r   r   r   r3   r   s       r!   %test_categorical_series_repr_datetimez9TestCategoricalRepr.test_categorical_series_repr_datetime  st    +#qA;s#$N Aw#~~+#q\R;s#$K Aw#~~r#   c                     t        ddd      }t        t        |d            }d}t        |      |k(  sJ t        dddd	      }t        t        |d            }d
}t        |      |k(  sJ y )Nr   r   rN   r   Tr   a6  0   2011-01-01 09:00:00
1   2011-01-01 10:00:00
2   2011-01-01 11:00:00
3   2011-01-01 12:00:00
4   2011-01-01 13:00:00
dtype: category
Categories (5, datetime64[ns]): [2011-01-01 09:00:00 < 2011-01-01 10:00:00 < 2011-01-01 11:00:00 <
                                 2011-01-01 12:00:00 < 2011-01-01 13:00:00]r   r   a  0   2011-01-01 09:00:00-05:00
1   2011-01-01 10:00:00-05:00
2   2011-01-01 11:00:00-05:00
3   2011-01-01 12:00:00-05:00
4   2011-01-01 13:00:00-05:00
dtype: category
Categories (5, datetime64[ns, US/Eastern]): [2011-01-01 09:00:00-05:00 < 2011-01-01 10:00:00-05:00 <
                                             2011-01-01 11:00:00-05:00 < 2011-01-01 12:00:00-05:00 <
                                             2011-01-01 13:00:00-05:00]r   r   s       r!   -test_categorical_series_repr_datetime_orderedzATestCategoricalRepr.test_categorical_series_repr_datetime_ordered  sx    +#qA;sD12O Aw#~~+#q\R;sD12K Aw#~~r#   c                     t        ddd      }t        t        |            }d}t        |      |k(  sJ t        ddd      }t        t        |            }d}t        |      |k(  sJ y )	Nr   r   rN   r   a  0    2011-01-01 09:00
1    2011-01-01 10:00
2    2011-01-01 11:00
3    2011-01-01 12:00
4    2011-01-01 13:00
dtype: category
Categories (5, period[h]): [2011-01-01 09:00, 2011-01-01 10:00, 2011-01-01 11:00, 2011-01-01 12:00,
                            2011-01-01 13:00]2011-01Mz0    2011-01
1    2011-02
2    2011-03
3    2011-04
4    2011-05
dtype: category
Categories (5, period[M]): [2011-01, 2011-02, 2011-03, 2011-04, 2011-05]r   r	   r   r   r   s       r!   #test_categorical_series_repr_periodz7TestCategoricalRepr.test_categorical_series_repr_period  sp    -CC;s#$1 Aw#~~93:;s#$L Aw#~~r#   c                     t        ddd      }t        t        |d            }d}t        |      |k(  sJ t        dd	d      }t        t        |d            }d
}t        |      |k(  sJ y )Nr   r   rN   r   Tr   a  0    2011-01-01 09:00
1    2011-01-01 10:00
2    2011-01-01 11:00
3    2011-01-01 12:00
4    2011-01-01 13:00
dtype: category
Categories (5, period[h]): [2011-01-01 09:00 < 2011-01-01 10:00 < 2011-01-01 11:00 < 2011-01-01 12:00 <
                            2011-01-01 13:00]r   r   z0    2011-01
1    2011-02
2    2011-03
3    2011-04
4    2011-05
dtype: category
Categories (5, period[M]): [2011-01 < 2011-02 < 2011-03 < 2011-04 < 2011-05]r   r   s       r!   +test_categorical_series_repr_period_orderedz?TestCategoricalRepr.test_categorical_series_repr_period_ordered  st    -CC;sD121 Aw#~~93:;sD12P Aw#~~r#   c                     t        dd      }t        t        |            }d}t        |      |k(  sJ t        dd      }t        t        |            }d}t        |      |k(  sJ y )N1 daysrN   r   z0   1 days
1   2 days
2   3 days
3   4 days
4   5 days
dtype: category
Categories (5, timedelta64[ns]): [1 days, 2 days, 3 days, 4 days, 5 days]1 hoursr   a  0   0 days 01:00:00
1   1 days 01:00:00
2   2 days 01:00:00
3   3 days 01:00:00
4   4 days 01:00:00
5   5 days 01:00:00
6   6 days 01:00:00
7   7 days 01:00:00
8   8 days 01:00:00
9   9 days 01:00:00
dtype: category
Categories (10, timedelta64[ns]): [0 days 01:00:00, 1 days 01:00:00, 2 days 01:00:00,
                                   3 days 01:00:00, ..., 6 days 01:00:00, 7 days 01:00:00,
                                   8 days 01:00:00, 9 days 01:00:00]r   r	   r   r   r   s       r!   &test_categorical_series_repr_timedeltaz:TestCategoricalRepr.test_categorical_series_repr_timedelta  sl    h2;s#$M Aw#~~i4;s#$H Aw#~~r#   c                     t        dd      }t        t        |d            }d}t        |      |k(  sJ t        dd      }t        t        |d            }d	}t        |      |k(  sJ y )
Nr   rN   r   Tr   z0   1 days
1   2 days
2   3 days
3   4 days
4   5 days
dtype: category
Categories (5, timedelta64[ns]): [1 days < 2 days < 3 days < 4 days < 5 days]r  r   a  0   0 days 01:00:00
1   1 days 01:00:00
2   2 days 01:00:00
3   3 days 01:00:00
4   4 days 01:00:00
5   5 days 01:00:00
6   6 days 01:00:00
7   7 days 01:00:00
8   8 days 01:00:00
9   9 days 01:00:00
dtype: category
Categories (10, timedelta64[ns]): [0 days 01:00:00 < 1 days 01:00:00 < 2 days 01:00:00 <
                                   3 days 01:00:00 ... 6 days 01:00:00 < 7 days 01:00:00 <
                                   8 days 01:00:00 < 9 days 01:00:00]r  r   s       r!   .test_categorical_series_repr_timedelta_orderedzBTestCategoricalRepr.test_categorical_series_repr_timedelta_ordered#  sp    h2;sD12Q Aw#~~i4;sD12I Aw#~~r#   N)r   r   r   r   r   r   r   r   r   r   r   r  r  r?   r#   r!   r   r   %  s6    "*"X448844@r#   r   )r   r   numpyrC   r   pandas._configr   pandasr   r   r   r   r	   r
   r   r   r   pandas._testing_testingr   r   r   r?   r#   r!   <module>r     sE   
   5 	 	 	 I" I"X\ \r#   