o
    5ct                     @   s   d dl mZm Z  d dlZd dlZd dlmZmZ d dlm	Z	m
Z
 d dlmZ d dlZd dlmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlm Z  G dd	 d	Z!dS )
    )datedatetimeN)IS64is_platform_windows)is_float_dtypeis_integer_dtype)CategoricalDtype)CategoricalCategoricalIndexDatetimeIndexIndexIntervalIntervalIndex
MultiIndexNaTSeries	Timestamp
date_rangeperiod_rangetimedelta_range)
Int64Indexc                   @   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d Zdd Zdd Zdd Zdd Zdd  Zejd!ed"d#d$d%ed"d#d$d&d'ed(d#d$d%gd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zejd3ed4d5d6ejgejg d7d8d9d:d;d<ejge !d=e !d>e"ge#d?e#d@e"ge#d?d&dAe#d@d&dAe"ggdBdC Z$ejdDdEdFgdGdH Z%dIdJ Z&ejdKdLd:d;gd:d<ggejdDdEdFgdMdN Z'dOdP Z(dQdR Z)dSdT Z*dUdV Z+dWdX Z,dYdZ Z-ejd[d\d] e.gd^d_ Z/d`da Z0dbdc Z1ddde Z2dfdg Z3dhdi Z4djdk Z5dldm Z6dndo Z7ejd[e8e9gdpdq Z:ejd[e8e9gdrds Z;dtdu Z<ejdvg dwg dxgdydz Z=d{d| Z>d}d~ Z?dd Z@dd ZAejddLdgdd ZBejddLdgdd ZCdd ZDdd ZEejdDg ddd ZFdd ZGdd ZHdd ZIdd ZJdd ZKejjLeM peN dddd ZOdd ZPdLS )TestCategoricalConstructorsc                 C   s@   t t tdddgd W d    d S 1 sw   Y  d S )NAB
categories)tmassert_produces_warningFutureWarningr	   self r!   g/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/tests/arrays/categorical/test_constructors.py"test_categorical_scalar_deprecated)   s   "z>TestCategoricalConstructors.test_categorical_scalar_deprecatedc                 C   sL   d}t jt|d tttdg W d    d S 1 sw   Y  d S )Nz3> 1 ndim Categorical are not supported at this timematchabcd)pytestraisesNotImplementedErrorr	   nparraylistr    msgr!   r!   r"   test_categorical_1d_only.   s   "z4TestCategoricalConstructors.test_categorical_1d_onlyc                 C   s   d}t }tg d}tj||d tg d|d W d    n1 s%w   Y  tj||d tjg dg d|d W d    d S 1 sIw   Y  d S )	Nz*'ordered' must either be 'True' or 'False'r         r$   r1   r2      ordered)r   r   r1   abcr   r6   )	TypeErrorr*   r+   r'   r(   r	   
from_codes)r    exp_msgexp_errr6   r!   r!   r"   test_validate_ordered4   s   "z1TestCategoricalConstructors.test_validate_orderedc                 C   sL   t g }tg }t|j| t g g dd}tg d}t|j| d S )Nr3   r   )r	   r   r   assert_index_equalr   r   )r    r:   expectedr!   r!   r"   test_constructor_emptyD   s   z2TestCategoricalConstructors.test_constructor_emptyc                 C   s2   t g ddgd}t|j }|ddgksJ d S )NTFr   )r	   sortedr   tolist)r    catr   r!   r!   r"   test_constructor_empty_booleanN   s   z:TestCategoricalConstructors.test_constructor_empty_booleanc                 C   sJ   t jg dtd}t|}tddgdd}t|j| |jdu s#J d S )N)r1   r1   r2   rH   rI   dtyperH   rI   Ftupleize_cols)	r*   r+   objectr	   r   r   rA   r   r6   r    valuesresultrB   r!   r!   r"   test_constructor_tuplesT   s
   z3TestCategoricalConstructors.test_constructor_tuplesc                 C   sn   t jtdftdftdftdfdgtdd d }t|}ttdftdfgdd}t|j| d S )Nz
2010-01-01z
2010-01-02r8   r9   rJ   FrL   )	r*   r+   r   rN   r	   r   r   rA   r   rO   r!   r!   r"   !test_constructor_tuples_datetimes[   s"   	
z=TestCategoricalConstructors.test_constructor_tuples_datetimesc                 C   st   t jdddt gdd}t|dd}|jrJ d}tjt|d	 t|d
d W d    d S 1 s3w   Y  d S )Nr1   r2   r4   OrJ   Fr5   zl'values' is not ordered, please explicitly specify the categories order by passing in a categories argument.r$   T)	r*   r+   r   nowr	   r6   r'   r(   r<   )r    arrfactorr.   r!   r!   r"   test_constructor_unsortableo   s   
"z7TestCategoricalConstructors.test_constructor_unsortablec                 C   sn   t tddtddtddgdd}ttddtddtddg}t |dd}t|| t|j| d S )Nr1   r2   r4      Tr5   )r	   r   r   r   assert_categorical_equalrA   r   )r    rQ   iiexpr!   r!   r"   test_constructor_interval~   s    z5TestCategoricalConstructors.test_constructor_intervalc                 C   sd  t jg dt jd}t|}t| | t|g dd}t| | t|g dd}t| | d}tjt	|d tdd	gg d
 W d    n1 sSw   Y  tjt	|d tddgg d W d    n1 ssw   Y  tg d}|j
rJ tg d}t|}t|| tg dg dd}t|}t|| tg dg dd}t|}t|| tg dg dd}t|g dd}t| |  t|jtg d tg dg dd}tt|}t|| tg dg dd}tt|}t|| tg d}ttg d}t|| tg dg dd}ttg dg dd}t|| tdd	dt jgg dd}t|jsSJ tt jdd	dg}t|jsdJ tt jdddg}t|jsuJ tt jdddg}t|jsJ tdg}t|jdksJ |jd dksJ t|jdksJ |jd dksJ tdg}t|jdksJ |jd dksJ t|jdksJ |jd dksJ tt td}W d    n	1 sw   Y  t|jdksJ |jd dksJ t|jdksJ |jd dks"J td  tg dg dd W d    n	1 s=w   Y  td  tg dg dd W d    n	1 s]w   Y  td  tg dg d tdd	gg dd}W d    n	1 sw   Y  td  tt jg ddg ddd W d    d S 1 sw   Y  d S )N)r8   r9   r:   r8   r9   r:   rJ   r7   r   r:   r9   r8   %Categorical categories must be uniquer$   r1   r2   )r1   r2   r2   r8   r9   )r8   r9   r9   r8   r9   r:   r8   )r8   r9   r:   d)r8   r:   r9   r4   r3          @      ?g      @r   )r   r1   r2   r   r1   r2   )r4         int64)r4   r2   r1   Tr;   )r*   r+   object_r	   r   assert_numpy_array_equal	__array__r'   r(   
ValueErrorr6   r\   rA   r   r   r   nanr   r   lencodesr   r   )r    exp_arrc1c2r.   rF   r!   r!   r"   test_constructor   s   




$z,TestCategoricalConstructors.test_constructorc                 C   s\   t g d}t g dddgd}t ||jd}t|| t t||jd}t|| d S )Nrb   r9   r:   r   )r	   r   r   r\   r   )r    c0rq   rr   c3r!   r!   r"   )test_constructor_with_existing_categories   s   zETestCategoricalConstructors.test_constructor_with_existing_categoriesc                 C   sH   d}t jt|d tddgdd W d    d S 1 sw   Y  d S )Nz.^Parameter 'categories' must be list-like, wasr$   r8   r9   r   )r'   r(   r<   r	   r-   r!   r!   r"   test_constructor_not_sequence	  s   "z9TestCategoricalConstructors.test_constructor_not_sequencec                 C   s   d}t jt|d ttjdddgtjdddgd W d    n1 s$w   Y  t jt|d tg dg dd W d    n1 sEw   Y  t jt|d ttdd	gttd	gd W d    d S 1 skw   Y  d S )
N%Categorical categories cannot be nullr$   r8   r9   r:   r   )Nr8   r9   r:   nat20160101)	r'   r(   rl   r	   r*   rm   r   r   r   r-   r!   r!   r"   test_constructor_with_null  s   "

"z6TestCategoricalConstructors.test_constructor_with_nullc                 C   s\   t tdtdd}t|jt| t tdtdd}t|jt|t|jd d S )Naabbcacabr   )	r
   r,   r   r\   rP   r	   astyperN   r   )r    cir!   r!   r"   test_constructor_with_index  s   z7TestCategoricalConstructors.test_constructor_with_indexc                 C   s   t g d}t dd dD }t|| t td}t|| ttdg dg t g ddd dD d}t|| t g dtdd}t|| d S )	Nr0   c                 s       | ]}|V  qd S Nr!   .0xr!   r!   r"   	<genexpr>-      zNTestCategoricalConstructors.test_constructor_with_generator.<locals>.<genexpr>r4   rg   r7   c                 s   r   r   r!   r   r!   r!   r"   r   5  r   r   )r	   r   r\   ranger   from_product)r    r^   rF   r!   r!   r"   test_constructor_with_generator(  s   z;TestCategoricalConstructors.test_constructor_with_generatorc                 C   sL   t td}t|}tj|j|dd tg d|d}tj|j|dd d S )Nr4   T)exactr1   r2   r   r   )r   r   r	   r   rA   r   )r    rngrF   r!   r!   r"    test_constructor_with_rangeindex:  s
   z<TestCategoricalConstructors.test_constructor_with_rangeindexdtlz1995-01-01 00:00:00rg   s)periodsfreq
US/Eastern)r   r   tzz1 dayc                 C   s   t |}t|}t||}d |j_t|j| t|j	t
jddd | }t|jd< t|}t|| }d |j_t|j| t
jg dt
jd}t|j	| t|}d|v s`J d S )Nrg   int8rJ   rT   )r   r1   r2   r4   rT   r   )r   r	   type_datar   r   rA   r   rj   ro   r*   arangecopyr   ilocdropnar+   r   repr)r    r   r   r:   rB   s2r^   rQ   r!   r!   r"   "test_constructor_with_datetimelikeD  s    
z>TestCategoricalConstructors.test_constructor_with_datetimelikec                 C   sN   t ddddd}|d }t|}t|j| tt|}t|j| d S )Nz2015-01-01 10:00Dr4   r   )r   r   r   )r   
_with_freqr	   r   rA   r   r   r    idxrQ   r!   r!   r"   -test_constructor_from_index_series_datetimetzi  s   
zITestCategoricalConstructors.test_constructor_from_index_series_datetimetzc                 C   s>   t  }t||g}|jjtksJ t|jd t u sJ d S )Nr   )r   todayr	   r   rK   rN   r   )r    vrF   r!   r!   r"   test_constructor_date_objectsr  s   z9TestCategoricalConstructors.test_constructor_date_objectsc                 C   sL   t dddd}|d }t|}t|j| tt|}t|j| d S )Nz1 daysr   r4   r   r   )r   r   r	   r   rA   r   r   r   r!   r!   r"   ,test_constructor_from_index_series_timedeltaz  s   
zHTestCategoricalConstructors.test_constructor_from_index_series_timedeltac                 C   sB   t dddd}t|}t|j| tt|}t|j| d S )Nz
2015-01-01r   r4   r   )r   r	   r   rA   r   r   r   r!   r!   r"   )test_constructor_from_index_series_period  s
   zETestCategoricalConstructors.test_constructor_from_index_series_periodrP   re   g333333?g?r3   rh   rJ   r8   r9   r:   z2014-01z2014-02z
2014-01-01z
2014-01-02)r   c                 C   s    t |}t |}t|| d S r   r	   r   r\   )r    rP   r:   rr   r!   r!   r"   test_constructor_invariant  s   z6TestCategoricalConstructors.test_constructor_invariantr6   TFc                 C   sT   g d}t ||d}tg d|d}tg d||d}t|| |j|u s(J d S )N)r9   r8   r:   r5   )r8   r9   r8   r:   rJ   r;   )r   r	   r   r\   r6   )r    r6   r   rK   rQ   rB   r!   r!   r"   test_constructor_with_dtype  s   
z7TestCategoricalConstructors.test_constructor_with_dtypec                 C   s   t ddgdd}d}tjt|d tddgddg|d W d    n1 s'w   Y  tjt|d tddgd|d W d    n1 sGw   Y  tjt|d tddgd	|d W d    d S 1 shw   Y  d S )
Nr8   r9   Tr5   z?Cannot specify `categories` or `ordered` together with `dtype`.r$   r   rK   r6   rK   F)r   r'   r(   rl   r	   r    rK   r.   r!   r!   r"   (test_constructor_dtype_and_others_raises  s   "zDTestCategoricalConstructors.test_constructor_dtype_and_others_raisesr   Nc                 C   s6   t ddg||dd}t ddg||d}t|| d S )Nr8   r9   categoryr   r6   rK   r;   r   )r    r   r6   rQ   rB   r!   r!   r"   test_constructor_str_category  s
   z9TestCategoricalConstructors.test_constructor_str_categoryc                 C   sD   t jtdd tddgdd W d    d S 1 sw   Y  d S )NzUnknown dtyper$   r1   r2   foorJ   )r'   r(   rl   r	   r   r!   r!   r"   test_constructor_str_unknown  s   "z8TestCategoricalConstructors.test_constructor_str_unknownc                 C   s:   t g dtdtdg}tdd |jD sJ d S )N)10r   r   r   c                 s   s    | ]	}t |tjV  qd S r   )
isinstancer*   str_r   r!   r!   r"   r     s    zGTestCategoricalConstructors.test_constructor_np_strs.<locals>.<genexpr>)r	   r*   r   allr   )r    rF   r!   r!   r"   test_constructor_np_strs  s   z4TestCategoricalConstructors.test_constructor_np_strsc                 C   sN   t g ddd}tg d}t||d}tg dg ddd}t|| d S )Nr7   Tr5   r8   r9   rc   rJ   r;   r   r	   r   r\   r    rK   rP   rQ   rB   r!   r!   r"   ,test_constructor_from_categorical_with_dtype  s   zHTestCategoricalConstructors.test_constructor_from_categorical_with_dtypec                 C   sJ   t d dd}tg d}t||d}tg dg ddd}t|| d S )NTr5   r   rJ   r;   r   r   r!   r!   r"   4test_constructor_from_categorical_with_unknown_dtype  s   zPTestCategoricalConstructors.test_constructor_from_categorical_with_unknown_dtypec                 C   sd   t g d}t |g dddd}t g dg ddd}t|| t |g ddd}t|| d S )Nr   r7   Tr   r   r;   r   rO   r!   r!   r"   (test_constructor_from_categorical_string  s   zDTestCategoricalConstructors.test_constructor_from_categorical_stringc                 C   s`   t ddgg dd}t ddgt g dd}t|| t ddgtg dd}t|| d S )Nr8   r9   r7   r   )r	   r   r\   r
   )r    rB   rQ   r!   r!   r"   ,test_constructor_with_categorical_categories  s
   zHTestCategoricalConstructors.test_constructor_with_categorical_categoriesklassc                 C   s   t j| tdS )NrJ   )r*   r+   rN   )r   r!   r!   r"   <lambda>  s    z$TestCategoricalConstructors.<lambda>c                 C   sH   |d|dg}t |}tddg}g d}t j||d}t|| d S )Nr8   r9   )r   rT   r1   )ro   rK   )r	   r   r=   r   r\   )r    r   nulls_fixturerP   rQ   rK   ro   rB   r!   r!   r"   test_construction_with_null  s   z7TestCategoricalConstructors.test_construction_with_nullc                 C   s`   t jtd|d}tjjddd}t|}tj||d}|j	j
|j
ks%J t|j	t| d S )Nrg   rJ   r4   )size)pdr+   r   r*   randomrandintr   r	   r=   r   rK   r   rA   r   )r    any_numeric_ea_dtypecatsro   rK   rX   r!   r!   r"   'test_from_codes_nullable_int_categories  s   zCTestCategoricalConstructors.test_from_codes_nullable_int_categoriesc                 C   s2   g d}t jg |d}t g |d}t|| d S )Nr7   r   r	   r=   r   r\   )r    rF   rQ   rB   r!   r!   r"   test_from_codes_empty  s   z1TestCategoricalConstructors.test_from_codes_emptyc                 C   s   t ddgd}d}tjt|d tjddg|jd W d    n1 s%w   Y  tjt|d tjddg|d W d    d S 1 sFw   Y  d S )Nr1   r2   r   zcodes need to be between r$   rJ   r   r'   r(   rl   r	   r=   r   r   r!   r!   r"   "test_from_codes_too_few_categories     "z>TestCategoricalConstructors.test_from_codes_too_few_categoriesc                 C   s   t ddgd}d}tjt|d tjdg|jd W d    n1 s$w   Y  tjt|d tjdg|d W d    d S 1 sDw   Y  d S )Nr1   r2   r   $codes need to be array-like integersr$   r8   rJ   r   r   r!   r!   r"   test_from_codes_non_int_codes  s   "z9TestCategoricalConstructors.test_from_codes_non_int_codesc                 C   sJ   t jtdd tjg dg dd W d    d S 1 sw   Y  d S )Nra   r$   r0   )r8   r8   r9   r   r'   r(   rl   r	   r=   r   r!   r!   r"   %test_from_codes_non_unique_categories"  s   "zATestCategoricalConstructors.test_from_codes_non_unique_categoriesc                 C   sN   t jtdd tjg dddtjgd W d    d S 1 s w   Y  d S )Nrx   r$   r0   r8   r9   r   )r'   r(   rl   r	   r=   r*   rm   r   r!   r!   r"    test_from_codes_nan_cat_included&  s   "z<TestCategoricalConstructors.test_from_codes_nan_cat_includedc                 C   s   t g dd}d}tjt|d tjg d|jd W d    n1 s%w   Y  tjt|d tjg d|d W d    d S 1 sFw   Y  d S )Nr7   r   z3codes need to be between -1 and len\(categories\)-1r$   )r1   r2   rJ   r   r   r!   r!   r"   test_from_codes_too_negative*  r   z8TestCategoricalConstructors.test_from_codes_too_negativec                 C   s`   t g dd}tg ddd}tjg d|jd}t|| tjg d|d}t|| d S )Nr7   r   Fr5   r0   rJ   )r   r	   r=   r   r   r\   )r    rK   r^   resr!   r!   r"   test_from_codes2  s   z+TestCategoricalConstructors.test_from_codesc                 C   s>   t ddgg dd}t jddg|g dd}t|| d S )Nr8   r9   r7   r   r   r1   r   )r    r   rB   rQ   r!   r!   r"   +test_from_codes_with_categorical_categories;  s   zGTestCategoricalConstructors.test_from_codes_with_categorical_categoriesc                 C   sL   t jtdd tddg|g d W d    d S 1 sw   Y  d S )Nra   r$   r   r1   )r8   r9   r8   r   )r    r   r!   r!   r"   6test_from_codes_with_non_unique_categorical_categoriesC  s   "zRTestCategoricalConstructors.test_from_codes_with_non_unique_categorical_categoriesc                 C   s   ddt jg}tg dd}tjtdd tj||jd W d    n1 s'w   Y  tjtdd tj||d W d    d S 1 sFw   Y  d S )Nr1   r2   r7   r   r   r$   rJ   )	r*   rm   r   r'   r(   rl   r	   r=   r   )r    ro   rK   r!   r!   r"   test_from_codes_with_nan_codeH  s   "z9TestCategoricalConstructors.test_from_codes_with_nan_codero   )re   rd   r   )g?rd   r   c                 C   s   t g dd}d}tjt|d t||j W d    n1 s"w   Y  tjt|d tj||d W d    d S 1 sAw   Y  d S )Nr7   r   r   r$   rJ   r   )r    ro   rK   r.   r!   r!   r"   test_from_codes_with_floatQ  s   "z6TestCategoricalConstructors.test_from_codes_with_floatc                 C   s   d}t jt|d tjddgddgtddgd W d    n1 s$w   Y  t jt|d tjddgdtddgd	 W d    d S 1 sJw   Y  d S )
NzCannot specifyr$   r   r1   r8   r9   r   Tr   )r'   r(   rl   r	   r=   r   r-   r!   r!   r"   !test_from_codes_with_dtype_raises]  s   "z=TestCategoricalConstructors.test_from_codes_with_dtype_raisesc                 C   sF   d}t jt|d tddg W d    d S 1 sw   Y  d S )NzBoth were Noner$   r   r1   r   r-   r!   r!   r"   test_from_codes_neitheri  s   "z3TestCategoricalConstructors.test_from_codes_neitherc                 C   sL   t jddgdd}ddg}tj||d}tj|t|d}t|| d S )Nr   r1   Int64rJ   r8   r9   r   )r   r+   r	   r=   to_numpyintr   r\   )r    ro   r   rQ   rB   r!   r!   r"   !test_from_codes_with_nullable_intn  s
   z=TestCategoricalConstructors.test_from_codes_with_nullable_intc                 C   s`   t jdd gdd}ddg}d}tjt|d tj||d W d    d S 1 s)w   Y  d S )	Nr   r   rJ   r8   r9   zcodes cannot contain NA valuesr$   r   )r   r+   r'   r(   rl   r	   r=   )r    ro   r   r.   r!   r!   r"   +test_from_codes_with_nullable_int_na_raisesw  s   "zGTestCategoricalConstructors.test_from_codes_with_nullable_int_na_raisesrK   r   c                 C   sD   ddg}t jg ddd}t|||}t||}t|| d S )Nr8   r9   )r   r   r1   r1   i8rJ   r*   r+   r	   _from_inferred_categoriesr=   r   r\   r    rK   r   ro   rQ   rB   r!   r!   r"   test_from_inferred_categories  s
   z9TestCategoricalConstructors.test_from_inferred_categoriesc                 C   sL   ddg}t jg ddd}t|||}tg dddg}t|| d S )Nr9   r8   )r   r1   r1   r1   r   rJ   )r1   r   r   r   r   r   r!   r!   r"   #test_from_inferred_categories_sorts  s
   z?TestCategoricalConstructors.test_from_inferred_categories_sortsc                 C   s^   g d}t jg ddd}tg ddd}t|||}tg dg ddd	}t|| d S )
Nr   )r   r1   r   r2   r   rJ   r`   Tr5   )r8   r9   r8   rc   r;   )r*   r+   r   r	   r   r   r\   r    r   ro   rK   rQ   rB   r!   r!   r"   #test_from_inferred_categories_dtype  s   z?TestCategoricalConstructors.test_from_inferred_categories_dtypec                 C   sV   g d}t jg ddd}tddg}t|||}tdddt jg}t|| d S )N)r   2bad)r   r   r1   r2   r   rJ   r1   r2   )r*   r+   r   r	   r   rm   r   r\   r   r!   r!   r"   %test_from_inferred_categories_coerces  s   zATestCategoricalConstructors.test_from_inferred_categories_coerces)NTFc                 C   s&   t g d|d}|jt|ksJ d S )Nr0   r5   )r	   r6   bool)r    r6   rF   r!   r!   r"   test_construction_with_ordered  s   z:TestCategoricalConstructors.test_construction_with_orderedc                 C   s>   g d}t |}t|jt| tt|t| d S )N)r1   r2   y      @      ?)r	   r   rA   r   r   rj   r*   r+   )r    rP   rq   r!   r!   r"   test_constructor_imaginary  s   z6TestCategoricalConstructors.test_constructor_imaginaryc                 C   s6   t tjg dtd}tg d}|j|sJ d S )N)r:   rS   r9   r8   r:   rJ   )rS   r   r:   )r	   r*   r+   rN   r   r   equals)r    r:   expected_indexr!   r!   r"   "test_constructor_string_and_tuples  s   z>TestCategoricalConstructors.test_constructor_string_and_tuplesc                 C   s  t jdddd}t||d}tjddd}t|j| t|j	| t|}t|j| t|j	| tt
|}t|j| t|j	| tt
|t
|d}t|j| t|j	| |g d}t||d}t|jtjg ddd t|j	| t jdd	d
d}t||d}tjg ddd}t|j| t|j	| ttddtddg}t||d}tjddgdd}t|j| t|j	| d S )Nr   
   r   r   r   rJ   r         r4   )r   	   rT   r2   r1   )r   interval_ranger	   r*   r   r   rj   ro   rA   r   r,   taker+   r   r   )r    r   rF   expected_codesrP   r!   r!   r"   test_interval  s8   z)TestCategoricalConstructors.test_intervalc                 C   sX   t jj|gd }t|}|j|jjksJ ttt jt jg|jd}t	
|| d S )Nr2   rJ   )r   arraysStringArray_from_sequencer	   rK   r   r   NAr   r\   )r    r   rX   rQ   rB   r!   r!   r"   )test_categorical_extension_array_nullable  s
   zETestCategoricalConstructors.test_categorical_extension_array_nullablec                 C   sX   t tdd}t j|d dd}|j|ju sJ t j|d dd}t||r*J d S )Nrg   r2   F)rK   r   T)r	   r*   r   repeatr  _codesr   shares_memory)r    rF   rQ   r!   r!   r"   test_from_sequence_copy  s
   z3TestCategoricalConstructors.test_from_sequence_copyz*Incorrectly raising in astype_overflowsafe)reasonc                 C   sB   t dd}|d d d  }t||d}||k sJ d S )Nr   zM8[D]r2   r   )r*   r   viewr   r	   r   )r    r   rP   rF   r!   r!   r"   $test_constructor_datetime64_non_nano  s   z@TestCategoricalConstructors.test_constructor_datetime64_non_nanoc                 C   s2   t ddd}|j}t|}|jj}||ksJ d S )Nz
2016-01-01rg   r   )r   r   r	   r   )r    dtirB   rF   rQ   r!   r!   r"   test_constructor_preserves_freq  s
   z;TestCategoricalConstructors.test_constructor_preserves_freq)Q__name__
__module____qualname__r#   r/   r@   rC   rG   rR   rU   rZ   r_   rs   rv   rw   r{   r   r   r   r'   markparametrizer   r   r   r   r   r   r   r*   r+   rm   r   Periodr   r   r   r   r   r   r   r   r   r   r   r   r,   r   r   r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  xfailr   r   r  r  r!   r!   r!   r"   r   (   s    
	v	

		








		

	
	



*
r   )"r   r   numpyr*   r'   pandas.compatr   r   pandas.core.dtypes.commonr   r   pandas.core.dtypes.dtypesr   pandasr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   pandas._testing_testingr   pandas.core.apir   r   r!   r!   r!   r"   <module>   s    <