ó
šßÈ[c           @   sŸ   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 d l	 m
 Z
 d „  Z e j j d	 ƒ d
 d d „  ƒ  Yƒ Z d „  Z d S(   iÿÿÿÿNi   (   t   table(   t   Row(   t   zipi   (   t   MaskedTablec          C   s|   t  j d g g d d g d t ƒ}  t |  d _ |  d d d k sK t ‚ t |  d _ |  d d t j j k sx t ‚ d S(   su   
    Numpy < 1.8 has a bug in masked array that prevents access a row if there is
    a column with object type.
    i   t   dtypet   Ot   maskedt   col0i    N(	   R    t   Tablet   Truet   Falset   maskt   AssertionErrort   npt   maR   (   t   t(    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_masked_row_with_object_col   s
    $t   table_typest   TestRowc           B   sƒ   e  Z d  „  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z RS(   c         C   s   | j  |  _ | j |  _ d  S(   N(   R   t   _table_typet   Columnt   _column_type(   t   selfR   (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   _setup   s    c         C   s’   |  j  d  k r d  St |  d ƒ s‹ |  j  d d d d d d g d d	 ƒ } |  j  d d
 d d d d g d d	 ƒ } |  j | | g ƒ |  _ n  |  j S(   Nt   _tt   namet   at   datai   i   i   R   t   i8t   bi   i   i   (   R   t   Nonet   hasattrR   R   (   R   R   R   (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyR   "   s    ''c         C   s8   |  j  | ƒ t |  j d ƒ } t | t ƒ s4 t ‚ d S(   s"   Row is subclass of ndarray and Rowi   N(   R   R   R   t
   isinstanceR   (   R   R   t   c(    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_subclass/   s    c         C   s*  |  j  | ƒ |  j } | d } | d d k s6 t ‚ | d d k sL t ‚ | d d k sb t ‚ | d d k sx t ‚ | j | j k s t ‚ | j | j k s¨ t ‚ | j | j k sÀ t ‚ t j t ƒ  | d Wd QXt	 j
 d k rt | j ƒ d	 k s&t ‚ n t | j ƒ d
 k s&t ‚ d S(   s3   Row accurately reflects table values and attributesi   R   i   R   i   i    Nt   littles   [('a', '<i8'), ('b', '<i8')]s   [('a', '>i8'), ('b', '>i8')](   R   R   R   t   metat   colnamest   columnst   pytestt   raisest
   IndexErrort   syst	   byteordert   strR   (   R   R   R    t   row(    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_values5   s    	
c         C   sZ   |  j  | ƒ |  j } | d } d | d <| j t k	 rV | d d d k sV t ‚ n  d S(   s+   Row is a reference into original table datai   i
   R   N(   R   R   R   R   R   (   R   R   R    R-   (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_refH   s    	

c         C   s›   |  j  | ƒ |  j j ƒ  } | j t k rY t j t ƒ  |  j d | d k Wd QXn> x; t |  j | ƒ D]' \ } } t	 j
 | | k ƒ sl t ‚ ql Wd S(   s=   Compare a table row to the corresponding structured array rowi    N(   R   R   t   as_arrayR   R   R'   R(   t
   ValueErrorR   R   t   allR   (   R   R   t   np_tR-   t   np_row(    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_left_equalQ   s    c         C   s®   |  j  | ƒ |  j j ƒ  } d d d g | d <| j t k rl t j t ƒ  |  j d | d k Wd QXn> x; t |  j | ƒ D]' \ } } t	 j
 | | k ƒ s t ‚ q Wd S(   s=   Compare a table row to the corresponding structured array rowi    R   N(   R   R   R0   R   R   R'   R(   R1   R   R   R2   R   (   R   R   R3   R-   R4   (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_left_not_equal\   s    c         C   s›   |  j  | ƒ |  j j ƒ  } | j t k rY t j t ƒ  |  j d | d k Wd QXn> x; t |  j | ƒ D]' \ } } t	 j
 | | k ƒ sl t ‚ ql Wd S(   s   Test right equali    N(   R   R   R0   R   R   R'   R(   R1   R   R   R2   R   (   R   R   R3   R-   R4   (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_right_equalh   s    c      
   C   sc  |  j  | ƒ |  j d } t j | ƒ } | j t k	 r\ t j | | j ƒ  k ƒ s\ t ‚ n  | | j ƒ  k	 st t ‚ | j	 t
 | j j ƒ k s• t ‚ t j | d t ƒ} | j t k	 rÝ t j | | j ƒ  k ƒ sÝ t ‚ n  | | j ƒ  k	 sõ t ‚ | j	 t
 | j j ƒ k st ‚ t j t ƒ 8 t j | d t d ƒ d f t d ƒ d f g ƒ} Wd  QXd  S(   Ni   t   copyR   R!   R   t   d(   R   R   R   t   arrayR   R   R2   t   as_voidR   R%   t   listR   t   namesR
   R'   R(   R1   R,   (   R   R   R9   t   np_data(    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_convert_numpy_arrays   s    $!$!c         C   sÿ   |  j  | ƒ |  j } | d } t | ƒ j ƒ  d j | j j d | j rP d n d ƒ d d d d	 g k sq t ‚ t	 | ƒ j ƒ  d
 d d g k s˜ t ‚ | j
 ƒ  j ƒ  d j | j j d | j rÈ d n d ƒ d j t | ƒ ƒ d d d d g k sû t ‚ d S(   s   Test formatting rowi    s   <{0} {1}{2}>s   index=0s    masked=Truet    s     a     b  s   int64 int64s   ----- -----s       1     4s    a   b s   --- ---s     1   4s   &lt;{0} {1}{2}&gt;s   <table id="table{0}">s,   <thead><tr><th>a</th><th>b</th></tr></thead>s4   <thead><tr><th>int64</th><th>int64</th></tr></thead>s   <tr><td>1</td><td>4</td></tr>s   </table>N(   R   R   t   reprt
   splitlinest   formatt	   __class__t   __name__R   R   R,   t   _repr_html_t   id(   R   R   R    R-   (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_format_row†   s.    	
		c         C   s,  |  j  | ƒ |  j } | d } | j ƒ  } | j rS t | t j j ƒ sk t ‚ n t | t j	 ƒ sk t ‚ | d d k s t ‚ | d d k s— t ‚ d | d d <| d d k s» t ‚ | d d k sÑ t ‚ | j r(t
 | d _ | d d k sý t ‚ | j ƒ  } | d t j j k s(t ‚ n  d S(   s   Test the as_void() methodi    R   i   R   i   iœÿÿÿN(   R   R   R;   R   R    R   R   t   mvoidR   t   voidR	   R   (   R   R   R    R-   t   row_void(    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_as_void¡   s"    	
		c         C   sÀ   | j  i d d 6i d d 6g g d d ƒ} | d d i d d 6k sM t ‚ | d d i d d 6k sn t ‚ | d j ƒ  d i d d 6k s• t ‚ | d j ƒ  d i d d 6k s¼ t ‚ d S(	   s6   Test the deprecated data property and as_void() methodi   R   i   R   R=   i    N(   R   (   R   R   R;   (   R   R   R   (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt!   test_row_and_as_void_with_objects¿   s
    ,!!'c         C   sC   |  j  | ƒ x/ d D]' } t j t ƒ  |  j | Wd QXq Wd S(   s;   Row gives index error upon creation for out-of-bounds indexiûÿÿÿiüÿÿÿi   i   N(   iûÿÿÿiüÿÿÿi   i   (   R   R'   R(   R)   R   (   R   R   t   ibad(    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_bounds_checkingÇ   s    (   RE   t
   __module__R   t   propertyR   R"   R.   R/   R5   R6   R7   R?   RH   RL   RM   RO   (    (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyR      s   												c          C   s5  t  j d d d g g d d ƒ}  |  d d d k s; t ‚ |  d t j d ƒ d k s^ t ‚ |  d t j d ƒ d k s t ‚ |  t j d ƒ d d k s¤ t ‚ d d d	 d
 d g } t |  d ƒ j ƒ  | k sÛ t ‚ t |  t j d ƒ ƒ j ƒ  | k st ‚ t |  t j d ƒ ƒ j ƒ  | k s1t ‚ d S(   s<  
    Test that accessing a row with an unsigned integer
    works as with a signed integer.  Similarly tests
    that printing such a row works.

    This is non-trivial: adding a signed and unsigned
    integer in numpy results in a float, which is an
    invalid slice index.

    Regression test for gh-7464.
    g      ð?g       @g      @R=   R   i   s   <Row index=1>s      a   t   float64s   -------s       2.0N(   R    R   R   R   t   intt   uintRA   RB   (   R   t   trepr(    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   test_uint_indexingÏ   s    !###	"+(    (   R*   R'   t   numpyR   R@   R    R   t   extern.six.movesR   t   conftestR   R   t   markt   usefixturesR   RV   (    (    (    s;   lib/python2.7/site-packages/astropy/table/tests/test_row.pyt   <module>   s   	%³