U
    NZf                     @   s:   d dl Zd dlZd dlmZ d dlmZ G dd dZdS )    N)Categoricalc                   @   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 )TestTakec              	   C   sB   t ddg}td  |ddg}W 5 Q R X ||s>td S )Nabr   )r   tmassert_produces_warningtakeequalsAssertionError)selfcatresult r   M/tmp/pip-unpacked-wheel-nbcvw55c/pandas/tests/arrays/categorical/test_take.pytest_take_default_allow_fill   s    z%TestTake.test_take_default_allow_fillc              	   C   s4   t ddg}td  |ddg W 5 Q R X d S )Nr   r   r   )r   r   r   r	   )r   r   r   r   r   test_take_positive_no_warning   s    z&TestTake.test_take_positive_no_warningc              	   C   sL   t dddg}|rd}nd}tjt|d |jddg|d W 5 Q R X d S )	Nr   r   indices are out-of-boundsz2index 4 is out of bounds for( axis 0 with)? size 3match      
allow_fillr   pytestraises
IndexErrorr	   r   r   r   msgr   r   r   test_take_bounds   s    zTestTake.test_take_boundsc              	   C   sL   t g ddgd}|rd}nd}tjt|d |jdg|d W 5 Q R X d S )	Nr   r   
categoriesr   z-cannot do a non-empty take from an empty axesr   r   r   r   r   r   r   r   test_take_empty!   s    zTestTake.test_take_emptyc                 C   sT   t ddddgddg|d}|jdddgdd}t dddg|j|d}t|| d S )	Nr   r   r"   orderedr         Fr   r   r	   r"   r   assert_categorical_equalr   r%   r   r   expectedr   r   r   test_positional_take+   s      zTestTake.test_positional_takec                 C   sN   t ddgdddg|d}|jddgdd}t ddg|j|d}t|| d S )	Nr   r   cr$   r&   r   Fr   r(   r*   r   r   r   test_positional_take_unobserved3   s    z(TestTake.test_positional_take_unobservedc                 C   sL   t dddg}|jdddgdd}t dtjtjgddgd}t|| d S )Nr   r   r   r   Tr   r!   )r   r	   npnanr   r)   r   r   r   r+   r   r   r   test_take_allow_fill9   s    zTestTake.test_take_allow_fillc                 C   sL   t dddg}|jdddgddd}t dddgdddgd}t|| d S )Nr   r   r&   T)r   
fill_valuer!   r   r	   r   r)   r1   r   r   r    test_take_fill_with_negative_one@   s    z)TestTake.test_take_fill_with_negative_onec                 C   sL   t dddg}|jdddgddd}t dddgdddgd	}t|| d S )
Nr   r   r-   r   r&   r   Tr3   r   r!   r4   r1   r   r   r   test_take_fill_valueG   s    zTestTake.test_take_fill_valuec              	   C   sF   t dddg}d}tjt|d |jdddgd	d
d W 5 Q R X d S )Nr   r   r-   z9Cannot setitem on a Categorical with a new category \(d\)r   r   r&   r   dTr6   )r   r   r   	TypeErrorr	   )r   r   Zxprr   r   r   test_take_fill_value_new_raisesN   s    z(TestTake.test_take_fill_value_new_raisesN)__name__
__module____qualname__r   r   r    r#   r,   r.   r2   r5   r7   r:   r   r   r   r   r      s   

r   )	Znumpyr/   r   Zpandasr   Zpandas._testingZ_testingr   r   r   r   r   r   <module>   s   