ó
šßÈ[c           @` sÚ   d  Z  d d l m Z m Z m Z m Z d d l 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
 e f d „  ƒ  YZ d d d e d „ Z d „  Z d e f d „  ƒ  YZ d S(   uT   
Helper functions for table development, mostly creating useful
tables for testing.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t   cycleNi   (   t   Tablet   Columni   (   t   zipt   range(   t   ParentDtypeInfot   TimingTablesc           B` s   e  Z d  Z d e d „ Z RS(   u{   
    Object which contains two tables and various other attributes that
    are useful for timing and other API tests.
    iè  c         C` s  | |  _  t d |  j  ƒ |  _ t j j d ƒ t j | ƒ |  j d <t j j | ƒ |  j d <t j j | ƒ d k |  j d <t j j | d f ƒ |  j d <t j j t j t	 t
 j ƒ ƒ | ƒ |  j d	 <i d
 d 6t d 6t j d d ƒ d 6d d	 6|  _ t j j d d | ƒ |  _ t j |  j d d k ƒ d |  _ |  j j d	 ƒ |  _ t d |  j  ƒ |  _ t j d | d ƒ |  j d <t j j ƒ  |  j d <|  j j d ƒ t d |  j  ƒ |  _ t j j | ƒ |  j d <t j j | d f ƒ |  j d <|  j d d k |  _ d  S(   Nt   maskedi90  u   iu   ag      à?u   bi
   u   cu   dg333333ó?i   u   Zi    id   gÍÌÌÌÌÌì?i   u   fu   gu   hg333333ã?(   R   R   t   tablet   npt   randomt   seedt   aranget   choicet   arrayt   listt   stringt   ascii_letterst   Truet   repeatt	   extra_rowt   randintt   extra_columnt   wheret   row_indicest   group_byt   table_groupedt   other_tablet   sortt   other_table_2t	   bool_mask(   t   selft   sizeR   (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyt   __init__   s(    	.1#(   t   __name__t
   __module__t   __doc__t   FalseR%   (    (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyR
      s   i   u   ifSc         C` sN  | d k r t | ƒ } n  | d k r6 t d ƒ ‚ n  g  } g  t | ƒ D] } t t d ƒ | ƒ ^ qI } t j g  t j	 D] } | ^ q{ ƒ } x@t
 t | ƒ t | ƒ ƒ D]#\ }	 }
 |
 d k rê t j d |  d d t j ƒ|	 } nÒ |
 d k rt j |  d t j ƒ|	 } n§ |
 d k rKt j |  ƒ |	 t | ƒ } | | } nq |
 d	 k r°t j |  ƒ |	 t | ƒ } | | } g  t
 | | ƒ D] \ } } i | | 6^ qŽ} n t d
 ƒ ‚ | j t | ƒ ƒ q¬ Wt | d | d | ƒ} | rJxV t | j j ƒ  ƒ D]< \ } } t j t j |  ƒ | d d t ƒ} | | _ qWn  | S(   u<  
    Return a simple table for testing.

    Example
    --------
    ::

      >>> from astropy.table.table_helpers import simple_table
      >>> print(simple_table(3, 6, masked=True, kinds='ifOS'))
       a   b     c      d   e   f
      --- --- -------- --- --- ---
       -- 1.0 {'c': 2}  --   5 5.0
        2 2.0       --   e   6  --
        3  -- {'e': 4}   f  -- 7.0

    Parameters
    ----------
    size : int
        Number of table rows
    cols : int, optional
        Number of table columns. Defaults to number of kinds.
    kinds : str
        String consisting of the column dtype.kinds.  This string
        will be cycled through to generate the column dtype.
        The allowed values are 'i', 'f', 'S', 'O'.

    Returns
    -------
    out : `Table`
        New table with appropriate characteristics
    i   u   Max 26 columns in SimpleTableu   au   ii   t   dtypeu   fu   Su   Ou   Unknown data kindt   namesR   i   N(   t   Nonet   lent
   ValueErrorR   t   chrt   ordR   R   R   R   R   R   R   t   int64t   float64t   appendR   R   t	   enumeratet   columnst   valuest   boolt   mask(   R$   t   colst   kindsR   R5   t   iiR+   t   ct   letterst   jjt   kindt   datat   indicest   valst   valt   indexR   t   colR8   (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyt   simple_table;   s6     /%(&
2"&c          C` s€   d d l  m }  d d l m } d d l } | j ƒ  * | j d ƒ | |  d ƒ d t ƒ} Wd QX| j ƒ  } | j	 ƒ  } | S(	   ul   
    Return a masked table from the io.votable test set that has a wide variety
    of stressing types.
    i   (   t   get_pkg_data_filename(   t   parsei    Nu   ignoreu'   ../io/votable/tests/data/regression.xmlt   pedantic(
   t
   utils.dataRG   t   io.votable.tableRH   t   warningst   catch_warningst   simplefilterR)   t   get_first_tablet   to_table(   RG   RH   RL   t   votablet   first_tableR   (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyt   complex_table|   s    t   ArrayWrapperc           B` sb   e  Z d  Z e ƒ  Z d „  Z d „  Z d „  Z d „  Z e	 d „  ƒ Z
 e	 d „  ƒ Z d „  Z RS(   uC   
    Minimal mixin using a simple wrapper around a numpy array
    c         C` s=   t  j | ƒ |  _ d t | d d ƒ k r9 | j |  _ n  d  S(   Nu   infou   __dict__(    (   R   R   R@   t   getattrt   info(   R#   R@   (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyR%   •   s    c         C` s`   t  | t t j f ƒ r( |  j | } n4 |  j |  j | ƒ } d |  j k r\ |  j | _ n  | S(   Nu   info(   t
   isinstancet   intR   t   integerR@   t	   __class__t   __dict__RV   (   R#   t   itemt   out(    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyt   __getitem__š   s    c         C` s   | |  j  | <d  S(   N(   R@   (   R#   R\   t   value(    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyt   __setitem__£   s    c         C` s   t  |  j ƒ S(   N(   R-   R@   (   R#   (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyt   __len__¦   s    c         C` s
   |  j  j S(   N(   R@   R*   (   R#   (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyR*   ©   s    c         C` s
   |  j  j S(   N(   R@   t   shape(   R#   (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyRb   ­   s    c         C` s"   d j  |  j j |  j j |  j ƒ S(   Nu   <{0} name='{1}' data={2}>(   t   formatRZ   R&   RV   t   nameR@   (   R#   (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyt   __repr__±   s    (   R&   R'   R(   R	   RV   R%   R^   R`   Ra   t   propertyR*   Rb   Re   (    (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyRT      s   						(   R(   t
   __future__R    R   R   R   t	   itertoolsR   R   t   numpyR   R   R   R   t   extern.six.movesR   R   t   utils.data_infoR	   t   objectR
   R,   R)   RF   RS   RT   (    (    (    s:   lib/python2.7/site-packages/astropy/table/table_helpers.pyt   <module>   s   "'A	