o
    5cU                     @   sF   d dl Zd dlZd dlmZmZmZmZ d dlm	Z
 G dd dZdS )    N)CategoricalCategoricalDtypeCategoricalIndexIndexc                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS ) TestCategoricalIndexConstructorsc                 C   sH   d}t jt|d ttddd W d    d S 1 sw   Y  d S )Nzwithout passing datamatchabcdF
categoriesordered)tmassert_produces_warningFutureWarningr   listselfmsg r   h/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/tests/indexes/categorical/test_constructors.py)test_construction_without_data_deprecated   s   "zJTestCategoricalIndexConstructors.test_construction_without_data_deprecatedc                 C   sJ   d}t jt|d tdtddd W d    d S 1 sw   Y  d S )Nz-must be called with a collection of some kindr      r	   F)datar   r   )pytestraises	TypeErrorr   r   r   r   r   r   "test_construction_disallows_scalar   s   "zCTestCategoricalIndexConstructors.test_construction_disallows_scalarc                 C   s  t tdtddd}|j}t|}tj||dd |jrJ t|j}tj||dd |jr1J t g |d}t|jt| t|j	t
jg dd	 |jrQJ t td|d}t|jt| t|j	t
jg d
dd	 ttd}t |}t|jttd t|j	t
jg d
dd	 |jrJ t ||d}t|jt| t|j	t
jg d
dd	 |jrJ t |tdd}t |}t|jt| t|j	t
jg d
dd	 |jrJ t |tdd}t|jttd t|j	t
jg ddd	 |jr	J t |tddd}t|jttd t|j	t
jg ddd	 |js1J t |tddd}t |tdddd}tj||dd tt
|}t|ts[J t|t rcJ d S )Naabbcar	   Fr
   Texactr   int8dtype)r   r   r   r      r   abcab)r   r   r   r   r   category)r   r   r#   )r   r   r   r   r   assert_index_equalr   valuesassert_numpy_array_equalcodesnparrayr   
isinstance)r   cir   resultcexpectedr   r   r   test_construction   sr   






z2TestCategoricalIndexConstructors.test_constructionc                 C   s   t tdtddd}tt|dd}tj||dd tt| dd}tj||dd t tdtd	dd}tt|dd|j	}tj||dd tt
d
}t g d|dd}t ||dd}tj||dd d S )Nr   r%   Fr
   r(   r"   Tr   cab   )r   r   r$   )r   r   r   r-   r.   r   r)   tolistreorder_categoriesr   range)r   r0   r1   idxr3   r   r   r   test_construction_with_dtyped   s   z=TestCategoricalIndexConstructors.test_construction_with_dtypec                 C   s2   t g ddgd}t|j }|ddgksJ d S )NTFr    )r   sortedr   r7   )r   catr   r   r   r   ,test_construction_empty_with_bool_categories{   s   zMTestCategoricalIndexConstructors.test_construction_empty_with_bool_categoriesc              	   C   s  d  d  d}}}t||d}t||d}t|||d}tj||dd t||d}tj||dd d}tjt|d t|||d	 W d    n1 sPw   Y  tjt|d$ t	t
 t|||d	 W d    n1 stw   Y  W d    n1 sw   Y  tjt|d t|||d
 W d    n1 sw   Y  tjt|d- t	t
 t|||d
 W d    n1 sw   Y  W d    d S W d    d S 1 sw   Y  d S )Nza a b bzc b aTr
   r"   r   z?Cannot specify `categories` or `ordered` together with `dtype`.r   )r   r#   )r   r#   )splitr   r   r   r)   r   r   r   
ValueErrorr   r   )r   r   catsr   r#   r1   r3   r   r   r   r   (test_construction_with_categorical_dtype   s6   "zITestCategoricalIndexConstructors.test_construction_with_categorical_dtypeN)	__name__
__module____qualname__r   r   r4   r;   r>   rB   r   r   r   r   r      s    Jr   )numpyr-   r   pandasr   r   r   r   pandas._testing_testingr   r   r   r   r   r   <module>   s
    