ó
šxŠ\c           @   s6  d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 d d l
 m Z d „  Z e j d „  ƒ Z e j d „  ƒ Z e j d	 „  ƒ Z e j d
 „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ  d e j! f d „  ƒ  YZ" d e j# f d „  ƒ  YZ$ d e j% f d „  ƒ  YZ& d  e j' f d! „  ƒ  YZ( d" e j) f d# „  ƒ  YZ* d$ e j+ f d% „  ƒ  YZ, d& e j- f d' „  ƒ  YZ. d S((   sj  
This file contains a minimal set of tests for compliance with the extension
array interface test suite, and should contain no other tests.
The test suite for the full functionality of the array is located in
`pandas/tests/arrays/`.

The tests in this file are inherited from the BaseExtensionTests, and only
minimal tweaks should be applied to get the tests passing (by overwriting a
parent method).

Additional tests should either be added to one of the BaseExtensionTests
classes (if they are relevant for the extension interface for all dtypes), or
be added to the array-specific tests in `pandas/tests/arrays/`.

iÿÿÿÿN(   t   Categorical(   t   CategoricalDtype(   t   basec          C   sJ   xC t  rE t j j t t j ƒ d d ƒ}  |  d |  d k r Pq q W|  S(   Nt   sizeid   i    i   (   t   Truet   npt   randomt   choicet   listt   stringt   ascii_letters(   t   values(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt	   make_data   s
    	!c           C   s   t  ƒ  S(   N(   R   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   dtype&   s    c           C   s   t  t ƒ  ƒ S(   s‰   Length-100 array for this type.

    * data[0] and data[1] should both be non missing
    * data[0] and data[1] should not gbe equal
    (   R    R   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   data+   s    c           C   s   t  t j d g ƒ S(   s   Length 2 array with [NA, Valid]t   A(   R    R   t   nan(    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   data_missing5   s    c           C   s(   t  d d d g d d d d g d t ƒS(   NR   t   Bt   Ct
   categoriest   ordered(   R    R   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   data_for_sorting;   s    !c           C   s%   t  d d  d g d d d g d t ƒS(   NR   R   R   R   (   R    t   NoneR   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   data_missing_for_sortingA   s    c           C   s   t  j S(   N(   R   R   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   na_valueG   s    c        	   C   s"   t  d d d  d  d d d d g ƒ S(   Nt   at   bt   c(   R    R   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   data_for_groupingL   s    t	   TestDtypec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR   Q   s   t   TestInterfacec           B   s&   e  Z e j j d  d ƒ d „  ƒ Z RS(   t   reasons   Memory usage doesn't matchc         C   s   t  t |  ƒ j | ƒ d  S(   N(   t   superR!   t   test_memory_usage(   t   selfR   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR$   V   s    (   R   R    t   pytestt   markt   skipR$   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR!   U   s   t   TestConstructorsc           B   s   e  Z RS(    (   R   R    (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR)   \   s   t   TestReshapingc           B   s   e  Z RS(    (   R   R    (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR*   `   s   t   TestGetitemc           B   sï   e  Z e j j d  d ƒ Z e j j d  d ƒ d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e j j d  d	 ƒ d
 „  ƒ Z e d „  ƒ Z e j j d  d ƒ d „  ƒ Z e j j d  d ƒ d „  ƒ Z RS(   R"   s	   GH-20664.s   Backwards compatibilityc         C   s   t  t |  ƒ j | ƒ d  S(   N(   R#   R+   t   test_getitem_scalar(   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR,   g   s    c         C   s    t  t |  ƒ j | | | ƒ d  S(   N(   R#   R+   t	   test_take(   R%   R   R   t   na_cmp(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR-   n   s    c         C   s   t  ƒ  j | ƒ d  S(   N(   R#   t   test_take_negative(   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR/   s   s    c         C   s   t  ƒ  j | | ƒ d  S(   N(   R#   t&   test_take_pandas_style_negative_raises(   R%   R   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR0   w   s    c         C   s   t  ƒ  j | ƒ d  S(   N(   R#   t   test_take_non_na_fill_value(   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR1   {   s    c         C   s   t  ƒ  j | | ƒ S(   N(   R#   t   test_take_out_of_bounds_raises(   R%   R   t
   allow_fill(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR2      s    s    GH-20747. Unobserved categories.c         C   s   t  ƒ  j | ƒ d  S(   N(   R#   t   test_take_series(   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR4   ƒ   s    c         C   s   t  ƒ  j | ƒ d  S(   N(   R#   t   test_reindex_non_na_fill_value(   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR5   ‡   s    s   Categorical.take buggyc         C   s   t  ƒ  j | | | ƒ d  S(   N(   R#   t   test_take_empty(   R%   R   R   R.   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR6   ‹   s    s*   test not written correctly for categoricalc         C   s   t  ƒ  j | | ƒ d  S(   N(   R#   t   test_reindex(   R%   R   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR7      s    (   R   R    R&   R'   R(   t	   skip_takeR,   R-   R/   R0   R1   R2   R4   R5   R6   R7   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR+   d   s   t   TestSetitemc           B   s   e  Z RS(    (   R   R    (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR9   ”   s   t   TestMissingc           B   sD   e  Z e j j d  d ƒ d „  ƒ Z e j j d  d ƒ d „  ƒ Z RS(   R"   s   Not implementedc         C   s   t  ƒ  j | ƒ d  S(   N(   R#   t   test_fillna_limit_pad(   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR;   š   s    c         C   s   t  ƒ  j | ƒ d  S(   N(   R#   t   test_fillna_limit_backfill(   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR<   ž   s    (   R   R    R&   R'   R(   R;   R<   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR:   ˜   s   t
   TestReducec           B   s   e  Z RS(    (   R   R    (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR=   £   s   t   TestMethodsc           B   sV   e  Z e j j d  d ƒ d „  ƒ Z d „  Z e j j d  d ƒ d „  ƒ Z d „  Z RS(   R"   s   Unobserved categories includedc         C   s   t  ƒ  j | | ƒ S(   N(   R#   t   test_value_counts(   R%   t   all_datat   dropna(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR?   ¨   s    c         C   sø   | d ƒ \ } } t  j | ƒ } t  j | ƒ } | j | d „  ƒ } t  j g  t t | ƒ t | ƒ ƒ D] \ } } | | ^ qg ƒ }	 |  j | |	 ƒ | j d }
 | j |
 d „  ƒ } t  j g  t | ƒ D] } | |
 ^ qË ƒ }	 |  j | |	 ƒ d  S(   Ni   c         S   s   |  | S(   N(    (   t   x1t   x2(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   <lambda>²   s    i    c         S   s   |  | S(   N(    (   RB   RC   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRD   ¸   s    (   t   pdt   Seriest   combinet   zipR   t   assert_series_equalt   iloc(   R%   t   data_repeatedt
   orig_data1t
   orig_data2t   s1t   s2t   resultR   R   t   expectedt   val(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   test_combine_add¬   s    	8,s   Not Applicablec         C   s   t  ƒ  j | ƒ d  S(   N(   R#   t   test_fillna_length_mismatch(   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRT   ¼   s    c         C   s"   | j  s t j d d ƒ ‚ n  d  S(   NR"   s#   searchsorted requires ordered data.(   R   R&   R(   (   R%   R   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   test_searchsortedÀ   s    	(	   R   R    R&   R'   R(   R?   RS   RT   RU   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyR>   §   s   	t   TestCastingc           B   s   e  Z RS(    (   R   R    (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRV   Å   s   t   TestArithmeticOpsc           B   s&   e  Z d  „  Z d „  Z e d „ Z RS(   c         C   s?   | } | d k r. t  t |  ƒ j | | ƒ n t j d ƒ d  S(   Nt   __rmod__s/   rmod never called when string is first argument(   R#   RW   t   test_arith_series_with_scalarR&   R(   (   R%   R   t   all_arithmetic_operatorst   op_name(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRY   Ë   s
    c         C   s7   t  j | ƒ } t j t d d ƒ | | Wd  QXd  S(   Nt   matchs   cannot perform(   RE   RF   R&   t   raisest	   TypeError(   R%   R   t   ser(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt$   test_add_series_with_extension_arrayÔ   s    c         C   s"   t  t |  ƒ j | | | d t ƒS(   Nt   exc(   R#   RW   t   _check_divmod_opR^   (   R%   t   st   opt   otherRa   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRb   Ù   s    (   R   R    RY   R`   t   NotImplementedErrorRb   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRW   É   s   			t   TestComparisonOpsc           B   s   e  Z d  „  Z RS(   c         C   sÌ   |  j  | ƒ } | d k rZ | | | ƒ } | j | d „  ƒ } | | k j ƒ  sÈ t ‚ nn | d k r¥ | | | ƒ } | j | d „  ƒ } | | k j ƒ  sÈ t ‚ n# t j t ƒ  | | | ƒ Wd  QXd  S(   Nt   __eq__c         S   s
   |  | k S(   N(    (   t   xt   y(    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRD   å   s    t   __ne__c         S   s
   |  | k S(   N(    (   Ri   Rj   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRD   ê   s    (   t   get_op_from_nameRG   t   allt   AssertionErrorR&   R]   R^   (   R%   Rc   R   R[   Re   Rd   RP   RQ   (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   _compare_otherá   s    (   R   R    Ro   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRg   ß   s   t   TestParsingc           B   s   e  Z RS(    (   R   R    (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyRp   ò   s   (/   t   __doc__R	   t   numpyR   R&   t   pandasRE   R    t   pandas.api.typesR   t   pandas.tests.extensionR   R   t   fixtureR   R   R   R   R   R   R   t   BaseDtypeTestsR   t   BaseInterfaceTestsR!   t   BaseConstructorsTestsR)   t   BaseReshapingTestsR*   t   BaseGetitemTestsR+   t   BaseSetitemTestsR9   t   BaseMissingTestsR:   t   BaseNoReduceTestsR=   t   BaseMethodsTestsR>   t   BaseCastingTestsRV   t   BaseArithmeticOpsTestsRW   t   BaseComparisonOpsTestsRg   t   BaseParsingTestsRp   (    (    (    sF   lib/python2.7/site-packages/pandas/tests/extension/test_categorical.pyt   <module>   s8   	
0