
    h                     L    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      Zy)    N)CategoricalCategoricalDtypeCategoricalIndexIndexc                   *    e Zd Zd Zd Zd Zd Zd Zy) TestCategoricalIndexConstructorsc                 "   d}t        j                  t        |      5  t        dt	        d      d       d d d        t        j                  t        |      5  t        t	        d      d       d d d        y # 1 sw Y   DxY w# 1 sw Y   y xY w)Nz-must be called with a collection of some kindmatch   abcdF)data
categoriesorderedr   r   )pytestraises	TypeErrorr   list)selfmsgs     WD:\jyotish\venv\Lib\site-packages\pandas/tests/indexes/categorical/test_constructors.py"test_construction_disallows_scalarzCTestCategoricalIndexConstructors.test_construction_disallows_scalar   s^    =]]9C0!VeL 1]]9C0VeD 10 1000s   A9B9BBc                 	   t        t        d      t        d      d      }|j                  }t        |      }t	        j
                  ||d       |j                  rJ t        |j                        }t	        j
                  ||d       |j                  rJ t        g |      }t	        j
                  |j                  t        |             t	        j                  |j                  t        j                  g d	             |j                  rJ t        t        d      |      }t	        j
                  |j                  t        |             t	        j                  |j                  t        j                  g d
d	             t        t        d            }t        |      }t	        j
                  |j                  t        t        d                   t	        j                  |j                  t        j                  g d
d	             |j                  rJ t        ||      }t	        j
                  |j                  t        |             t	        j                  |j                  t        j                  g d
d	             |j                  rJ t        |t        d            }t        |      }t	        j
                  |j                  t        |             t	        j                  |j                  t        j                  g d
d	             |j                  rJ t        |t        d            }t	        j
                  |j                  t        t        d                   t	        j                  |j                  t        j                  g dd	             |j                  rJ t        |t        d      d      }t	        j
                  |j                  t        t        d                   t	        j                  |j                  t        j                  g dd	             |j                  sJ t        |t        d      d      }t        |t        d      dd      }t	        j
                  ||d       t        t        j                  |            }t        |t              sJ t        |t               rJ y )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   tmassert_index_equalr   valuesassert_numpy_array_equalcodesnparrayr   
isinstance)r   cir   resultcexpecteds         r   test_constructionz2TestCategoricalIndexConstructors.test_construction   s~   d8nfuU]]
r
fb5>>!!ryy!
fb5>>!! ""<
f//z1BC
##FLL"((2V2LM>>!! "$x.ZH
f//z1BC
##LL"((#5VD	
 X'!!$
f//tE{1CD
##LL"((#5VD	
 >>!!!!
;
f//z1BC
##LL"((#5VD	
 >>!!aDL9!"%
f//z1BC
##LL"((#5VD	
 >>!!!"d<
f//tDz1BC
##LL"((#6fE	
 >>!!!"dTJ
f//tDz1BC
##LL"((#6fE	
 ~~~!"dTJ#4:t:
 	fhd; rxx|$&%(((f&67777    c                    t        t        d      t        d      d      }t        t        j                  |      d      }t        j                  ||d       t        t        j                  |      j                         d      }t        j                  ||d       t        t        d      t        d	      d      }t        t        j                  |      d      j                  |j                        }t        j                  ||d       t        t        d
            }t        g d|d      }t        ||d      }t        j                  ||d       y )Nr   r#   Fr   r&   r    Tr   cab   )r   r   r"   )r   r   r   r,   r-   r'   r(   tolistreorder_categoriesr   range)r   r/   r0   idxr2   s        r   test_construction_with_dtypez=TestCategoricalIndexConstructors.test_construction_with_dtype^   s    d8neeTrxx|:6
fb5rxx|**,J?
fb5 d8neeTrxx|:6II"--X
fb5 E!Ho#I#tL!##tD
fhd;r4   c                 z    t        g ddg      }t        |j                  j                               }|ddgk(  sJ y )NTFr   )r   sortedr   r8   )r   catr   s      r   ,test_construction_empty_with_bool_categorieszMTestCategoricalIndexConstructors.test_construction_empty_with_bool_categoriest   s;    rtUm<CNN1134
eT]***r4   c                    dj                         dj                         d}}}t        ||      }t        ||      }t        |||      }t        j                  ||d       t        ||      }t        j                  ||d       d}t        j                  t        |      5  t        |||	       d d d        t        j                  t        |      5  t        |||
       d d d        y # 1 sw Y   <xY w# 1 sw Y   y xY w)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   
ValueError)r   r   catsr   r!   r0   r2   r   s           r   (test_construction_with_categorical_dtypezITestCategoricalIndexConstructors.test_construction_with_categorical_dtypez   s     (oo/$Gd D'B!$e4#DT7K
fhd; t5)
fhd; P]]:S1Td%@ 2 ]]:S1T7%@ 21 21 21s   %C/C;/C8;DN)__name__
__module____qualname__r   r3   r<   r@   rE    r4   r   r   r      s    EG8R<,+Ar4   r   )numpyr,   r   pandasr   r   r   r   pandas._testing_testingr'   r   rI   r4   r   <module>rN      s(       AA AAr4   