HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/pandas/tests/series/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/pandas/tests/series/__pycache__/test_repr.cpython-36.pyc
3

���h�:�@s~ddlmZmZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZddljZGdd�d�ZGdd�d�ZdS)�)�datetime�	timedeltaN)	�Categorical�	DataFrame�Index�
MultiIndex�Series�
date_range�option_context�period_range�timedelta_rangec@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �TestSeriesReprc
Cs�tddddgdddggdddd	d	d
d
dddg
dd	d
dd	d	d
dd	d
g
gdd
gd�}ttt|��|dd�}ddddddddddddg}dj|�}t|�|ks�t�dS)N�foo�bar�bazZquxZoneZtwoZthreer����first�second)Zlevels�codes�namesZsth)�index�namez
first  secondzfoo    one       0z       two       1z       three     2zbar    one       3z       two       4zbaz    two       5z       three     6zqux    one       7z       two       8z       three     9zName: sth, dtype: int64�
)rr�range�len�join�repr�AssertionError)�selfr�s�expected�r#�?/tmp/pip-build-5_djhm0z/pandas/pandas/tests/series/test_repr.py�test_multilevel_name_prints&.
z)TestSeriesRepr.test_multilevel_name_printcCs�tdddg�}d|_dt|�ks$t�d|_dt|�ks:t�ttd��}d|_dt|�ks\t�d|_dt|�ksrt�ttdd	�dtd
�}dt|�ks�t�dS)Nrrr�testz
Name: testzName:i�Z20010101Z20020101)rr�dtype)rrrrrr	�object)r r!r#r#r$�test_name_printing.sz!TestSeriesRepr.test_name_printingc
Cs�t|�t|�t|jt��t|�tttjd�tjd�d��tttjd�tjddd%d�d��tttd��tj	|dd�<t|�|jd	�}d|ddd
�<t
|�xd+D]}||_t
|�q�Wttjd�tjd�d,d�}t
|�ttjjd�dd�}t
|�}d|k�st
�ttjjd�dd�}t
|�}d|k�s:t
�tdgddgd�}dt
|�k�s^t
�d t
|�k�spt
�d!t
|�k�s�t
�tgtjd
d"�}	t
|	�d#k�s�t
�tgtjdd"�}	t
|	�d$k�s�t
�dS)-Ni�)rrr)�step)r'���Or��333333�?r�αβγ�7loooooooooooooooooooooooooooooooooooooooooooooooooooongrr�ffffff@�α�β�γ)rr�d)rzName: 0i�za

	bza

	dza

	f)rr�	�
za
)r'rz#Series([], Name: foo, dtype: int64)zSeries([], dtype: int64)����rrr�rr�rrr2�r3r4r5�r3r)r.rr/rr0r1r:r;r<r=r>)rrr)�strZastype�intr�tm�randn�np�aranger(�NaNrr�randomr�int64)
r Zdatetime_seriesZ
string_seriesZ
object_seriesZotsrZbiggie�serZrep_strr!r#r#r$�	test_reprDsV"
zTestSeriesRepr.test_reprcCs tdgd�}d|_t|�dS)Nuאi�Ztitle1)rrr)r �ar#r#r$�test_tidy_repr�szTestSeriesRepr.test_tidy_reprcCs8tdd�td�D��}t|�|j�}|jdks4t�dS)NcSsg|]}ttjjdd���qS)r)rrCrFrB)�.0�ir#r#r$�
<listcomp>�sz7TestSeriesRepr.test_repr_bool_fails.<locals>.<listcomp>r+r.)rrrZ
readouterr�errr)r Zcapsysr!Zcapturedr#r#r$�test_repr_bool_fails�sz#TestSeriesRepr.test_repr_bool_failscCs2tdddgtjd�d�}t|�d|_t|�dS)Nrrr)r�א)rQ)rQrQ)rrCrGrr)r r!r#r#r$�!test_repr_name_iterable_indexable�sz0TestSeriesRepr.test_repr_name_iterable_indexablecCs<ddddg}ddddg}t||d�}t|j�tk�s8t�dS)	N�r+ruσuτuυuφ)r)r�type�__repr__r?r)r �dataZindex1�dfr#r#r$�test_repr_should_return_str�sz*TestSeriesRepr.test_repr_should_return_strcCs,tjdd��tttd���WdQRXdS)NZmax_rowsi�)�pdr
r?rr)r r#r#r$�test_repr_max_rows�sz!TestSeriesRepr.test_repr_max_rowscCstdgdd�}t|�dS)Nuאuב)r)rr?)r rWr#r#r$� test_unicode_string_with_unicode�sz/TestSeriesRepr.test_unicode_string_with_unicodec	Cs8tdgdd�}d}tjt|d��t|�WdQRXdS)N�abc)rz2^'str' object cannot be interpreted as an integer$)�match)r�pytestZraises�	TypeError�bytes)r rW�msgr#r#r$�test_str_to_bytes_raises�sz'TestSeriesRepr.test_str_to_bytes_raisescCs�tdd�td�D�td�}ttjjt|��|�}t|�t	j
d�}t|�j�d	jd�s\t
�|jtjjdt|�dd�}t|�j�d
dS)NcSs g|]}tddd�t|��qS)i�r)rr)rLrMr#r#r$rN�szDTestSeriesRepr.test_timeseries_repr_object_dtype.<locals>.<listcomp>i�)r'rzFreq:ri�r9r9)rrr(rrCrFrBrrrAZmakeTimeSeries�
splitlines�
startswithrZiloc�randint)r r�tsZts2r#r#r$�!test_timeseries_repr_object_dtype�s
z0TestSeriesRepr.test_timeseries_repr_object_dtypecCsPd}tdddd��$tdddg�}||j�ks2t�WdQRX|j�dksLt�dS)	Nz�\begin{tabular}{ll}
\toprule
{} &         0 \\
\midrule
0 &  $\alpha$ \\
1 &         b \\
2 &         c \\
\bottomrule
\end{tabular}
zdisplay.latex.escapeFzdisplay.latex.reprTz$\alpha$�b�c)r
rZ_repr_latex_r)r �resultr!r#r#r$�test_latex_repr�s

zTestSeriesRepr.test_latex_reprcCs6tdtjg�}tddg|d�}d}t|�|ks2t�dS)Nrr)rz1.0    1
NaN    2
dtype: int64)rrC�nanrrr)r rMr!�expr#r#r$�!test_index_repr_in_frame_with_nan�sz0TestSeriesRepr.test_index_repr_in_frame_with_nancCs.tdddd�}|j�td|d�}t|�dS)Nz1/1/1850z1/1/1950zA-DEC)�freqr)r)r	�formatrr)r �rngrfr#r#r$�test_format_pre_1900_dates�sz)TestSeriesRepr.test_format_pre_1900_datescCs4tdddtjjgdd�}t|�}d}||ks0t�dS)Nri�i�zM8[ns])r'z�0   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])rrYZNaT�valuerr)r Zseriesrjr"r#r#r$�test_series_repr_nat�sz#TestSeriesRepr.test_series_repr_natN)�__name__�
__module__�__qualname__r%r)rIrKrPrRrXrZr[rbrgrkrnrrrtr#r#r#r$r
sA		
r
c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestCategoricalReprcsPGdd�d��tj�fdd�td�D��}tj|�}|j�}t|�t|�dS)Nc@s"eZdZdZdZed�dd�ZdS)zATestCategoricalRepr.test_categorical_repr_unicode.<locals>.CountyuSan SebastiánZPR)�returncSs|jd|jS)Nz, )r�state)r r#r#r$rU�szJTestCategoricalRepr.test_categorical_repr_unicode.<locals>.County.__repr__N)rurvrwrrzr?rUr#r#r#r$�County�sr{csg|]
}���qSr#r#)rL�_)r{r#r$rN�szETestCategoricalRepr.test_categorical_repr_unicode.<locals>.<listcomp>�=)rYrrrZ	to_seriesrr?)r �cat�idxrHr#)r{r$�test_categorical_repr_unicode�s
z1TestCategoricalRepr.test_categorical_repr_unicodec
Cs�ttddddg��}d}||j�ks(t�ttddgd	��}d}tdd��|t|�ks\t�WdQRXtd�}ttddg|dd��}d}||j�ks�t�dS)Nrrr�z0    1
1    2
2    3
3    4
z3dtype: category
Categories (4, int64): [1, 2, 3, 4]rJrh�z0     a
1     b
z     ..
z48    a
49    b
z>Length: 50, dtype: category
Categories (2, object): ['a', 'b']zdisplay.max_rowsr+�abcdefghijklmnopqrstuvwxyzT)�
categories�orderedz0    a
1    b
zZdtype: category
Categories (26, object): ['a' < 'b' < 'c' < 'd' ... 'w' < 'x' < 'y' < 'z']zO0    1
1    2
2    3
3    4
dtype: category
Categories (4, int64): [1, 2, 3, 4]z0     a
1     b
     ..
z(0     a
1     b
     ..
48    a
49    b
zf0     a
1     b
     ..
48    a
49    b
Length: 50, dtype: category
Categories (2, object): ['a', 'b']zh0    a
1    b
dtype: category
Categories (26, object): ['a' < 'b' < 'c' < 'd' ... 'w' < 'x' < 'y' < 'z'])rr�__str__rr
r�list)r rJrmZlevsr#r#r$�test_categorical_reprsz)TestCategoricalRepr.test_categorical_reprcCsPttdddg��}d}t|�|ks&t�tttjd���}d}t|�|ksLt�dS)NrrrzE0    1
1    2
2    3
dtype: category
Categories (3, int64): [1, 2, 3]�
z�0    0
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
dtype: category
Categories (10, int64): [0, 1, 2, 3, ..., 6, 7, 8, 9])rrrrrCrD)r r!rmr#r#r$�test_categorical_series_reprsz0TestCategoricalRepr.test_categorical_series_reprcCsXttdddgdd��}d}t|�|ks*t�tttjd�dd��}d}t|�|ksTt�dS)	NrrrT)r�zG0    1
1    2
2    3
dtype: category
Categories (3, int64): [1 < 2 < 3]r�z�0    0
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
dtype: category
Categories (10, int64): [0 < 1 < 2 < 3 ... 6 < 7 < 8 < 9])rrrrrCrD)r r!rmr#r#r$�$test_categorical_series_repr_ordered8sz8TestCategoricalRepr.test_categorical_series_repr_orderedcCsbtdddd�}tt|��}d}t|�|ks.t�tddddd�}tt|��}d}t|�|ks^t�dS)	Nz2011-01-01 09:00�Hr+)ro�periodsa20   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]z
US/Eastern)ror��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	rrrr)r rr!rmr#r#r$�%test_categorical_series_repr_datetimeRs	z9TestCategoricalRepr.test_categorical_series_repr_datetimecCsjtdddd�}tt|dd��}d}t|�|ks2t�tddddd	�}tt|dd��}d
}t|�|ksft�dS)Nz2011-01-01 09:00r�r+)ror�T)r�a60   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]z
US/Eastern)ror�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	rrrr)r rr!rmr#r#r$�-test_categorical_series_repr_datetime_orderedns	zATestCategoricalRepr.test_categorical_series_repr_datetime_orderedcCs`tdddd�}tt|��}d}t|�|ks.t�tdddd�}tt|��}d}t|�|ks\t�dS)	Nz2011-01-01 09:00r�r+)ror�a0    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]z2011-01�Mz�0    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])rrrrr)r rr!rmr#r#r$�#test_categorical_series_repr_period�sz7TestCategoricalRepr.test_categorical_series_repr_periodcCshtdddd�}tt|dd��}d}t|�|ks2t�tdd	dd�}tt|dd��}d
}t|�|ksdt�dS)Nz2011-01-01 09:00r�r+)ror�T)r�a0    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]z2011-01r�z�0    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])rrrrr)r rr!rmr#r#r$�+test_categorical_series_repr_period_ordered�sz?TestCategoricalRepr.test_categorical_series_repr_period_orderedcCs\tddd�}tt|��}d}t|�|ks,t�tddd�}tt|��}d}t|�|ksXt�dS)Nz1 daysr+)r�z�0   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]z1 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rrrr)r rr!rmr#r#r$�&test_categorical_series_repr_timedelta�sz:TestCategoricalRepr.test_categorical_series_repr_timedeltacCsdtddd�}tt|dd��}d}t|�|ks0t�tddd�}tt|dd��}d	}t|�|ks`t�dS)
Nz1 daysr+)r�T)r�z�0   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]z1 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rrrr)r rr!rmr#r#r$�.test_categorical_series_repr_timedelta_ordered�szBTestCategoricalRepr.test_categorical_series_repr_timedelta_orderedN)
rurvrwr�r�r�r�r�r�r�r�r�r�r#r#r#r$rx�s rx)rrZnumpyrCr^ZpandasrYrrrrrr	r
rrZpandas._testingZ_testingrAr
rxr#r#r#r$�<module>s,
]