o
    d	>                     @   s|   d dl m Z mZ d dlZ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mZ d dlmZ G dd dZG dd dZdS )    datetime	timedeltaN)Categorical	DataFrameIndexSeries
date_rangeoption_contextperiod_rangetimedelta_rangec                   @   s<  e Z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dd Zdd Zdd Zej	dg ddd Zdd Zej	dddgdd  Zd!d" Zej	d#d$d%gd&d'ggd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Zd>d? Zd@dA ZdBdC Z dDdE Z!d&S )FTestSeriesReprc                 C   s@   |}t tt||dd}g d}d|}t||ksJ d S )Nsthindex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   rangelenjoinrepr)self%lexsorted_two_level_string_multiindexr   serexpected r   b/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/pandas/tests/series/test_repr.pytest_multilevel_name_print   s
   
z)TestSeriesRepr.test_multilevel_name_printc                 C   s<   t g d}d|_dt|v sJ d |_dt|vsJ d S )N)r         test
Name: testName:r   r   r   r   sr   r   r   test_small_name_printing,   
   z'TestSeriesRepr.test_small_name_printingc                 C   s<   t td}d|_dt|v sJ d |_dt|vsJ d S )N  r    r!   r"   )r   r   r   r   r$   r   r   r   test_big_name_printing6   r'   z%TestSeriesRepr.test_big_name_printingc                 C   s(   t tdddtd}dt|v sJ d S )N2001010120020101r    )r   r   dtyper!   )r   r	   objectr   r$   r   r   r   test_empty_name_printing@   s   z'TestSeriesRepr.test_empty_name_printingargsr   )r   c                 C   s*   t ttjdtjdg|R  d d S )Nr(   r   )strr   nprandomrandnarange)r   r/   r   r   r   test_float_rangeD   s   *zTestSeriesRepr.test_float_rangec                 C   s   t ttd d S )Nr,   )r2   r   r-   r   r   r   r   test_empty_objectH   s   z TestSeriesRepr.test_empty_objectc                 C   s0   t | t |t tj|dd< t | d S )N      )r2   astypeintr3   NaN)r   string_seriesr   r   r   test_stringL   s   zTestSeriesRepr.test_stringc                 C   s   t | d S N)r2   )r   object_seriesr   r   r   test_objectT   s   zTestSeriesRepr.test_objectc                 C   s,   t | |d}d |d d d< t| d S )NOr   )r2   r=   r   )r   datetime_seriesotsr   r   r   test_datetimeW   s   
zTestSeriesRepr.test_datetimer   ) r   g333333?foou   αβγ7loooooooooooooooooooooooooooooooooooooooooooooooooooongrJ   barbaz)r   r   )rJ   r   gffffff@)   αu   βu   γ)rO   rM   c                 C   s   ||_ t| d S rB   )r   r   )r   r   r@   r   r   r   test_various_names^   s   z!TestSeriesRepr.test_various_namesc                 C   s(   t tjdtddd}t| d S )Nr(   rL   r   )r   r3   r4   r5   r6   r   )r   biggier   r   r   test_tuple_names   s   zTestSeriesRepr.test_tuple_nameargd     c                 C   s,   t tj|dd}t|}d|v sJ d S )Nr   r   zName: 0)r   r3   r4   r5   r   )r   rS   r   rep_strr   r   r   test_tidy_repr_name_0y   s   z$TestSeriesRepr.test_tidy_repr_name_0c                 C   sF   t dgddgd}dt|vsJ dt|vsJ dt|vs!J d S )Nza
	bza
	dza
	f)r   r   	za
)r   r   )r   r   r   r   r   test_newline   s   zTestSeriesRepr.test_newlinezname, expectedrJ   z#Series([], Name: foo, dtype: int64)NzSeries([], dtype: int64)c                 C   s$   t g tj|d}t||ksJ d S )N)r,   r   )r   r3   int64r   )r   r   r   r%   r   r   r   test_empty_int64   s   	zTestSeriesRepr.test_empty_int64c                 C   s    t dgd }d|_t| d S )N   אr(   title1r#   )r   ar   r   r   test_tidy_repr   s   zTestSeriesRepr.test_tidy_reprc                 C   s8   t dd tdD }t| | }|jdksJ d S )Nc                 S   s   g | ]}t tjd d qS )r   )r   r3   r4   r5   .0ir   r   r   
<listcomp>   s    z7TestSeriesRepr.test_repr_bool_fails.<locals>.<listcomp>r;   rI   )r   r   r   
readouterrerr)r   capsysr%   capturedr   r   r   test_repr_bool_fails   s   z#TestSeriesRepr.test_repr_bool_failsc                 C   s0   t g dtdd}t| d|_t| d S )Nr   r      rl   rV   )r^   r^   )r   r3   r\   r   r   r$   r   r   r   !test_repr_name_iterable_indexable   s   z0TestSeriesRepr.test_repr_name_iterable_indexablec                 C   s4   g d}g d}t ||d}t| tksJ d S )N)   r;   rl   r;   )u   σu   τu   υu   φr1   )r   type__repr__r2   )r   dataindex1dfr   r   r   test_repr_should_return_str   s   z*TestSeriesRepr.test_repr_should_return_strc                 C   s@   t dd  tttd W d    d S 1 sw   Y  d S )Ndisplay.max_rowsrU   )r
   r2   r   r   r9   r   r   r   test_repr_max_rows   s   "z!TestSeriesRepr.test_repr_max_rowsc                 C   s   t dgdd}t| d S )Nr^   u   בrV   )r   r2   )r   rs   r   r   r    test_unicode_string_with_unicode   s   z/TestSeriesRepr.test_unicode_string_with_unicodec                 C   sN   t dgdd}d}tjt|d t| W d    d S 1 s w   Y  d S )NabcrV   z2^'str' object cannot be interpreted as an integer$)match)r   pytestraises	TypeErrorbytes)r   rs   msgr   r   r   test_str_to_bytes_raises   s
   
"z'TestSeriesRepr.test_str_to_bytes_raisesc                 C   s   t dd tdD td}ttjt||}t| t	
d}t| d ds.J |jtjdt|d d	 }t| d  d S )
Nc                 S   s    g | ]}t d ddt| qS )  r   r   rb   r   r   r   re      s     zDTestSeriesRepr.test_timeseries_repr_object_dtype.<locals>.<listcomp>r(   r8   r0   zFreq:r   r   i  )r   r   r-   r   r3   r4   r5   r   r   tmmakeTimeSeries
splitlines
startswithilocrandint)r   r   tsts2r   r   r   !test_timeseries_repr_object_dtype   s   
z0TestSeriesRepr.test_timeseries_repr_object_dtypec                 C   sl   t d d}tdd dd tg d}|| ksJ W d    n1 s'w   Y  | d u s4J d S )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)rz   importorskipr
   r   _repr_latex_)r   resultr%   r   r   r   test_latex_repr   s   

zTestSeriesRepr.test_latex_reprc                 C   s6   t dtjg}tddg|d}d}t||ksJ d S )Nr   r   r1   z1.0    1
NaN    2
dtype: int64)r   r3   nanr   r   )r   rd   r%   expr   r   r   !test_index_repr_in_frame_with_nan   s   z0TestSeriesRepr.test_index_repr_in_frame_with_nanc                 C   s.   t dddd}|  td|d}t| d S )Nz1/1/1850z1/1/1950zA-DEC)freqr   r1   )r	   formatr   r   )r   rngr   r   r   r   test_format_pre_1900_dates   s   z)TestSeriesRepr.test_format_pre_1900_datesc                 C   s4   t dddtjjgdd}t|}d}||ksJ d S )Nr   r(   r   zM8[ns]r8   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   pdNaT_valuer   )r   seriesr   r   r   r   r   test_series_repr_nat   s
   z#TestSeriesRepr.test_series_repr_natc                 C   s(   t dgt}d}t||ksJ d S )Ng      ?z0    1.0
dtype: object)r   r=   r-   r   )r   r   r   r   r   r   test_float_repr   s   zTestSeriesRepr.test_float_reprc                 C   s6   t g ddd tjtjg}t|}d}||ksJ d S )Nr   r   rl      Tz4True    1
None    2
NaN     3
NaT     4
dtype: int64)r   r3   r   r   r   r   )r   r   r   r   r   r   r   test_different_null_objects  s   z*TestSeriesRepr.test_different_null_objects)"__name__
__module____qualname__r   r&   r)   r.   rz   markparametrizer7   r:   rA   rD   rH   rP   rR   rX   r[   r]   ra   rj   rm   rt   rv   rw   r   r   r   r   r   r   r   r   r   r   r   r   r      sR    





		r   c                   @   s\   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd ZdS )TestCategoricalReprc                    sL   G dd d t  fddtdD }t|}| }t| t| d S )Nc                   @   s"   e Zd ZdZdZdefddZdS )zATestCategoricalRepr.test_categorical_repr_unicode.<locals>.Countyu   San SebastiánPRreturnc                 S   s   | j d | j S )Nz, )r   stater9   r   r   r   rp     s   zJTestCategoricalRepr.test_categorical_repr_unicode.<locals>.County.__repr__N)r   r   r   r   r   r2   rp   r   r   r   r   County  s    r   c                    s   g | ]}  qS r   r   )rc   _r   r   r   re     s    zETestCategoricalRepr.test_categorical_repr_unicode.<locals>.<listcomp>=   )r   r   r   	to_seriesr   r2   )r   catidxr   r   r   r   test_categorical_repr_unicode  s   z1TestCategoricalRepr.test_categorical_repr_unicodec                 C   s   t tg d}d}|| ksJ t tddgd }d}tdd |t|ks,J W d    n1 s6w   Y  td	}t tddg|d
d}d}|| ksTJ d S )Nr   zO0    1
1    2
2    3
3    4
dtype: category
Categories (4, int64): [1, 2, 3, 4]r`   r      zf0     a
1     b
     ..
48    a
49    b
Length: 50, dtype: category
Categories (2, object): ['a', 'b']ru   r;   abcdefghijklmnopqrstuvwxyzT)
categoriesorderedzh0    a
1    b
dtype: category
Categories (26, object): ['a' < 'b' < 'c' < 'd' ... 'w' < 'x' < 'y' < 'z'])r   r   __str__r
   r   list)r   r`   r   levsr   r   r   test_categorical_repr!  s   z)TestCategoricalRepr.test_categorical_reprc                 C   s\   t tg d}d}t||ksJ t ttd}dt j d}t||ks,J d S )Nrk   zE0    1
1    2
2    3
dtype: category
Categories (3, int64): [1, 2, 3]
   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   r3   r6   int_r,   r   r%   r   r   r   r   test_categorical_series_repr<  s   z0TestCategoricalRepr.test_categorical_series_reprc                 C   sd   t tg ddd}d}t||ksJ t ttddd}dt j d}t||ks0J d S )Nrk   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   r   r   r   $test_categorical_series_repr_orderedV  s   z8TestCategoricalRepr.test_categorical_series_repr_orderedc                 C   sb   t dddd}tt|}d}t||ksJ t ddddd}tt|}d}t||ks/J d S )	N2011-01-01 09:00Hr;   r   periodsa2  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   r%   r   r   r   r   %test_categorical_series_repr_datetimep  s   	
z9TestCategoricalRepr.test_categorical_series_repr_datetimec                 C   sj   t dddd}tt|dd}d}t||ksJ t ddddd	}tt|dd}d
}t||ks3J d S )Nr   r   r;   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   r   r   r   -test_categorical_series_repr_datetime_ordered  s   	
zATestCategoricalRepr.test_categorical_series_repr_datetime_orderedc                 C   s`   t dddd}tt|}d}t||ksJ t dddd}tt|}d}t||ks.J d S )	Nr   r   r;   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   r   r   r   #test_categorical_series_repr_period  s   	z7TestCategoricalRepr.test_categorical_series_repr_periodc                 C   sh   t dddd}tt|dd}d}t||ksJ t dd	dd}tt|dd}d
}t||ks2J d S )Nr   r   r;   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   r   r   r   +test_categorical_series_repr_period_ordered  s   	z?TestCategoricalRepr.test_categorical_series_repr_period_orderedc                 C   s\   t ddd}tt|}d}t||ksJ t ddd}tt|}d}t||ks,J d S )N1 daysr;   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   r   r   r   &test_categorical_series_repr_timedelta  s   z:TestCategoricalRepr.test_categorical_series_repr_timedeltac                 C   sd   t ddd}tt|dd}d}t||ksJ t ddd}tt|dd}d	}t||ks0J d S )
Nr   r;   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   r   r   r   .test_categorical_series_repr_timedelta_ordered  s   zBTestCategoricalRepr.test_categorical_series_repr_timedelta_orderedN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s     r   )r   r   numpyr3   rz   pandasr   r   r   r   r   r	   r
   r   r   pandas._testing_testingr   r   r   r   r   r   r   <module>   s    (
 y