HOME


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

���h�A�@sddlmZddlZddlZddlZddlmZddljZ	ddl
jjZ
ejddgd�dd��Zejejdfejdfejdfejdfejdfejdfejdfejdfejdfejdfejdfejdfgd�d	d
��Zejejejd�ejfejejd�ejfejd
ejfejdejfejdejfejdejfejdejfejd
ejfejdejfejdejfejdejfejdejfejd
ejfejdejfejdejfejdejfejdejfejd
ejfejdejfejdejfejdejfejdejfgd�dd��ZGdd�d�ZGdd�d�Z dS)�)�datetimeN)�iNaTTF)�paramscCs|jS)N)�param)�request�r�8/tmp/pip-build-5_djhm0z/pandas/pandas/tests/test_take.py�	writeable
sr	cCs|jS)N)r)rrrr�dtype_can_hold_nasr
���g@g@y@�cCs|jS)N)r)rrrr�dtype_fill_out_dtype)src@s�eZdZejd�Zdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�TestTakez Incompatible type for fill_valuec	Cs�|\}}tjjddd�j|�}||j_ddddg}tjd|d�}tj|||d�|j	|�}t
j||�dddd	g}tjd|d�}|r�tj|||d�|j	|�}tj|d<t
j||�n:t
jt|jd��tj|||d�WdQRX|j	||d�dS)
Nr��r
)�dtype)�out�)�match���)�np�random�randint�astype�flagsr	�empty�algos�take_1d�take�tm�assert_almost_equal�nan�pytest�raises�	TypeError�
fill_error)	�selfr
r	r�can_hold_na�data�indexerr�expectedrrr�test_1d_with_outKs$


zTestTake.test_1d_with_outcCs�|\}}}tjjddd�j|�}ddddg}tj|||d�}|dddg|dddgkj�s`t�|d|kspt�|j|ks~t�ddddg}tj|||d�}|ddddg||kj�s�t�|j|ks�t�dS)Nrrrr
)�
fill_valuerr)	rrrrrr�all�AssertionErrorr)r(rrr.�	out_dtyper*r+�resultrrr�test_1d_fill_nonnags
$ zTestTake.test_1d_fill_nonnac
Cs�|\}}tjjddd�j|�}||j_ddddg}tjd|d�}tjd
|d�}tj|||dd�tj|||dd�|j	|dd	�}	|j	|dd	�}
t
j||	�t
j||
�ddddg}tjd|d�}tjd|d�}|�rRtj|||dd�tj|||dd�|j	|dd	�}	|j	|dd	�}
tj|	ddd�f<tj|
dd�df<t
j||	�t
j||
�nZxXt
||g�D]H\}}tjt|jd
��tj||||d�WdQRX|j	|||d��q`WdS)Nrr�rr
r)r)r�axis)r5)r)r4r)rr)r4rr)rr)r4r)rrrrrr	rr�take_ndr r!r"r#�	enumerater$r%r&r')
r(r
r	rr)r*r+�out0�out1�	expected0�	expected1�irrrr�test_2d_with_outws8zTestTake.test_2d_with_outcCs�|\}}}tjjddd�j|�}ddddg}tj||d|d�}|dddgdd�f|dddgdd�fkj�srt�|ddd�f|kj�s�t�|j|ks�t�tj||d|d�}|dd�dddgf|dd�dddgfkj�s�t�|dd�df|kj��st�|j|k�st�ddddg}tj||d|d�}|ddddgdd�f||dd�fkj��s`t�|j|k�spt�tj||d|d�}|dd�ddddgf|dd�|fkj��s�t�|j|k�s�t�dS)	Nrrr4rr
)r5r.)r4rr)	rrrrrr6r/r0r)r(rrr.r1r*r+r2rrr�test_2d_fill_nonna�s$
4422zTestTake.test_2d_fill_nonnacCsB|\}}tjjddd�j|�}ddddg}tjd|d�}tjd
|d�}tjd|d�}tj|||dd�tj|||dd�tj|||dd�|j|dd	�}	|j|dd	�}
|j|dd	�}tj	||	�tj	||
�tj	||�ddddg}tjd|d�}tjd|d�}tjd|d�}|�r�tj|||dd�tj|||dd�tj|||dd�|j|dd	�}	|j|dd	�}
|j|dd	�}tj
|	ddd�dd�f<tj
|
dd�ddd�f<tj
|dd�dd�df<tj	||	�tj	||
�tj	||�n\xZt|||g�D]H\}}
tj
t|jd
��tj|||
|d�WdQRX|j||
|d��q�WdS)Nrrr4rrr
)r)rr5)r5)r)r4rr)rrr)r4rr)r4rrr)rrr)r4rr)r4rr)rrrrrrr6r r!r"r#r7r$r%r&r')r(r
rr)r*r+r8r9Zout2r:r;Z	expected2r<rrrr�test_3d_with_out�sHzTestTake.test_3d_with_outcCs�|\}}}tjjddd�j|�}dddd	g}tj||d|d�}|dddgdd�dd�f|dddgdd�dd�fkj�s~t�|ddd�dd�f|kj�s�t�|j|ks�t�tj||d|d�}|dd�dddgdd�f|dd�dddgdd�fkj��st�|dd�ddd�f|kj��s&t�|j|k�s6t�tj||d|d�}|dd�dd�dddgf|dd�dd�dddgfkj��s�t�|dd�dd�df|kj��s�t�|j|k�s�t�ddddg}tj||d|d�}|ddddgdd�dd�f||dd�dd�fkj��st�|j|k�s*t�tj||d|d�}|dd�ddddgdd�f|dd�|dd�fkj��szt�|j|k�s�t�tj||d|d�}|dd�dd�ddddgf|dd�dd�|fkj��s�t�|j|k�s�t�dS)
Nrrr4rrr
)r5r.)r4rrr)	rrrrrr6r/r0r)r(rrr.r1r*r+r2rrr�test_3d_fill_nonna�s2
@"B$B$>>>zTestTake.test_3d_fill_nonnacCsPtjjd�jtj�}ddddg}tj||�}|j|�}tj|d<t	j
||�dS)N�
r
rrrr)rr�randnr�float32rrr r#r!r")r(�arrr+r2r,rrr�test_1d_other_dtypess

zTestTake.test_1d_other_dtypescCs�tjjdd�jtj�}ddddg}tj||dd�}|j|dd�}tj|d	<t	j
||�tj||dd�}|j|dd�}tj|dd�d
f<t	j
||�dS)NrAr4r
rrr)r5rrr)rrrBrrCrr6r r#r!r")r(rDr+r2r,rrr�test_2d_other_dtypess
zTestTake.test_2d_other_dtypescCsltjdddgtd�}tj|ddddg�}|jddddg�}tj||�tj|dddg�}|jtj	ksht
�dS)Nrr
)rrr)r�array�boolrrr r!�assert_numpy_array_equalr�object_r0)r(rDr2r,rrr�test_1d_bool&szTestTake.test_1d_boolcCs�tjdddgdddgdddggtd�}tj|ddddg�}|jddddgdd�}tj||�tj|ddddgdd�}|jddddgdd�}tj||�tj|dddg�}|jtj	ks�t
�dS)Nrr
)rr)r5r)rrGrHrr6r r!rIrrJr0)r(rDr2r,rrr�test_2d_bool0s&zTestTake.test_2d_boolcCs$tjjdd�jtj�}dddddg}tj||dd�}tj|�}tj||d|d�tj	||�|j
|dd�}tj|ddgdd�f<tj	||�tjt
|�|jdfdd	�}tj|||d
�tj||dd�}tj|�}tj||d|d�tj	||�|j
|dd�}tj|dd�ddgf<tj	||�dS)
Nrrrrr
)r5)r5rrC)r)rrr)rrrBrrCrr6�
empty_liker!r"r r#r�len�shape)r(rDr+r2�result2r,rrrr�test_2d_float32>s$

zTestTake.test_2d_float32c	Cstjjddd�d}|jdd�}dd	dd
dg}tj||dd�}tj|�}tj||d|d�tj||�|j	|dd�}t
|jtj�d	d
gdd�f<tj||�tj||dtdd
d
�d�}tj|�}tj|||dtdd
d
�d�tj||�|j	|dd�}tdd
d
�|d	d
gdd�f<tj||�tj||d
d�}tj|�}tj||d
|d�tj||�|j	|d
d�}t
|jtj�dd�d	d
gf<tj||�tj||d
tdd
d
�d�}tj|�}tj|||d
tdd
d
�d�tj||�|j	|d
d�}tdd
d
�|dd�d	d
gf<tj||�dS)Ni��i�Y�r4rlh�]zdatetime64[ns])rrrr
)r5)r5rri�)r5r.)rr5r.)r4rrr)
rrr�viewrr6rMr!r"r r�int64r)r(rDr+r2rPr,rrr�test_2d_datetime64ZsB



zTestTake.test_2d_datetime64cCs�tjd�jdd�}tj|ddg�}tjdddgddd	gg�}tj||�tj|dd
gd
dd�}tjdddgdddgg�}tj||�dS)N�rrrr
r�	rA�T)�
allow_fillr.rr)r�arange�reshaperr rGr!rI)r(rDr2r,rrr�test_take_axis_0�szTestTake.test_take_axis_0cCs�tjd�jdd�}tj|ddgdd�}tjddgddgd	d
gddgg�}tj||�tj|ddgdd
dd�}tjddgddgd	dgddgg�}tj||�tj	t
dd��tj|ddgdd
dd�WdQRXdS)NrUrrrr
)r5rr4��rVrWT)r5rXr.zindices are out-of-bounds)rrr)rrYrZrr rGr!rIr$r%�
IndexError)r(rDr2r,rrr�test_take_axis_1�s""zTestTake.test_take_axis_1N)�__name__�
__module__�__qualname__�re�compiler'r-r3r=r>r?r@rErFrKrLrQrTr[r_rrrrrGs
(3"	
0rc@sFeZdZdd�Zdd�Zejjdddg�dd	��Zd
d�Z	dd
�Z
dS)�TestExtensionTakecCsvtjddg�}d}tjt|d��tj|ddgdd�WdQRXd}tjt|d��tj|ddgd	d�WdQRXdS)
Nr
rzindices are out-of-bounds)rrT)rXz2index 2 is out of bounds for( axis 0 with)? size 2F)rrGr$r%r^rr )r(rD�msgrrr�test_bounds_check_large�sz)TestExtensionTake.test_bounds_check_largecCs�tjdddgtjd�}dd
dg}d}tjt|d��tj||dd	�WdQRXtj||�}tjdddgtjd�}tj	||�dS)Nr
rr)rrz7'indices' contains values less than allowed \(-2 < -1\))rT)rXr���)
rrGrSr$r%�
ValueErrorrr r!rI)r(rDr+rfr2r,rrr�test_bounds_check_small�s
z)TestExtensionTake.test_bounds_check_smallrXTFcCs`tjgtjd�}tj|g|d�}tj||�d}tjt	|d��tj|dg|d�WdQRXdS)N)r)rXzHcannot do a non-empty take from an empty axes.|indices are out-of-bounds)rr)
rrGrSrr r!rIr$r%r^)r(rXrDr2rfrrr�test_take_empty�sz!TestExtensionTake.test_take_emptycCs:tjtjg�ddgddd�}tjddg�}tj||�dS)Nr
Tg)rXr.rr)rr rrGr!rI)r(r2r,rrr�test_take_na_empty�sz$TestExtensionTake.test_take_na_emptycCs8dddg}tj|ddg�}tjddg�}tj||�dS)Nr
rrr)rr rrGr!rI)r(rDr2r,rrr�test_take_coerces_list�s
z(TestExtensionTake.test_take_coerces_listN)r`rarbrgrjr$�markZparametrizerkrlrmrrrrre�s
rey@@y@@y@@y@@)!rrcZnumpyrr$Zpandas._libsrZpandas._testingZ_testingr!Zpandas.core.algorithms�coreZ
algorithmsrZfixturer	Zfloat64rCZuint64Zuint32Zuint16Zuint8rSZint32Zint16Zint8rJZbool_r
Z
complex128rrrerrrr�<module>s^
`