ó
šxŠ\c           @   s£   d  d l  Z d  d l Z d  d l Z d  d l m Z m Z d  d l m	 Z	 m
 Z
 d e
 e	 f d „  ƒ  YZ e j d „  ƒ Z d „  Z d „  Z d	 „  Z d
 „  Z d S(   iÿÿÿÿN(   t   BlockManagert   SingleBlockManager(   t   Blockt   NonConsolidatableMixInt   CustomBlockc           B   s&   e  Z e j Z d  „  Z d d „ Z RS(   c         C   s,   t  j g  |  j D] } d j | ƒ ^ q ƒ S(   Ns   Val: {}(   t   npt   arrayt   valuest   format(   t   selft   i(    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyt   formatting_values   s    c         C   sP   t  j g  | D] } | j ^ q ƒ } |  j | d | pL t d t | ƒ d ƒ ƒS(   st   
        Always concatenate disregarding self.ndim as the values are
        always 1D in this custom Block
        t	   placementi    i   (   R   t   concatenateR   t   make_block_same_classt   slicet   len(   R	   t	   to_concatR   t   blkR   (    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyt   concat_same_type   s    %N(   t   __name__t
   __module__R   t   ndarrayt   _holderR   t   NoneR   (    (    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyR      s   		c          C   sœ   t  j i d d d g d 6ƒ }  |  j j } t j d d d ƒ} t | d t d d ƒ ƒ} | | f } t | t  j	 d d g ƒ |  j
 g ƒ } t  j | ƒ S(	   Ni   i   i   t   at   dtypet   int64R   t   b(   t   pdt	   DataFramet   _datat   blocksR   t   arangeR   R   R    t   Indext   index(   t   df1R    R   t   custom_blockt   block_manager(    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyt   df   s    'c          C   sÐ   t  j d d d ƒ}  t |  d t d d ƒ ƒ} t j t | t j d ƒ ƒ ƒ } t | ƒ d k si t	 ‚ t |  d t d d ƒ ƒ} t
 | g d g t d ƒ g ƒ } t j | ƒ } t | ƒ d	 k sÌ t	 ‚ d  S(
   Ni   R   R   R   i    s0   0    Val: 0
1    Val: 1
2    Val: 2
dtype: int64i   t   cols'         col
0  Val: 0
1  Val: 1
2  Val: 2(   R   R!   R   R   R   t   SeriesR   t
   RangeIndext   reprt   AssertionErrorR    t   rangeR   (   R   t   blockt   st   blk_mgrR'   (    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyt   test_custom_repr(   s    !!c          C   s‰   t  j d d d ƒ}  t |  d t d d ƒ ƒ} t j | t j d ƒ d t ƒ} t j | | g ƒ } t	 | j
 j d t ƒ s… t ‚ d  S(   Ni   R   R   R   i    t   fastpath(   R   R!   R   R   R   R)   R*   t   Truet   concatt
   isinstanceR   R    R,   (   R   R.   R/   t   res(    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyt   test_concat_series8   s
    !c         C   s8   t  j |  |  g ƒ } t | j j d t ƒ s4 t ‚ d  S(   Ni   (   R   R4   R5   R   R    R   R,   (   R'   R6   (    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyt   test_concat_dataframeB   s    c         C   s]   t  j i d d d g d 6ƒ } t  j |  | g d d ƒ} t | j j d t ƒ sY t ‚ d  S(   Ngš™™™™™¹?gš™™™™™É?g333333Ó?t   ct   axisi   (   R   R   R4   R5   R   R    R   R,   (   R'   t   df2R6   (    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyt   test_concat_axis1H   s    (   t   numpyR   t   pytestt   pandasR   t   pandas.core.internalsR    R   t   pandas.core.internals.blocksR   R   R   t   fixtureR'   R1   R7   R8   R<   (    (    (    sI   lib/python2.7/site-packages/pandas/tests/extension/test_external_block.pyt   <module>   s   		
	