
[c           @` s  d  d l  m Z m Z m Z m Z d d l m Z d d l m Z m	 Z	 d d l
 m Z m Z m Z d  d l Z d  d l Z d  d l m Z m Z d  d l Z d  d	 l m 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 m  Z  d d l! m" Z" m# Z# d d l$ m% Z& d d l' m( Z( d d l) m* Z* d d l+ m, Z, m- Z- m. Z. m/ Z/ d d l m0 Z0 d d l1 m2 Z2 d d l3 m4 Z4 m5 Z5 m6 Z6 m7 Z7 m8 Z8 m9 Z9 d d l: m; Z; d d l< m= Z= m> Z> d d l? m@ Z@ d d l
 mA ZA mB ZB mC ZC d d l mD ZD d d d d g ZE d eF f d      YZG d!   ZH d"   ZI d# e f d$     YZJ d% eK f d&     YZL d' eL f d(     YZM d) e jN f d*     YZO d S(+   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsi   (   t   six(   t   zipt   rangei   (   t   TableIndicest   TableLoct	   TableILocN(   t   OrderedDictt   Mapping(   t   deepcopy(   t   ma(   t   log(   t   registry(   t   Quantityt   QuantityInfo(   t
   isiterablet   ShapedLikeNDArray(   t   broadcast_to(   t   color_print(   t   MetaData(   t   BaseColumnInfot	   MixinInfot   ParentDtypeInfot   DataInfo(   t   groups(   t   TableFormatter(   t
   BaseColumnt   Columnt   MaskedColumnt   _auto_namest
   FalseArrayt   col_copy(   t   Row(   t   fix_column_namet   recarray_fromrecords(   t	   TableInfo(   t   Indext   _IndexModeContextt	   get_index(   t   confu
   Table.readu   Table.writeu#   Table.convert_bytestring_to_unicodeu#   Table.convert_unicode_to_bytestringt   TableReplaceWarningc           B` s   e  Z d  Z RS(   u	  
    Warning class for cases when a table column is replaced via the
    Table.__setitem__ syntax e.g. t['a'] = val.

    This does not inherit from AstropyWarning because we want to use
    stacklevel=3 to show the user where the issue occurred in their code.
    (   t   __name__t
   __module__t   __doc__(    (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR+   *   s   c         C` sY   |  j  j d k r d n	 |  j  j } t |  d  r@ |  j d n d } |  j  j | | f S(   u   Array-interface compliant full description of a column.

    This returns a 3-tuple (name, type, shape) that can always be
    used in a structured array dtype definition.
    u   Ou   shapei   N(    (   t   infot   dtypet   Nonet   hasattrt   shapet   name(   t   colt	   col_dtypet	   col_shape(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   descr5   s    $"c         C` s   t  |  d  o t |  j |  S(   Nu   info(   R2   t
   isinstanceR/   (   t   objt   cls(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   has_info_class@   s    t   TableColumnsc           B` sb   e  Z d  Z i  d  Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   uB  OrderedDict subclass for a set of columns.

    This class enhances item access to provide convenient access to columns
    by name or index, including slice access.  It also handles renaming
    of columns.

    The initialization argument ``cols`` can be a list of ``Column`` objects
    or any structure that is valid for initializing a Python dict.  This
    includes a dict, list of (key, val) tuples or [key, val] lists, etc.

    Parameters
    ----------
    cols : dict, list, tuple; optional
        Column objects as data structure that can init dict (see above)
    c         C` s   t  | t t f  rm g  } xF | D]> } t | t  rS | j | j j | f  q" | j |  q" W| } n  t t	 |   j
 |  d  S(   N(   R9   t   listt   tupleR<   R   t   appendR/   R4   t   superR=   t   __init__(   t   selft   colst   newcolsR5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRB   U   s    	c         C` s  t  | t j  r" t j |  |  St  | t t j f  rH |  j   | St  | t j	  r | j
 d k r | j j d k r |  j   | j   St  | t  r |  j g  | D] } |  | ^ q  St  | t  r |  j g  t |   | D] } |  | ^ q  St d j |  j j    d S(   u?  Get items from a TableColumns object.
        ::

          tc = TableColumns(cols=[Column(name='a'), Column(name='b'), Column(name='c')])
          tc['a']  # Column('a')
          tc[1] # Column('b')
          tc['a', 'b'] # <TableColumns names=('a', 'b')>
          tc[1:3] # <TableColumns names=('b', 'c')>
        u   iu(   Illegal key or index value for {} objectN(    (   R9   R   t   string_typesR
   t   __getitem__t   intt   npt   integert   valuest   ndarrayR3   R0   t   kindt   itemR?   t	   __class__t   sliceR>   t
   IndexErrort   formatR,   (   RC   RN   t   x(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRG   b   s    
3$.	c         C` sA   | |  k r$ t  d j |    n  t t |   j | |  d  S(   NuA   Cannot replace column '{0}'.  Use Table.replace_column() instead.(   t
   ValueErrorRR   RA   R=   t   __setitem__(   RC   RN   t   value(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRU   z   s    	c         C` s8   d   t  j |   D } d j d j |  |  j j  S(   Nc         s` s   |  ] } d  j  |  Vq d S(   u   '{0}'N(   RR   (   t   .0RS   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>   s    u   <{1} names=({0})>u   ,(   R   t   iterkeysRR   t   joinRO   R,   (   RC   t   names(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __repr__   s    c         C` s   | | k r d  S| |  k r4 t  d j |    n  i | | 6} g  |  D] } | j | |  ^ qH } t t j |    } |  j   |  j t t | |    d  S(   Nu   Column {0} already exists(	   t   KeyErrorRR   t   getR>   R   t
   itervaluest   cleart   updateR   (   RC   R4   t   new_namet   mappert	   new_namesRD   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _rename_column   s    %
c         C` s   t  t j |    S(   N(   R>   R
   t   keys(   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRe      s    c         C` s   t  t j |    S(   N(   R>   R
   RK   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRK      s    c         C` s2   g  |  j    D] } t | |  r | ^ q } | S(   u{  
        Return a list of columns which are instances of the specified classes.

        Parameters
        ----------
        cls : class or tuple of classes
            Column class (including mixin) or tuple of Column classes.

        Returns
        -------
        col_list : list of Columns
            List of Column objects which are instances of given classes.
        (   RK   R9   (   RC   R;   R5   RD   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR9      s    .c         C` s2   g  |  j    D] } t | |  s | ^ q } | S(   u  
        Return a list of columns which are not instances of the specified classes.

        Parameters
        ----------
        cls : class or tuple of classes
            Column class (including mixin) or tuple of Column classes.

        Returns
        -------
        col_list : list of Columns
            List of Column objects which are not instances of given classes.
        (   RK   R9   (   RC   R;   R5   RD   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   not_isinstance   s    .(   R,   R-   R.   RB   RG   RU   R[   Rd   Re   RK   R9   Rf   (    (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR=   D   s   							t   Tablec        
   B` s  e  Z d  Z e   Z e Z e Z e Z e Z e	 Z	 e
 d  Z d_ d_ d_ d_ d_ e d_ e d  Z d   Z d   Z e d    Z e j d    Z e d    Z d_ d  Z e d	    Z e d
    Z e d    Z d_ e
 d  Z d   Z d   Z d_ d  Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d   Z% d   Z& e' d    Z( d   Z) e
 d_ d_ d_ e d_ d_ d  Z* d   Z+ d   Z, d   Z- e. j/ se- Z0 n  d    Z1 e. j/ re1 Z0 n  e d!    Z2 d"   Z3 d_ d_ e d_ e
 d_ d#  Z4 d$   Z5 d_ d_ d% d& d' d(  Z6 d) e
 d* i e d+ 6d_ d, d_ d' d-  Z7 d_ d_ e d_ e
 e
 d_ d_ d_ d. 	 Z8 d_ d_ e d_ e
 d/  Z9 d0   Z: d1   Z; d2   Z< d3   Z= e d4    Z> e> j d5    Z> d6   Z? e d7    Z@ e d8    ZA e d9    ZB d:   ZC d;   ZD d<   ZE d_ d_ e
 d=  ZF d_ d_ e e
 d>  ZG d?   ZH d@   ZI dA   ZJ dB   ZK dC   ZL dD   ZM dE   ZN e
 dF  ZO e
 dG  ZP dH   ZQ dI   ZR d_ d_ dJ  ZS d_ d_ dK  ZT dL   ZU d_ d_ dM  ZV d_ dN  ZW dO   ZX eY dP    ZZ dQ   Z[ e dR  Z\ d_ dS  Z] dT   Z^ dU   Z_ dV   Z` dW   Za dX   Zb dY   Zc dZ   Zd e d[    Ze d\   Zf d]   Zg eY d^    Zh ei   Zj RS(`   u=  A class to represent tables of heterogeneous data.

    `Table` provides a class for heterogeneous tabular data, making use of a
    `numpy` structured array internally to store the data values.  A key
    enhancement provided by the `Table` class is the ability to easily modify
    the structure of the table by adding or removing columns, or adding new
    rows of data.  In addition table and column metadata are fully supported.

    `Table` differs from `~astropy.nddata.NDData` by the assumption that the
    input data consists of columns of homogeneous data, where each column
    has a unique identifier and may contain additional metadata such as the
    data unit, format, and description.

    Parameters
    ----------
    data : numpy ndarray, dict, list, Table, or table-like object, optional
        Data to initialize table.
    masked : bool, optional
        Specify whether the table is masked.
    names : list, optional
        Specify column names.
    dtype : list, optional
        Specify column data types.
    meta : dict, optional
        Metadata associated with the table.
    copy : bool, optional
        Copy the input data. If the input is a Table the ``meta`` is always
        copied regardless of the ``copy`` parameter.
        Default is True.
    rows : numpy ndarray, list of lists, optional
        Row-oriented data for table instead of ``data`` argument.
    copy_indices : bool, optional
        Copy any indices in the input data. Default is True.
    **kwargs : dict, optional
        Additional keyword args when converting table-like object.
    c         C` s'  t  |  j  d k r d	 Sd
 t j d k } d | f } g  } |  j j   } x | D]w } t |  } | j j j } | r | | k r t	 j | d  j
 d  }	 | d |	 | d f } n  | j |  qT W|  j r t j n t	 j }
 |
 t  |   d | } x | D] } | | | j j <q	W| S(   uN  
        Return a new copy of the table in the form of a structured np.ndarray or
        np.ma.MaskedArray object (as appropriate).

        Parameters
        ----------
        keep_byteorder : bool, optional
            By default the returned array has all columns in native byte
            order.  However, if this option is `True` this preserves the
            byte order of all columns (if any are non-native).

        Returns
        -------
        table_array : np.ndarray (unmasked) or np.ma.MaskedArray (masked)
            Copy of table as a numpy structured array
        i    u   >u   <u   littleu   =i   i   R0   N(   u   >u   <(   t   lent   columnsR1   t   syst	   byteorderRK   R8   R/   R0   RI   t   newbyteorderR@   t   maskedR   t   emptyR4   (   RC   t   keep_byteordert   sys_byteordert   native_orderR0   RD   R5   t	   col_descrRk   t   new_dtt
   empty_initt   data(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   as_array   s$    c	         K` s  |  j  |  |  j   |  _ | |  _ |  j   |  _ t |  _ | |  _ d  |  _
 | rq | d  k	 rq t d   n  t }
 | d  k	 r| d  k	 r t d   n  t d   | D  r t }
 | } qt | |  j  r | } qt |  } g  | j j D] } | | ^ q } n  d  } t | d  rF| j |  j | |	  } t } n. |	 rtt d j t |	 j    d    n  t | t j  r| j d k r| j j rd  } n  t | |  j  r| j | j | j d !} n  t | t t f  r<|  j  } | r-|
 st d   | D  r-t! | d  } q+t! |  } nt | t j  r| j j r|  j" } t! | j j  } | j j } q+|  j" } | j d k rt d	   n1 t! | j  d k r| t j# d  d   f } n  | j d } n?t | t$  r|  j% } t |  } t! |  } nt | t&  rg|  j' } t! | j(  } | j( } |  j o^| j |  _ n | d  k r| d  k r| d  k rd  Sy9 t j |  } | j } g  | D] } | | ^ q} Wqt) k
 rt d
   qXn  |  j  } t! |  } g  g | } n t d j t* |     | d  k rM| pGd  g | } n  | d  k rid  g | } n  g  | D] } t+ |  ^ qp} |  j, | | |  | | | | | |  t* |  j-  t. k	 rt d   n  d  S(   Nu$   Cannot specify dtype when copy=Falseu+   Cannot supply both `data` and `rows` valuesc         s` s   |  ] } t  | t  Vq d  S(   N(   R9   t   dict(   RW   t   row(    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>2  s    u   __astropy_table__u/   __init__() got unexpected keyword argument {!r}i    i   c         s` s   |  ] } t  | t  Vq d  S(   N(   R9   Rw   (   RW   Rx   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>V  s    u(   Can not initialize a Table with a scalaru<   dtype was specified but could not be parsed for column namesu'   Data type {0} not allowed to init Tableu1   masked property has not been set to True or False(   i    (    (/   t   _set_maskedR=   Ri   t   metaR   t	   formattert   Truet   _copy_indicest   _init_indicesR1   t   primary_keyRT   t   Falset   allR9   R#   R%   R0   RZ   R2   t   __astropy_table__RO   t	   TypeErrorRR   R>   Re   RI   RL   R3   t   _tablet   _indexR?   t   _init_from_listRh   t   _init_from_ndarrayt   newaxisR   t   _init_from_dictRg   t   _init_from_tablet   colnamest	   Exceptiont   typeR$   t   _check_names_dtypeRm   t   bool(   RC   Ru   Rm   RZ   R0   Rz   t   copyt   rowst   copy_indicest   kwargst   is_list_of_dictt   rec_dataR4   t   default_namest	   init_funct   n_cols(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRB     s    						&				"						!		c         C` s,   t  d   |  j j   D  } | |  j f S(   Nc         s` s<   |  ]2 \ } } | t  | t  r' | n	 t |  f Vq d  S(   N(   R9   R   R"   (   RW   t   keyR5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s   (   R
   Ri   t   itemsRz   (   RC   Ri   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __getstate__  s    	c         C` s#   | \ } } |  j  | d | d  S(   NRz   (   RB   (   RC   t   stateRi   Rz   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __setstate__  s    c         C` sY   |  j  rO t g  |  j j   D] } | j ^ q d |  j d t } t | _ n d  } | S(   NRZ   R   (
   Rm   Rg   Ri   RK   t   maskR   R   R|   t   _setitem_inplaceR1   (   RC   R5   t
   mask_table(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    	(c         C` s   | |  j  (d  S(   N(   R   (   RC   t   val(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    c         C` s   |  j    j S(   u   This is needed so that comparison of a masked Table and a
        MaskedArray works.  The requirement comes from numpy.ma.core
        so don't remove this property.(   Rv   R   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _mask  s    c         C` s\   |  j  r: g  t j |  j  D] } | j |  ^ q } n |  } |  j | d t |  j  S(   u  Return a copy of self, with masked values filled.

        If input ``fill_value`` supplied then that value is used for all
        masked entries in the table.  Otherwise the individual
        ``fill_value`` defined for each table column is used.

        Parameters
        ----------
        fill_value : str
            If supplied, this ``fill_value`` is used for all masked entries
            in the entire table.

        Returns
        -------
        filled_table : Table
            New table with masked values filled
        Rz   (   Rm   R   R^   Ri   t   filledRO   R   Rz   (   RC   t
   fill_valueR5   Ru   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    	1c         C` s|   g  } xi |  j  j   D]X } xO | j j D]A } t g  | D] } | | k ^ q9  d k r) | j |  q) q) Wq Wt |  S(   uk   
        Return the indices associated with columns of the table
        as a TableIndices object.
        i    (   Ri   RK   R/   t   indicest   sumR@   R   (   RC   t   lstt   columnt   indexRS   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    +c         C` s
   t  |   S(   u   
        Return a TableLoc object that can be used for retrieving
        rows by index in a given data range. Note that both loc
        and iloc work only with single-column indices.
        (   R   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   loc  s    c         C` s
   t  |   S(   u   
        Return a TableILoc object that can be used for retrieving
        indexed rows in the order they appear in the index.
        (   R	   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   iloc  s    c         C` s   t  | t j  r | f } n  |  j t |  j   } xJ | D]B } t | j d t  s> t	 d j
 | j j t |     q> q> Wt | d | d | } |  j s | |  _ n  x! | D] } | j j j |  q Wd S(   uR  
        Insert a new index among one or more columns.
        If there are no indices, make this index the
        primary table index.

        Parameters
        ----------
        colnames : str or list
            List of column names (or a single column name) to index
        engine : type or None
            Indexing engine class to use, from among SortedArray, BST,
            FastBST, and FastRBT. If the supplied argument is None (by
            default), use SortedArray.
        unique : bool
            Whether the values of the index must be unique. Default is False.
        u   _supports_indexingu5   Cannot create an index on column "{0}", of type "{1}"t   enginet   uniqueN(   R9   R   RF   Ri   R?   RK   t   getattrR/   R   RT   RR   R4   R   R'   R   R   R@   (   RC   R   R   R   Ri   R5   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt	   add_index  s    	"	c         C` sw   |  j  | } xc |  j D]X } y | j | j j  Wn t k
 rG q Xx$ | j  D] } | j j j |  qR Wq Wd S(   u  
        Remove all indices involving the given column.
        If the primary index is removed, the new primary
        index will be the most recently added remaining
        index.

        Parameters
        ----------
        colname : str
            Name of column
        N(   Ri   R   t   col_positionR/   R4   RT   t   remove(   RC   t   colnameR5   R   t   c(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   remove_indices  s    c         C` s   t  |  |  S(   u'  
        Return a context manager for an indexing mode.

        Parameters
        ----------
        mode : str
            Either 'freeze', 'copy_on_getitem', or 'discard_on_copy'.
            In 'discard_on_copy' mode,
            indices are not copied whenever columns or tables are copied.
            In 'freeze' mode, indices are not modified whenever columns are
            modified; at the exit of the context, indices refresh themselves
            based on column values. This mode is intended for scenarios in
            which one intends to make many additions or modifications in an
            indexed column.
            In 'copy_on_getitem' mode, indices are copied when taking column
            slices as well as table slices, so col[i0:i1] will preserve
            indices.
        (   R(   (   RC   t   mode(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt
   index_mode2  s    c         C` s;   | d k	 r t d   n  |  j r1 |  j   j S|  j   S(   u   Support converting Table to np.array via np.array(table).

        Coercion to a different dtype via np.array(table, dtype) is not
        supported and will raise a ValueError.
        u    Datatype coercion is not allowedN(   R1   RT   Rm   Rv   Ru   (   RC   R0   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt	   __array__G  s    
c         C` s   xJ | d f | d f f D]0 \ } } t  |  s t d j |    q q Wt |  | k sq t |  | k r t d j |    n  d S(   uc   Make sure that names and dtype are both iterable and have
        the same length as data.
        u   dtypeu   namesu   {0} must be a list or Noneu:   Arguments "names" and "dtype" must match number of columnsN(   R   RT   RR   Rh   (   RC   RZ   R0   R   t   inp_listt   inp_str(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   Z  s    %$c         C` s{   |  j  d  k rE t d   | D  r5 |  j t  qw |  j t  n2 |  j  sw t d   | D  rw |  j t  qw n  d  S(   Nc         s` s'   |  ] } t  | t t j f  Vq d  S(   N(   R9   R   R   t   MaskedArray(   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>i  s    c         s` s9   |  ]/ } t  | t t j f  r t j | j  Vq d  S(   N(   R9   R   R   R   RI   t   anyR   (   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>n  s    (   Rm   R1   R   Ry   R|   R   (   RC   RD   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _set_masked_from_colsg  s    	c         C` s   t    } x | D] } | j |  q Wi  } xz | D]r }	 g  | |	 <x_ t |  D]Q \ }
 } y | |	 j | |	  WqQ t k
 r t d j |
 |	    qQ XqQ Wq4 Wt d   | D  r t |  } n  |  j	 | | | | |  d  S(   Nu#   Row {0} has no value for column {1}c         s` s   |  ] } | d  k Vq d  S(   N(   R1   (   RW   R4   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>~  s    (
   t   setR`   t	   enumerateR@   R\   RT   RR   R   t   sortedR   (   RC   Ru   RZ   R0   R   R   t   names_from_dataRx   RD   R4   t   i(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _init_from_list_of_dictsq  s    	
$c         C` s  | r9 t  d   | D  r9 |  j | | | | |  d S|  j |  g  } t |  } xt | | | |  D]m\ } }	 }
 } t | t j  r t | j	  d k r |  j
 |  r | j t  } n  t | t t f  r |  j d |	 p | j j p |
 d | d | d | d |  j  } n |  j
 |  rn| rMt | d |  j } n  |	 pb| j j pb|
 | j _ n` t | t j  st |  r|  j d |	 p|
 d | d | d | d |  j  } n t d	   | j |  qn W|  j |  d S(
   u   Initialize table from a list of columns.  A column can be a
        Column object, np.ndarray, mixin, or any other iterable object.
        c         s` s   |  ] } t  | t  Vq d  S(   N(   R9   Rw   (   RW   Rx   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    Ni   R4   Ru   R0   R   R   uB   Elements in list initialization must be either Column or list-like(   R   R   R   R    R   R9   RI   RL   Rh   R0   t   _add_as_mixin_columnt   viewt   NdarrayMixinR   R   t   ColumnClassR/   R4   R~   R"   R   RT   R@   t   _init_from_cols(   RC   Ru   RZ   R0   R   R   RD   t	   def_namesR5   R4   t   def_name(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s0    ('!!!c         C` s  | j  j p t |  } | j  j d k	 } g  t |  D] \ } }	 |	 pP | | ^ q7 } | r| g  | D]? }	 | |	 ^ qf n, g  t |  D] } | d d  | f ^ q }
 |  j |
  | r |  j |
 | | | |  n g  t | |
  D]% \ }	 } |	 | j  | j	 d f ^ q } | j
 |  j   } |  j   } x> | D]6 }	 |  j d |	 d | |	  | |	 <|  | |	 j _ q=W| |  _ d S(   u1   Initialize table from an ndarray structured arrayNi   R4   Ru   (   R0   RZ   R    R1   R   R   R   R   R   R3   R   t   ravelR=   R   R/   t   parent_tableRi   (   RC   Ru   RZ   R0   R   R   t
   data_namest   structR   R4   RD   R5   t   newdataRi   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    /#/; c         C` sO   | s t  d   n  g  | D] } | | ^ q } |  j | | | | |  d S(   u-   Initialize table from a dictionary of columnsu,   Cannot use copy=False with a dict data inputN(   RT   R   (   RC   Ru   RZ   R0   R   R   R4   t	   data_list(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    c         C` sj   | } |  j  j   |  j  j t | j    | j |  _ t | j j    } |  j | | | | |  d S(   u/   Initialize table from an existing Table object N(	   Rz   R_   R`   R   R   R>   Ri   RK   R   (   RC   Ru   RZ   R0   R   R   t   tableRD   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    c         C` s7   | j  |  j k	 r3 t | t  r3 |  j |  } n  | S(   u  
        Make sure that all Column objects have correct class for this type of
        Table.  For a base Table this most commonly means setting to
        MaskedColumn if the table is masked.  Table subclasses like QTable
        override this method.
        (   RO   R   R9   R   (   RC   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _convert_col_for_table  s    !c   	      C` s  t  d   | D  } t |  d k r@ t d j |    n  |  j |  g  | D] } |  j |  ^ qT } |  j |  |  i  } x |  j   D]u } xl t | j	 j
 p g   D]R \ } } t d   | j D  } | | k r | | | j	 j
 | <q | | | <q Wq Wd S(   u7   Initialize table from a list of Column or mixin objectsc         s` s   |  ] } t  |  Vq d  S(   N(   Rh   (   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    i   u%   Inconsistent data column lengths: {0}c         s` s   |  ] } | j  j Vq d  S(   N(   R/   R4   (   RW   t   ind_col(    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    N(   R   Rh   RT   RR   R   R   t   _make_table_from_colst   itercolsR   R/   R   R?   Ri   (	   RC   RD   t   lengthsR5   RE   t
   index_dictR   R   RZ   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    	"%c         C` s   |  j  d |  j  } | j j   | j j t |  j   |  j | _ |  j j   } g  } xm | D]e } |  j	 | j
 _	 | | } | j
 j r | j
 j | | t |   } n  | j |  t | j
 _	 qc W|  j | |  | S(   u3   Create a new table as a referenced slice from self.Rm   (   RO   Rm   Rz   R_   R`   R   R   Ri   RK   R}   R/   R   t   slice_indicesRh   R@   R|   R   (   RC   t   slice_R   RD   RE   R5   t   newcol(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _new_from_slice  s    
!c         C` s   t  d   | D  } d | k r1 t d   n  t |  t |  k rX t d   n  |  j d   | D  } xH | D]@ } |  | j _ |  j rx t	 | d  rx t
 | j  | _ qx qx W| |  _ d S(   u[   
        Make ``table`` in-place so that it represents the given list of ``cols``.
        c         s` s   |  ] } | j  j Vq d  S(   N(   R/   R4   (   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    u    Cannot have None for column nameu   Duplicate column namesc         s` s!   |  ] } | j  j | f Vq d  S(   N(   R/   R4   (   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>%  s    u   maskN(   R   R1   R   Rh   RT   R=   R/   R   Rm   R2   R!   R3   R   Ri   (   R   RD   R   Ri   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    c         c` s!   x |  j  D] } |  | Vq
 Wd S(   u  
        Iterate over the columns of this table.

        Examples
        --------

        To iterate over the columns of a table::

            >>> t = Table([[1], [2]])
            >>> for col in t.itercols():
            ...     print(col)
            col0
            ----
               1
            col1
            ----
               2

        Using ``itercols()`` is similar to  ``for col in t.columns.values()``
        but is syntactically preferred.
        N(   Ri   (   RC   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   .  s    c         C` sB  | d  k rS |  j j g } |  j r4 | j d  n  | j d j t |     n  d d j |  d } | r d d l m	 }	 |	 |  } n  | d  k r d j d	 t
 |    } n  |  j j |  d
 | d | d | d t d d  d | d | d | \ }
 } | d j |
  } t j r>t | t j  r>| j d  } n  | S(   Nu   masked=Trueu
   length={0}u   <u    u   >
i   (   t
   xml_escapeu	   table{id}t   idt   tableidt   htmlt	   max_widtht	   show_namet	   show_unitt
   show_dtypet	   max_linest
   tableclassu   
u   utf-8(   R1   RO   R,   Rm   R@   RR   Rh   RY   t   utils.xml.writerR   R   R{   t   _pformat_tableR|   R   t   PY2R9   t	   text_typet   encode(   RC   R   t
   descr_valsR   R   R   R   R   R8   R   t
   data_linest   outst   out(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _base_repr_G  s&    		c         C` s   |  j  d t d d d t j  S(   NR   R   iR   (   R   R|   R*   t   default_notebook_table_class(   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _repr_html_d  s    c         C` s   |  j  d t d d   S(   NR   R   (   R   R   R1   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR[   h  s    c         C` s   d j  |  j    S(   Nu   
(   RY   t   pformat(   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __unicode__k  s    c         C` s   t  j |   j d  S(   Nu   utf-8(   R   R   R   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt	   __bytes__p  s    c         C` s   t  d   |  j j   D  S(   ur   
        True if table has any mixin columns (defined as columns that are not Column
        subclasses).
        c         s` s   |  ] } t  | t  Vq d  S(   N(   R<   R   (   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>{  s    (   R   Ri   RK   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   has_mixin_columnsu  s    c         C` s0   t  | t  r t St | t  o/ t | t  S(   ug   
        Determine if ``col`` should be added to the table directly as
        a mixin column.
        (   R9   R   R   R<   R   R   (   RC   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   }  s    c         C` s   |  j  j |  | | d | d | d | d | \ } } | d r_ | j d j t |     n  | d }	 x@ t |  D]2 \ }
 } |
 |	 k  r t | d  qv t |  qv Wd	 S(
   u  Print a formatted string representation of the table.

        If no value of ``max_lines`` is supplied then the height of the
        screen terminal is used to set ``max_lines``.  If the terminal
        height cannot be determined then the default is taken from the
        configuration item ``astropy.conf.max_lines``.  If a negative
        value of ``max_lines`` is supplied then there is no line limit
        applied.

        The same applies for max_width except the configuration item is
        ``astropy.conf.max_width``.

        Parameters
        ----------
        max_lines : int
            Maximum number of lines in table output.

        max_width : int or `None`
            Maximum character width of output.

        show_name : bool
            Include a header row for column names. Default is True.

        show_unit : bool
            Include a header row for unit.  Default is to show a row
            for units only if one or more columns has a defined value
            for the unit.

        show_dtype : bool
            Include a header row for column dtypes. Default is True.

        align : str or list or tuple or `None`
            Left/right alignment of columns. Default is right (None) for all
            columns. Other allowed values are '>', '<', '^', and '0=' for
            right, left, centered, and 0-padded, respectively. A list of
            strings can be provided for alignment of tables with multiple
            columns.
        R   R   R   t   alignu   show_lengthu   Length = {0} rowsu   n_headeru   redN(   R{   R   R@   RR   Rh   R   R   t   print(   RC   R   R   R   R   R   R   t   linesR   t   n_headerR   t   line(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   pprint  s    (

c         C` sa   | |  j  k rY |  j d | d t j t |     } |  j | g |  j  j   d t S|  Sd  S(   NR4   Ru   R   (   Ri   R   RI   t   arangeRh   RO   RK   R   (   RC   t   index_row_namet   idx_col(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   _make_index_row_display_table  s
    'i2   u   astropy-defaultu   idxc         C` s:  d d l  m } d d l m } | d k rV d j t |   t j j	 d d   } n  | d |  } | r} |  j
 |  }	 n |  }	 | d k r t j } n  |	 j d	 t d
 d d | d d d t d |  }
 |	 j j   } g  t |  D]$ \ } } | j j d k r | ^ q } |
 | j | d | d | 7}
 | |
  S(   u  Render the table in HTML and show it in the IPython notebook.

        Parameters
        ----------
        tableid : str or `None`
            An html ID tag for the table.  Default is ``table{id}-XXX``, where
            id is the unique integer id of the table object, id(self), and XXX
            is a random number to avoid conflicts when printing the same table
            multiple times.
        table_class : str or `None`
            A string with a list of HTML classes used to style the table.
            The special default string ('astropy-default') means that the string
            will be retrieved from the configuration item
            ``astropy.table.default_notebook_table_class``. Note that these
            table classes may make use of bootstrap, as this is loaded with the
            notebook.  See `this page <http://getbootstrap.com/css/#tables>`_
            for the list of classes.
        css : string
            A valid CSS string declaring the formatting for the table. Defaults
            to ``astropy.table.jsviewer.DEFAULT_CSS_NB``.
        display_length : int, optional
            Number or rows to show. Defaults to 50.
        show_row_index : str or False
            If this does not evaluate to False, a column with the given name
            will be added to the version of the table that gets displayed.
            This new column shows the index of the row in the table itself,
            even when the displayed table is re-sorted by another column. Note
            that if a column with this name already exists, this option will be
            ignored. Defaults to "idx".

        Notes
        -----
        Currently, unlike `show_in_browser` (with ``jsviewer=True``), this
        method needs to access online javascript code repositories.  This is due
        to modern browsers' limitations on accessing local files.  Hence, if you
        call this method while offline (and don't have a cached version of
        jquery and jquery.dataTables), you will not get the jsviewer features.
        i   (   t   JSVieweri    (   t   HTMLu   table{0}-{1}g    .At   display_lengthu   astropy-defaultR   R   iR   R   R   R   u   iufct   csst   sort_columnsN(   t   jsviewerR   t   IPython.displayR   R1   RR   R   RI   t   randomt   randintR   R*   R   R   R|   R   Ri   RK   R   R0   RM   t   ipynb(   RC   R   R  R  t   table_classt   show_row_indexR   R   t   jsvt   display_tableR   Ri   R   R5   t   sortable_columns(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   show_in_notebook  s&    )	i  u   defaultu   use_local_filesu   display compactc	         C` s  d d l  }	 d d l }
 d d l } d d l m } d d l m } d d l m } | d k ri | } n  | j
   } |	 j j | d  } t | d	  r } | r | r |  j |  } n |  } | j | d
 d d | d | d | d | d | n |  j | d
 d Wd QXy% |
 j | d k r(d n |  } Wn* |
 j k
 r^t j d j |   n X| j | d | |    d S(   u  Render the table in HTML and show it in a web browser.

        Parameters
        ----------
        max_lines : int
            Maximum number of rows to export to the table (set low by default
            to avoid memory issues, since the browser view requires duplicating
            the table in memory).  A negative value of ``max_lines`` indicates
            no row limit.
        jsviewer : bool
            If `True`, prepends some javascript headers so that the table is
            rendered as a `DataTables <https://datatables.net>`_ data table.
            This allows in-browser searching & sorting.
        browser : str
            Any legal browser name, e.g. ``'firefox'``, ``'chrome'``,
            ``'safari'`` (for mac, you may need to use ``'open -a
            "/Applications/Google Chrome.app" {}'`` for Chrome).  If
            ``'default'``, will use the system default browser.
        jskwargs : dict
            Passed to the `astropy.table.JSViewer` init. Defaults to
            ``{'use_local_files': True}`` which means that the JavaScript
            libraries will be served from local copies.
        tableid : str or `None`
            An html ID tag for the table.  Default is ``table{id}``, where id
            is the unique integer id of the table object, id(self).
        table_class : str or `None`
            A string with a list of HTML classes used to style the table.
            Default is "display compact", and other possible values can be
            found in https://www.datatables.net/manual/styling/classes
        css : string
            A valid CSS string declaring the formatting for the table. Defaults
            to ``astropy.table.jsviewer.DEFAULT_CSS``.
        show_row_index : str or False
            If this does not evaluate to False, a column with the given name
            will be added to the version of the table that gets displayed.
            This new column shows the index of the row in the table itself,
            even when the displayed table is re-sorted by another column. Note
            that if a column with this name already exists, this option will be
            ignored. Defaults to "idx".
        i    Ni   (   t   urljoin(   t   pathname2urli   (   t   DEFAULT_CSSu
   table.htmlu   wRR   u   jsviewerR  R   t   jskwargst   table_idR	  u   htmlu   defaultu   Browser '{}' not found.u   file:(   t   ost
   webbrowsert   tempfilet   extern.six.moves.urllib.parseR  t   extern.six.moves.urllib.requestR  R  R  R1   t   mkdtempt   pathRY   t   openR   t   writeR]   t   ErrorR   t   errorRR   (   RC   R   R  t   browserR  R   R	  R  R
  R  R  R  R  R  R  t   tmpdirR  t   tmpR  t   br(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   show_in_browser  s0    -	%c
         C` su   |  j  j |  | | d | d | d | d | d | d |	 d | \ }
 } | d rq |
 j d	 j t |     n  |
 S(
   u  Return a list of lines for the formatted string representation of
        the table.

        If no value of ``max_lines`` is supplied then the height of the
        screen terminal is used to set ``max_lines``.  If the terminal
        height cannot be determined then the default is taken from the
        configuration item ``astropy.conf.max_lines``.  If a negative
        value of ``max_lines`` is supplied then there is no line limit
        applied.

        The same applies for ``max_width`` except the configuration item  is
        ``astropy.conf.max_width``.

        Parameters
        ----------
        max_lines : int or `None`
            Maximum number of rows to output

        max_width : int or `None`
            Maximum character width of output

        show_name : bool
            Include a header row for column names. Default is True.

        show_unit : bool
            Include a header row for unit.  Default is to show a row
            for units only if one or more columns has a defined value
            for the unit.

        show_dtype : bool
            Include a header row for column dtypes. Default is True.

        html : bool
            Format the output as an HTML table. Default is False.

        tableid : str or `None`
            An ID tag for the table; only used if html is set.  Default is
            "table{id}", where id is the unique integer id of the table object,
            id(self)

        align : str or list or tuple or `None`
            Left/right alignment of columns. Default is right (None) for all
            columns. Other allowed values are '>', '<', '^', and '0=' for
            right, left, centered, and 0-padded, respectively. A list of
            strings can be provided for alignment of tables with multiple
            columns.

        tableclass : str or list of str or `None`
            CSS classes for the table; only used if html is set.  Default is
            None.

        Returns
        -------
        lines : list
            Formatted table as a list of strings.

        R   R   R   R   R   R   R   u   show_lengthu   Length = {0} rows(   R{   R   R@   RR   Rh   (   RC   R   R   R   R   R   R   R   R   R   R   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   W  s    =	
c      
   C` s,   |  j  j |  | | d | d | d | d S(   u  Interactively browse table with a paging interface.

        Supported keys::

          f, <space> : forward one page
          b : back one page
          r : refresh same page
          n : next row
          p : previous row
          < : go to beginning
          > : go to end
          q : quit browsing
          h : print this help

        Parameters
        ----------
        max_lines : int
            Maximum number of lines in table output

        max_width : int or `None`
            Maximum character width of output

        show_name : bool
            Include a header row for column names. Default is True.

        show_unit : bool
            Include a header row for unit.  Default is to show a row
            for units only if one or more columns has a defined value
            for the unit.

        show_dtype : bool
            Include a header row for column dtypes. Default is True.
        R   R   R   N(   R{   t   _more_tabcol(   RC   R   R   R   R   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   more  s    #c         C` sE  t  | t j  r |  j | St  | t t j f  rE |  j |  |  St  | t j  r | j	 d k r | j
 j d k r |  j |  | j    St  | t t f  rz| rzt d   | D  rzg  | D] } | |  j k r | ^ q } | rt d j d j |     n  |  j g  | D] } |  | ^ qd t |  j  d |  j } t j | d |  j j d |  j j | _ | St  | t j  r| j d	 k st  | t t f  r| r|  j g   St  | t  st  | t j  st  | t  st  | t  r&t d
   | D  r&|  j |  St d j t  |     d  S(   Nu   ic         s` s!   |  ] } t  | t j  Vq d  S(   N(   R9   R   RF   (   RW   RS   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    u*   Slice name(s) {0} not valid column name(s)u   , Rz   R   R   Re   i    c         s` s!   |  ] } t  | t j  Vq d  S(   N(   R9   RI   RL   (   RW   RS   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s   u&   Illegal type {0} for table item access(    (!   R9   R   RF   Ri   RH   RI   RJ   R#   RL   R3   R0   RM   RN   R?   R>   R   R   RT   RR   RY   RO   R   Rz   R}   R   t   TableGroupst   _indicest   _keyst   _groupst   sizeR   RP   R   (   RC   RN   RS   t	   bad_namesR   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRG     s:    3(	#!	c         ` s  t  | t j  rN| |  j k rN|  j r3 |  j n |  j } t   d  rn |  j    rn t	 j
      n  t    t	 j  r t   j  d k r |  j    r   j t    n  | } t    t  s |  j    rt |   d k rt   d t  s)t   d d   d k s)t    d k rt |   f t   d d  d } t    t	 j  ryt   d | d t   qt    t  r  j t d | d t   qn  t    } | | j _ nq t |   d k r|   d | } nJ | d | d	 t |   d
   j d   j d d t   d d    }   | (|  j | g d t nt |  j  } t  | t j  rt |  d t  rt j ry |  j  |    d  SWqt! k
 rqXn    |  j | (nt  | t" t	 j# f  rbt   d  st$ d   n  t    | k r,t% d j& |    n  xt' |  j j(      D] \ } }	 |	 | | <qEWnnt  | t)  st  | t	 j  st  | t*  st  | t+  rt, d   | D  rt    t-  rd     j j(   D }
 n t    t	 j  r  j j. r  f d     j j. D }
 n` t	 j/    rOd d  l0 } | j1   |  }
 n0 t    | k ryt% d j& |    n    }
 xN t' |  j j(   |
  D] \ } }	 |	 | | <qWn t% d j& t2 |     d  S(   Nu   dtypei   i    u   isscalaru   shapeR3   t   subokR4   t   lengthR0   t   unitu   unitR   u   _setitem_inplaceu   __len__u!   Right side value must be iterableu9   Right side value needs {0} elements (one for each column)c         s` s!   |  ] } t  | t j  Vq d  S(   N(   R9   RI   RL   (   RW   RS   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>=  s    c         s` s   |  ] } | Vq d  S(   N(    (   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>@  s    c         3` s   |  ] }   | Vq d  S(   N(    (   RW   R4   (   RV   (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>C  s    u&   Illegal type {0} for table item access(    (    (3   R9   R   RF   R   Rm   R   R   R2   R   RI   t   asarrayRL   Rh   R0   R   R   R   R   R   R1   t   np_broadcast_toR|   R   t   _applyR"   R/   R4   R3   t   add_columnsRi   R*   t   replace_inplacet   _replace_column_warningsR   RH   RJ   R   RT   RR   R   RK   RP   R>   R?   R   Rg   RZ   t   isscalart	   itertoolst   repeatR   (   RC   RN   RV   t	   NewColumnR4   t	   new_shapet
   new_columnR   R5   R   t   valsR6  (    (   RV   s2   lib/python2.7/site-packages/astropy/table/table.pyRU     s    ! '	$#!
	%	%	c         C` sE   t  | t j  r" |  j |  n t  | t  rA |  j |  n  d  S(   N(   R9   R   RF   t   remove_columnR?   t   remove_columns(   RC   RN   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __delitem__V  s    c         C` s   |  j  | S(   u/   Return column[item] for recarray compatibility.(   Ri   (   RC   RN   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   field\  s    c         C` s   |  j  S(   N(   t   _masked(   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRm   `  s    c         C` s   t  d   d  S(   NuZ   Masked attribute is read-only (use t = Table(t, masked=True) to convert to a masked table)(   R   (   RC   Rm   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRm   d  s    c         C` s
  t  |  d  r |  j d k r< | t t g k r< | |  _ q |  j t k rp | t k rp t j d  | |  _ q |  j | k r t d j |    q t d j | |  j    n- | t t d g k r | |  _ n t	 d   |  j r |  j
 |  _ n |  j |  _ d S(   u   
        Set the table masked property.

        Parameters
        ----------
        masked : bool
            State of table masking (`True` or `False`)
        u   _maskeduQ   Upgrading Table to masked Table. Use Table.filled() to convert to unmasked table.u&   Masked attribute is already set to {0}u;   Cannot change masked attribute to {0} once it is set to {1}u)   masked should be one of True, False, NoneN(   R2   R@  R1   R   R|   R   R/   R   RR   RT   R   t   _column_classR   (   RC   Rm   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRy   i  s     	!		c         C` s!   |  j  d  k r |  j S|  j  Sd  S(   N(   RA  R1   R   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    c         C` s/   t  j g  |  j j   D] } t |  ^ q  S(   N(   RI   R0   Ri   RK   R8   (   RC   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR0     s    c         C` s   t  |  j j    S(   N(   R>   Ri   Re   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR     s    c         C` s   t  |  j j    S(   N(   R>   Ri   Re   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRe     s    c         C` s   t  |  j  d k r d St d   |  j j   D  } t  |  d k r g  |  j j   D]$ \ } } d j | t  |   ^ qZ } t d j d j |     n  | j   S(   Ni    c         s` s   |  ] } t  |  Vq d  S(   N(   Rh   (   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    i   u
    {0} : {1}u   Column length mismatch:
{0}u   
(	   Rh   Ri   R   RK   R   RR   RT   RY   t   pop(   RC   R   R4   R5   t   len_strs(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __len__  s    :!c         C` sA   y |  j  j |  SWn& t k
 r< t d j |    n Xd S(   u  
        Return the positional index of column ``name``.

        Parameters
        ----------
        name : str
            column name

        Returns
        -------
        index : int
            Positional index of column ``name``.

        Examples
        --------
        Create a table with three columns 'a', 'b' and 'c'::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3], ['x', 'y', 'z']],
            ...           names=('a', 'b', 'c'))
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              2 0.2   y
              3 0.3   z

        Get index of column 'b' of the table::

            >>> t.index_column('b')
            1
        u   Column {0} does not existN(   R   R   RT   RR   (   RC   R4   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   index_column  s     c         C` sY   | d k r t |  j  } n  | d k	 r6 | f } n  |  j | g | g | d | d S(   uA
  
        Add a new Column object ``col`` to the table.  If ``index``
        is supplied then insert column before ``index`` position
        in the list of columns, otherwise append column to the end
        of the list.

        Parameters
        ----------
        col : Column
            Column object to add.
        index : int or `None`
            Insert column before this position or at end (default).
        name : str
            Column name
        rename_duplicate : bool
            Uniquify column name if it already exist. Default is False.

        Examples
        --------
        Create a table with two columns 'a' and 'b'::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3]], names=('a', 'b'))
            >>> print(t)
             a   b
            --- ---
              1 0.1
              2 0.2
              3 0.3

        Create a third column 'c' and append it to the end of the table::

            >>> col_c = Column(name='c', data=['x', 'y', 'z'])
            >>> t.add_column(col_c)
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              2 0.2   y
              3 0.3   z

        Add column 'd' at position 1. Note that the column is inserted
        before the given index::

            >>> col_d = Column(name='d', data=['a', 'b', 'c'])
            >>> t.add_column(col_d, 1)
            >>> print(t)
             a   d   b   c
            --- --- --- ---
              1   a 0.1   x
              2   b 0.2   y
              3   c 0.3   z

        Add second column named 'b' with rename_duplicate::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3]], names=('a', 'b'))
            >>> col_b = Column(name='b', data=[1.1, 1.2, 1.3])
            >>> t.add_column(col_b, rename_duplicate=True)
            >>> print(t)
             a   b  b_1
            --- --- ---
              1 0.1 1.1
              2 0.2 1.2
              3 0.3 1.3

        Add an unnamed column or mixin object in the table using a default name
        or by specifying an explicit name with ``name``. Name can also be overridden::

            >>> t = Table([[1, 2], [0.1, 0.2]], names=('a', 'b'))
            >>> col_c = Column(data=['x', 'y'])
            >>> t.add_column(col_c)
            >>> t.add_column(col_c, name='c')
            >>> col_b = Column(name='b', data=[1.1, 1.2])
            >>> t.add_column(col_b, name='d')
            >>> print(t)
             a   b  col2  c   d
            --- --- ---- --- ---
              1 0.1    x   x 1.1
              2 0.2    y   y 1.2

        To add several columns use add_columns.
        t   rename_duplicateN(   R1   Rh   Ri   R2  (   RC   R5   R   R4   RF  (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt
   add_column  s
    Rc         C` s  | d k r+ t |  j  g t |  } n' t |  t |  k rR t d   n  | rz g  | D] } t |  ^ q_ } n  t |  j  d k r | } n t |  j j    } t t t |  d   } xL t | |  D]; \ } }	 | j	 |	  }
 | j
 |
 d  | j
 |
 |  q W| d k r7d t |  } n' t |  t |  k r^t d   n  x t t | |   D] \ }
 \ } } | d k r| j j d k	 rqtn  d j |
 t |  j   } n  | j j d k	 rt |  } n  | | j _ qtW| rt |  j  } x | D] } d }
 | j j } | j j | k rx_ | j j | k r| j j d k	 rvt |  } n  d j | |
  } | | j _ |
 d 7}
 qCW| j |  qqWn  |  j |  d S(	   u  
        Add a list of new Column objects ``cols`` to the table.  If a
        corresponding list of ``indexes`` is supplied then insert column
        before each ``index`` position in the *original* list of columns,
        otherwise append columns to the end of the list.

        Parameters
        ----------
        cols : list of Columns
            Column objects to add.
        indexes : list of ints or `None`
            Insert column before this position or at end (default).
        names : list of str
            Column names
        copy : bool
            Make a copy of the new columns. Default is True.
        rename_duplicate : bool
            Uniquify new column names if they duplicate the existing ones.
            Default is False.


        Examples
        --------
        Create a table with two columns 'a' and 'b'::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3]], names=('a', 'b'))
            >>> print(t)
             a   b
            --- ---
              1 0.1
              2 0.2
              3 0.3

        Create column 'c' and 'd' and append them to the end of the table::

            >>> col_c = Column(name='c', data=['x', 'y', 'z'])
            >>> col_d = Column(name='d', data=['u', 'v', 'w'])
            >>> t.add_columns([col_c, col_d])
            >>> print(t)
             a   b   c   d
            --- --- --- ---
              1 0.1   x   u
              2 0.2   y   v
              3 0.3   z   w

        Add column 'c' at position 0 and column 'd' at position 1. Note that
        the columns are inserted before the given position::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3]], names=('a', 'b'))
            >>> col_c = Column(name='c', data=['x', 'y', 'z'])
            >>> col_d = Column(name='d', data=['u', 'v', 'w'])
            >>> t.add_columns([col_c, col_d], [0, 1])
            >>> print(t)
             c   a   d   b
            --- --- --- ---
              x   1   u 0.1
              y   2   v 0.2
              z   3   w 0.3

        Add second column 'b' and column 'c' with ``rename_duplicate``::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3]], names=('a', 'b'))
            >>> col_b = Column(name='b', data=[1.1, 1.2, 1.3])
            >>> col_c = Column(name='c', data=['x', 'y', 'z'])
            >>> t.add_columns([col_b, col_c], rename_duplicate=True)
            >>> print(t)
             a   b  b_1  c
            --- --- --- ---
              1 0.1 1.1  x
              2 0.2 1.2  y
              3 0.3 1.3  z

        Add unnamed columns or mixin objects in the table using default names
        or by specifying explicit names with ``names``. Names can also be overridden::

            >>> t = Table()
            >>> col_a = Column(data=['x', 'y'])
            >>> col_b = Column(name='b', data=['u', 'v'])
            >>> t.add_columns([col_a, col_b])
            >>> t.add_columns([col_a, col_b], names=['c', 'd'])
            >>> print(t)
            col0  b   c   d
            ---- --- --- ---
               x   u   x   u
               y   v   y   v
        u+   Number of indexes must match number of colsi    i   u)   Number of names must match number of colsu   col{}u   {0}_{1}N(   N(   R1   Rh   Ri   RT   R"   R>   RK   R   R   R   t   insertR   R/   R4   RR   R   R   R   t   addR   (   RC   RD   t   indexesRZ   R   RF  R5   RE   t   new_indexesR   R   R4   t   existing_namest	   orig_nameRa   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR2  #  sP    W"	(c         C` s  t  j } d | k r: | |  j k r: t j |  |  } n  | |  j k rV |  | } n  |  j | |  d | k r t j d j |  t	 d d n  d | k r yA t
 | j | j  r d j |  } t j | t	 d d n  Wq t k
 r q Xn  d | k rNt j |  |  } | | k rNd j |  } t j | t	 d d qNn  d	 | k rg  } |  | }	 xE t j D]: }
 t | j |
  t |	 j |
  k rt| j |
  qtqtW| rd
 j | |  } t j | t	 d d qn  d S(   uY   
        Same as replace_column but issues warnings under various circumstances.
        u   refcountu   alwaysu   replaced column '{}'t
   stackleveli   u   sliceuu   replaced column '{}' which looks like an array slice. The new column no longer shares memory with the original array.uH   replaced column '{}' and the number of references to the column changed.u
   attributesu6   replaced column '{}' and column attributes {} changed.N(   R*   t   replace_warningsR   Rj   t   getrefcountt   replace_columnt   warningst   warnRR   R+   R9   t   baseRO   t   AttributeErrorR   t
   attr_namesR   R/   R@   (   RC   R4   R5   t   warnst   refcountt   old_colt   msgt   new_refcountt   changed_attrst   new_colt   attr(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR4    sB    			
$c         C` s   | |  j  k r' t d j |    n  |  | j j rF t d   n  |  j | g d | g } t |  j  } | | | | <|  j | j	    d S(   u$  
        Replace column ``name`` with the new ``col`` object.

        Parameters
        ----------
        name : str
            Name of column to replace
        col : column object (list, ndarray, Column, etc)
            New column object to replace the existing column

        Examples
        --------
        Replace column 'a' with a float version of itself::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3]], names=('a', 'b'))
            >>> float_a = t['a'].astype(float)
            >>> t.replace_column('a', float_a)
        u#   column name {0} is not in the tableu#   cannot replace a table index columnRZ   N(
   R   RT   RR   R/   R   RO   R
   Ri   R   RK   (   RC   R4   R5   t   tRD   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRQ    s    c         C` s;   t  | t j t j f  s* t d   n  |  j |  d S(   u  
        Remove a row from the table.

        Parameters
        ----------
        index : int
            Index of row to remove

        Examples
        --------
        Create a table with three columns 'a', 'b' and 'c'::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3], ['x', 'y', 'z']],
            ...           names=('a', 'b', 'c'))
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              2 0.2   y
              3 0.3   z

        Remove row 1 from the table::

            >>> t.remove_row(1)
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              3 0.3   z

        To remove several rows at the same time use remove_rows.
        u   Row index must be an integerN(   R9   R   t   integer_typesRI   RJ   R   t   remove_rows(   RC   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt
   remove_row  s    "c         C` s   x |  j  D] } | j |  q
 Wt j t |   d t j } t | | <|  j   } x= |  j j	   D], \ } } | | } |  | j
 _ | | | <qe W|  j |  t |  d  r |  ` n  d S(   ut  
        Remove rows from the table.

        Parameters
        ----------
        row_specifier : slice, int, or array of ints
            Specification for rows to remove

        Examples
        --------
        Create a table with three columns 'a', 'b' and 'c'::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3], ['x', 'y', 'z']],
            ...           names=('a', 'b', 'c'))
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              2 0.2   y
              3 0.3   z

        Remove rows 0 and 2 from the table::

            >>> t.remove_rows([0, 2])
            >>> print(t)
             a   b   c
            --- --- ---
              2 0.2   y


        Note that there are no warnings if the slice operator extends
        outside the data::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3], ['x', 'y', 'z']],
            ...           names=('a', 'b', 'c'))
            >>> t.remove_rows(slice(10, 20, 1))
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              2 0.2   y
              3 0.3   z
        R0   u   _groupsN(   R   Ra  RI   t   onesRh   R   R   R=   Ri   R   R/   R   t   _replace_colsR2   R)  (   RC   t   row_specifierR   t	   keep_maskRi   R4   R5   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRa  )  s    -

c         C` s   |  j  | g  d S(   uR  
        Remove a column from the table.

        This can also be done with::

          del table[name]

        Parameters
        ----------
        name : str
            Name of column to remove

        Examples
        --------
        Create a table with three columns 'a', 'b' and 'c'::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3], ['x', 'y', 'z']],
            ...           names=('a', 'b', 'c'))
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              2 0.2   y
              3 0.3   z

        Remove column 'b' from the table::

            >>> t.remove_column('b')
            >>> print(t)
             a   c
            --- ---
              1   x
              2   y
              3   z

        To remove several columns at the same time use remove_columns.
        N(   R=  (   RC   R4   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR<  h  s    'c         C` s{   t  | t j  r | g } n  x5 | D]- } | |  j k r% t d j |    q% q% Wx | D] } |  j j |  q] Wd S(   u  
        Remove several columns from the table.

        Parameters
        ----------
        names : list
            A list containing the names of the columns to remove

        Examples
        --------
        Create a table with three columns 'a', 'b' and 'c'::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3], ['x', 'y', 'z']],
            ...     names=('a', 'b', 'c'))
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              2 0.2   y
              3 0.3   z

        Remove columns 'b' and 'c' from the table::

            >>> t.remove_columns(['b', 'c'])
            >>> print(t)
             a
            ---
              1
              2
              3

        Specifying only a single column also works. Remove column 'b' from the table::

            >>> t = Table([[1, 2, 3], [0.1, 0.2, 0.3], ['x', 'y', 'z']],
            ...     names=('a', 'b', 'c'))
            >>> t.remove_columns('b')
            >>> print(t)
             a   c
            --- ---
              1   x
              2   y
              3   z

        This gives the same as using remove_column.
        u   Column {0} does not existN(   R9   R   RF   Ri   R\   RR   RB  (   RC   RZ   R4   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR=    s    .c   	      ` s   | r t  j r d S|  j j   } t   f d   | D  sB d Sg  } xf | D]^ } | j j   k r t j   | | j j	  } | j
 | d | } n | } | j |  qO W|  j |  d S(   u8  
        Convert string-like columns to/from bytestring and unicode (internal only).

        Parameters
        ----------
        in_kind : str
            Input dtype.kind
        out_kind : str
            Output dtype.kind
        python3_only : bool
            Only do this operation for Python 3
        Nc         3` s!   |  ] } | j  j   k Vq d  S(   N(   R0   RM   (   RW   R5   (   t   in_kind(    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    R0   (   R   R   Ri   RK   R   R0   RM   t   ret   subt   strRO   R@   R   (	   RC   Rg  t   out_kindt   python3_onlyRD   RE   R5   t   newdtypeR   (    (   Rg  s2   lib/python2.7/site-packages/astropy/table/table.pyt   _convert_string_dtype  s    c         C` s   |  j  d d |  d S(   u  
        Convert bytestring columns (dtype.kind='S') to unicode (dtype.kind='U') assuming
        ASCII encoding.

        Internally this changes string columns to represent each character in the string
        with a 4-byte UCS-4 equivalent, so it is inefficient for memory but allows Python
        3 scripts to manipulate string arrays with natural syntax.

        The ``python3_only`` parameter is provided as a convenience so that code can
        be written in a Python 2 / 3 compatible way::

          >>> t = Table.read('my_data.fits')
          >>> t.convert_bytestring_to_unicode(python3_only=True)

        Parameters
        ----------
        python3_only : bool
            Only do this operation for Python 3
        u   Su   UN(   Rn  (   RC   Rl  (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   convert_bytestring_to_unicode  s    c         C` s   |  j  d d |  d S(   u  
        Convert ASCII-only unicode columns (dtype.kind='U') to bytestring (dtype.kind='S').

        When exporting a unicode string array to a file in Python 3, it may be desirable
        to encode unicode columns as bytestrings.  This routine takes advantage of numpy
        automated conversion which works for strings that are pure ASCII.

        The ``python3_only`` parameter is provided as a convenience so that code can
        be written in a Python 2 / 3 compatible way::

          >>> t.convert_unicode_to_bytestring(python3_only=True)
          >>> t.write('my_data.fits')

        Parameters
        ----------
        python3_only : bool
            Only do this operation for Python 3
        u   Uu   SN(   Rn  (   RC   Rl  (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   convert_unicode_to_bytestring  s    c         C` s   t  | t j  r | g } n  x5 | D]- } | |  j k r% t d j |    q% q% Wt t |  j    t |   } |  j	 |  d S(   u  
        Keep only the columns specified (remove the others).

        Parameters
        ----------
        names : list
            A list containing the names of the columns to keep. All other
            columns will be removed.

        Examples
        --------
        Create a table with three columns 'a', 'b' and 'c'::

            >>> t = Table([[1, 2, 3],[0.1, 0.2, 0.3],['x', 'y', 'z']],
            ...           names=('a', 'b', 'c'))
            >>> print(t)
             a   b   c
            --- --- ---
              1 0.1   x
              2 0.2   y
              3 0.3   z

        Specifying only a single column name keeps only this column.
        Keep only column 'a' of the table::

            >>> t.keep_columns('a')
            >>> print(t)
             a
            ---
              1
              2
              3

        Specifying a list of column names is keeps is also possible.
        Keep columns 'a' and 'c' of the table::

            >>> t = Table([[1, 2, 3],[0.1, 0.2, 0.3],['x', 'y', 'z']],
            ...           names=('a', 'b', 'c'))
            >>> t.keep_columns(['a', 'c'])
            >>> print(t)
             a   c
            --- ---
              1   x
              2   y
              3   z
        u   Column {0} does not existN(
   R9   R   RF   Ri   R\   RR   R>   R   Re   R=  (   RC   RZ   R4   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   keep_columns  s    0"c         C` sA   | |  j    k r* t d j |    n  | |  j | j _ d S(   ug  
        Rename a column.

        This can also be done directly with by setting the ``name`` attribute
        for a column::

          table[name].name = new_name

        TODO: this won't work for mixins

        Parameters
        ----------
        name : str
            The current name of the column.
        new_name : str
            The new name for the column

        Examples
        --------
        Create a table with three columns 'a', 'b' and 'c'::

            >>> t = Table([[1,2],[3,4],[5,6]], names=('a','b','c'))
            >>> print(t)
             a   b   c
            --- --- ---
              1   3   5
              2   4   6

        Renaming column 'a' to 'aa'::

            >>> t.rename_column('a' , 'aa')
            >>> print(t)
             aa  b   c
            --- --- ---
              1   3   5
              2   4   6
        u   Column {0} does not existN(   Re   R\   RR   Ri   R/   R4   (   RC   R4   Ra   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   rename_columnO  s    'c         C` s   |  j  t |   | |  d S(   u  Add a new row to the end of the table.

        The ``vals`` argument can be:

        sequence (e.g. tuple or list)
            Column values in the same order as table columns.
        mapping (e.g. dict)
            Keys corresponding to column names.  Missing values will be
            filled with np.zeros for the column dtype.
        `None`
            All values filled with np.zeros for the column dtype.

        This method requires that the Table object "owns" the underlying array
        data.  In particular one cannot add a row to a Table that was
        initialized with copy=False from an existing array.

        The ``mask`` attribute should give (if desired) the mask for the
        values. The type of the mask should match that of the values, i.e. if
        ``vals`` is an iterable, then ``mask`` should also be an iterable
        with the same length, and if ``vals`` is a mapping, then ``mask``
        should be a dictionary.

        Parameters
        ----------
        vals : tuple, list, dict or `None`
            Use the specified values in the new row
        mask : tuple, list, dict or `None`
            Use the specified mask values in the new row

        Examples
        --------
        Create a table with three columns 'a', 'b' and 'c'::

           >>> t = Table([[1,2],[4,5],[7,8]], names=('a','b','c'))
           >>> print(t)
            a   b   c
           --- --- ---
             1   4   7
             2   5   8

        Adding a new row with entries '3' in 'a', '6' in 'b' and '9' in 'c'::

           >>> t.add_row([3,6,9])
           >>> print(t)
             a   b   c
             --- --- ---
             1   4   7
             2   5   8
             3   6   9
        N(   t
   insert_rowRh   (   RC   R;  R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   add_row{  s    3c         ` s  |  j    t |   } | | k  s. | | k rI t d j | |    n  | d k  rb | | 7} n  d   } | d k	 r |  j r |  j t  n  | |  s | d k r%| d k	 r | |  r t d   n  | d k	 rt	 | j
    t	 | j
    k rt d   n  | rAt   f d   | D  rAt d   n  g  } g  } x   D] } | r| | k r| j | |  | j | d k rt n | |  qT|  | }	 t |	 d  r| j t j d	 d d
 |	 j   | j |  j o| d k	  qTt d j |    qTW| } | } n  t |  r| d k	 ret |  sV| |  ret d   n  t |  j  t |  k rt d   n  | d k	 rt |  j  t |  k rt d   qqt g t |  j  } n t d   |  j   }
 ygx0t   |  j j   | |  D]\ } }	 } } t |	 t  rgt |	 |  j  rg|  j |	 d t }	 n  |	 j | | d d } t | t  s| | j _ |  j rt | j   | _! qn  t |  | d k rt d j | | t |  | d    n  |  | j _" |  j r!| | j! | <n  | |
 | <qWx- |  j# D]" } | j$ | | |  j j    q9WWn+ t% k
 r} t d j | |    n& X|  j& |
  t |  d  r|  `' n  d S(   u  Add a new row before the given ``index`` position in the table.

        The ``vals`` argument can be:

        sequence (e.g. tuple or list)
            Column values in the same order as table columns.
        mapping (e.g. dict)
            Keys corresponding to column names.  Missing values will be
            filled with np.zeros for the column dtype.
        `None`
            All values filled with np.zeros for the column dtype.

        The ``mask`` attribute should give (if desired) the mask for the
        values. The type of the mask should match that of the values, i.e. if
        ``vals`` is an iterable, then ``mask`` should also be an iterable
        with the same length, and if ``vals`` is a mapping, then ``mask``
        should be a dictionary.

        Parameters
        ----------
        vals : tuple, list, dict or `None`
            Use the specified values in the new row
        mask : tuple, list, dict or `None`
            Use the specified mask values in the new row
        u4   Index {0} is out of bounds for table with length {1}i    c         ` s    d } t    f d   | D  S(	   u9   Minimal checker for mapping (dict-like) interface for obju   __getitem__u   __len__u   __iter__u   keysu   valuesu   itemsc         3` s   |  ] } t    |  Vq d  S(   N(   R2   (   RW   R^  (   R:   (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    (   u   __getitem__u   __len__u   __iter__u   keysu   valuesu   items(   R   (   R:   t   attrs(    (   R:   s2   lib/python2.7/site-packages/astropy/table/table.pyt   _is_mapping  s    u&   Mismatch between type of vals and masku&   keys in mask should match keys in valsc         3` s   |  ] } |   k Vq d  S(   N(    (   RW   R4   (   R   (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>  s    u+   Keys in vals must all be valid column namesu   dtypeR3   R0   u'   Value must be supplied for column '{0}'u+   Mismatch between number of vals and columnsu,   Mismatch between number of masks and columnsu+   Vals must be an iterable or mapping or NoneR   t   axisi   uK   Incorrect length for column {0} after inserting {1} (expected {2}, got {3})u>   Unable to insert row because of exception in column '{0}':
{1}u   _groupsN(    ((   R   Rh   RQ   RR   R1   Rm   Ry   R|   R   R   Re   RT   R   R@   R   R2   RI   t   zerosR0   R   Ri   R=   R   RK   R9   R   R   RH  R   R/   R4   R!   R3   R   R   R   Rs  R   Rd  R)  (   RC   R   R;  R   t   NRv  t	   vals_listt	   mask_listR4   R5   Ri   R   t   mask_R   t   table_indext   err(    (   R   s2   lib/python2.7/site-packages/astropy/table/table.pyRs    s    			0"&
"	%1"		"	$	c         C` s   x~ t  |  j j   | j    D]^ \ } } g  | j _ xC | j j D]5 } | | j | j | j j  <| j j j |  qD Wq W| |  _ d  S(   N(   R   Ri   RK   R/   R   R   R4   R@   (   RC   Ri   R5   R]  R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRd  <	  s    +c         C` s   t  | t j  r | g } n  | d k	 rV t |  |  |  } | d k	 rV | j   Sn  i  } | ro | | d <n  | r | | d <n  | r |  | j   } n |  j   } | j |   S(   u_  
        Return the indices which would sort the table according to one or
        more key columns.  This simply calls the `numpy.argsort` function on
        the table with the ``order`` parameter set to ``keys``.

        Parameters
        ----------
        keys : str or list of str
            The column name(s) to order the table by
        kind : {'quicksort', 'mergesort', 'heapsort'}, optional
            Sorting algorithm.

        Returns
        -------
        index_array : ndarray, int
            Array of indices that sorts the table by the specified key
            column(s).
        u   orderu   kindN(   R9   R   RF   R1   R)   t   sorted_dataRv   t   argsort(   RC   Re   RM   R   R   Ru   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  E	  s    c         C` s  | d k rP |  j s$ t d   n  g  |  j d j D] } | j j ^ q5 } n  t | t j  rn | g } n  |  j	 |  } t
 |  |  |  } | d k	 r | j } t | _ n  x- |  j j   D] } | j | d d | (q W| d k	 r| | _ | j   n  d S(   u*  
        Sort the table according to one or more keys. This operates
        on the existing table and does not return a new table.

        Parameters
        ----------
        keys : str or list of str
            The key(s) to order the table by. If None, use the
            primary index of the Table.

        Examples
        --------
        Create a table with 3 columns::

            >>> t = Table([['Max', 'Jo', 'John'], ['Miller','Miller','Jackson'],
            ...         [12,15,18]], names=('firstname','name','tel'))
            >>> print(t)
            firstname   name  tel
            --------- ------- ---
                  Max  Miller  12
                   Jo  Miller  15
                 John Jackson  18

        Sorting according to standard sorting rules, first 'name' then 'firstname'::

            >>> t.sort(['name','firstname'])
            >>> print(t)
            firstname   name  tel
            --------- ------- ---
                 John Jackson  18
                   Jo  Miller  15
                  Max  Miller  12
        u/   Table sort requires input keys or a table indexi    Rw  N(   R1   R   RT   Ri   R/   R4   R9   R   RF   R  R)   t   _frozenR|   RK   t   taket   sort(   RC   Re   RS   RJ  t
   sort_indext   prev_frozenR5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  n	  s     "	,		c         C` sP   x+ |  j  j   D] } | d d d  | (q Wx |  j D] } | j   q8 Wd S(   u)  
        Reverse the row order of table rows.  The table is reversed
        in place and there are no function arguments.

        Examples
        --------
        Create a table with three columns::

            >>> t = Table([['Max', 'Jo', 'John'], ['Miller','Miller','Jackson'],
            ...         [12,15,18]], names=('firstname','name','tel'))
            >>> print(t)
            firstname   name  tel
            --------- ------- ---
                  Max  Miller  12
                   Jo  Miller  15
                 John Jackson  18

        Reversing order::

            >>> t.reverse()
            >>> print(t)
            firstname   name  tel
            --------- ------- ---
                 John Jackson  18
                   Jo  Miller  15
                  Max  Miller  12
        Ni(   Ri   RK   R   t   reverse(   RC   R5   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  	  s    c         O` sm   t  j |  | |  } |  | j k	 ri y |  | d t } Wqi t k
 re t d j |  j    qi Xn  | S(   u^  
        Read and parse a data table and return as a Table.

        This function provides the Table interface to the astropy unified I/O
        layer.  This allows easily reading a file in many supported data formats
        using syntax such as::

          >>> from astropy.table import Table
          >>> dat = Table.read('table.dat', format='ascii')
          >>> events = Table.read('events.fits', format='fits')

        The arguments and keywords (other than ``format``) provided to this function are
        passed through to the underlying data reader (e.g. `~astropy.io.ascii.read`).
        R   u-   could not convert reader output to {0} class.(   t   io_registryt   readRO   R   R   R   RR   R,   (   R;   t   argsR   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  	  s    	c         O` s   t  j |  | |  d S(   uX  
        Write this Table object out in the specified format.

        This function provides the Table interface to the astropy unified I/O
        layer.  This allows easily writing a file in many supported data formats
        using syntax such as::

          >>> from astropy.table import Table
          >>> dat = Table([[1, 2], [3, 4]], names=('a', 'b'))
          >>> dat.write('table.dat', format='ascii')

        The arguments and keywords (other than ``format``) provided to this function are
        passed through to the underlying data reader (e.g. `~astropy.io.ascii.write`).
        N(   R  R  (   RC   R  R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  	  s    c         C` sU   |  j  |  d | } t |  d  rQ t j | d |  j j d |  j j | _ n  | S(   u;  
        Return a copy of the table.

        Parameters
        ----------
        copy_data : bool
            If `True` (the default), copy the underlying data array.
            Otherwise, use the same data array. The ``meta`` is always
            deepcopied regardless of the value for ``copy_data``.
        R   u   _groupsR   Re   (   RO   R2   R   R&  R)  R'  R(  (   RC   t	   copy_dataR   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   	  s
    c         C` s   |  j  t  S(   N(   R   R|   (   RC   t   memo(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __deepcopy__
  s    c         C` s   |  j  t  S(   N(   R   R   (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __copy__
  s    c         C` sG   t  j r- t d j t t |      n t t |   j |  Sd  S(   Nu    unorderable types: Table() < {0}(	   R   R   R   RR   Rj  R   RA   Rg   t   __lt__(   RC   t   other(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  
  s    		c         C` sG   t  j r- t d j t t |      n t t |   j |  Sd  S(   Nu    unorderable types: Table() > {0}(	   R   R   R   RR   Rj  R   RA   Rg   t   __gt__(   RC   R  (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  
  s    		c         C` sG   t  j r- t d j t t |      n t t |   j |  Sd  S(   Nu!   unorderable types: Table() <= {0}(	   R   R   R   RR   Rj  R   RA   Rg   t   __le__(   RC   R  (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  
  s    		c         C` sG   t  j r- t d j t t |      n t t |   j |  Sd  S(   Nu!   unorderable types: Table() >= {0}(	   R   R   R   RR   Rj  R   RA   Rg   t   __ge__(   RC   R  (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  &
  s    		c         C` s.  t  | t  r | j   } n  |  j r t  | t j j  rQ |  j   | k } q*t j d d g  |  j j	 D] } | t
 f ^ qj } |  j   j | k |  j | k @} n t  | t j j  rt j d d g  | j j	 D] } | t
 f ^ q } |  j   | j k | j | k @} n |  j   | k } | S(   Ni   R0   (   R9   Rg   Rv   Rm   RI   R   R   Rx  R0   RZ   R   Ru   R   (   RC   R  t   resultt   nt
   false_mask(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __eq__-
  s    	4%4%c         C` s   |  j  |  S(   N(   R  (   RC   R  (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __ne__E
  s    c         C` s+   t  |  d  s$ t j |   |  _ n  |  j S(   Nu   _groups(   R2   R   R&  R)  (   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   H
  s    c         C` s(   |  j  r t d   n  t j |  |  S(   u<  
        Group this table by the specified ``keys``

        This effectively splits the table into groups which correspond to
        unique values of the ``keys`` grouping object.  The output is a new
        `TableGroups` which contains a copy of this table but sorted by row
        according to ``keys``.

        The ``keys`` input to `group_by` can be specified in different ways:

          - String or list of strings corresponding to table column name(s)
          - Numpy array (homogeneous or structured) with same length as this table
          - `Table` with same length as this table

        Parameters
        ----------
        keys : str, list of str, numpy array, or `Table`
            Key grouping object

        Returns
        -------
        out : `Table`
            New table with groups set
        u4   group_by not available for tables with mixin columns(   R   t   NotImplementedErrorR   t   table_group_by(   RC   Re   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   group_byN
  s    	c         C` s  d d l  m } |  j r( t d   n  t d   |  j j   D  rV t d   n  t   } x|  j j   D]\ } } t	 | t
  r?t j | j  r?| j j d k r | j t  j t j  | | <t j d j |  t d	 d
 qI| j j d k r| j t j  | | <qI| j t j  j t j  | | <n
 | | | <| | j j d k ro | | j   j   | | <qo qo W| |  S(   uv  
        Return a :class:`pandas.DataFrame` instance

        Returns
        -------
        dataframe : :class:`pandas.DataFrame`
            A pandas :class:`pandas.DataFrame` instance

        Raises
        ------
        ImportError
            If pandas is not installed
        ValueError
            If the Table contains mixin or multi-dimensional columns
        i    (   t	   DataFrameu?   Cannot convert a table with mixin columns to a pandas DataFramec         s` s'   |  ] } t  | d  d  d k Vq d S(   u   ndimi   N(   R   (   RW   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>
  s    uK   Cannot convert a table with multi-dimensional columns to a pandas DataFrameu   iu   uu+   converted column '{}' from integer to floatRN  i   u   fu   cu   =u   |(   u   iu   u(   u   fu   c(   u   =u   |(   t   pandasR  R   RT   R   Ri   RK   R
   R   R9   R   RI   R   R0   RM   t   astypet   floatR   t   nanRR  RS  RR   R+   t   objectRk   t   byteswapRl   (   RC   R  R   R4   R   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt	   to_pandasl
  s(    		!%
!c         ` s-  t    } x| j D]} | | } t j | j    } t j |  } | j j d k r t j  t j	 s{  t
 f 7 n  t j   t    f d   | D  r d | | <t j g  | D] } | ^ q  } q n  t j |  rt d | d | d |  | | <q t d | d |  | | <q W|  |  S(   uA  
        Create a `Table` from a :class:`pandas.DataFrame` instance

        Parameters
        ----------
        dataframe : :class:`pandas.DataFrame`
            The pandas :class:`pandas.DataFrame` instance

        Returns
        -------
        table : `Table`
            A `Table` (or subclass) instance
        u   Oc         3` s*   |  ]  } t  |   p! |   k Vq d  S(   N(   R9   (   RW   RS   (   R  RF   (    s2   lib/python2.7/site-packages/astropy/table/table.pys	   <genexpr>
  s    t    Ru   R4   R   (   R
   Ri   RI   t   arrayt   isnullR0   RM   R   RF   R   t   bytesR  R   R   R   R   (   R;   t	   dataframeR   R4   R   R   Ru   RS   (    (   R  RF   s2   lib/python2.7/site-packages/astropy/table/table.pyt   from_pandas
  s"    	
			
("N(k   R,   R-   R.   R   Rz   R#   R   R   R=   R   R   Rv   R1   R|   RB   R   R   t   propertyR   t   setterR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   staticmethodR   R   R   R   R[   R   R   R   t   __str__R   R   R   R   R   R  R#  R   R%  RG   RU   R>  R?  Rm   Ry   R   R0   R   Re   RD  RE  RG  R2  R4  RQ  Rb  Ra  R<  R=  Rn  Ro  Rp  Rq  Rr  Rt  Rs  Rd  R  R  R  t   classmethodR  R  R   R  R  R  R  R  R  R  R  R   R  R  R  R&   R/   (    (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyRg      s   $	/			!				
		+		
																	5		@L	E	%	$	n						%Y	7		&	?	)	8	 	;	,5		):	!										-.t   QTablec           B` s    e  Z d  Z d   Z d   Z RS(   uv  A class to represent tables of heterogeneous data.

    `QTable` provides a class for heterogeneous tabular data which can be
    easily modified, for instance adding columns or new rows.

    The `QTable` class is identical to `Table` except that columns with an
    associated ``unit`` attribute are converted to `~astropy.units.Quantity`
    objects.

    Parameters
    ----------
    data : numpy ndarray, dict, list, Table, or table-like object, optional
        Data to initialize table.
    masked : bool, optional
        Specify whether the table is masked.
    names : list, optional
        Specify column names.
    dtype : list, optional
        Specify column data types.
    meta : dict, optional
        Metadata associated with the table.
    copy : bool, optional
        Copy the input data. Default is True.
    rows : numpy ndarray, list of lists, optional
        Row-oriented data for table instead of ``data`` argument.
    copy_indices : bool, optional
        Copy any indices in the input data. Default is True.
    **kwargs : dict, optional
        Additional keyword args when converting table-like object.

    c         C` s   t  | t  S(   ug   
        Determine if ``col`` should be added to the table directly as
        a mixin column.
        (   R<   R   (   RC   R5   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   
  s    c         C` s   t  | t  rl t | d d   d  k	 rl t | j d t  } | | j | j d t } | j | _ | } n t	 t
 |   j |  } | S(   Nu   unitu   _quantity_classR   (   R9   R   R   R1   R.  R   Ru   R   R/   RA   R  R   (   RC   R5   t   q_clst   qcol(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   
  s    '	(   R,   R-   R.   R   R   (    (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR  
  s   	R   c           B` s;   e  Z d  Z e   Z d   Z d   Z d   Z d   Z RS(   u   
    Mixin column class to allow storage of arbitrary numpy
    ndarrays within a Table.  This is a subclass of numpy.ndarray
    and has the same initialization options as ndarray().
    c         O` sI   t  j | | |  j |   } d t | d d  k rE | j | _ n  | S(   Nu   infou   __dict__(    (   RI   R  R   R   R/   (   R;   R:   R  R   RC   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   __new__  s    c         C` so   | d  k r d  St j t t |   j  rD t t |   j |  n  d t | d d  k rk | j |  _ n  d  S(   Nu   infou   __dict__(    (   R1   R   t   callableRA   R   t   __array_finalize__R   R/   (   RC   R:   (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR    s    c         C` s<   t  t t |   j    } | d |  j f | d <t |  S(   Ni   (   R>   RA   R   t
   __reduce__t   __dict__R?   (   RC   t   object_state(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR    s    c         C` s6   | \ } } t  t |   j |  |  j j |  d  S(   N(   RA   R   R   R  R`   (   RC   R   t   nd_statet	   own_state(    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR   #  s    (	   R,   R-   R.   R   R/   R  R  R  R   (    (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyR      s   				(P   t
   __future__R    R   R   R   t   externR   t   extern.six.movesR   R   R   R   R   R	   Rh  Rj   t   collectionsR
   R   RR  R   R   t   numpyRI   R   R  R   t   ioR   R  t   unitsR   R   t   utilsR   R   t   utils.compat.numpyR   R0  t   utils.consoleR   t   utils.metadataR   t   utils.data_infoR   R   R   R   R   R   R   R   R   R   R   R    R!   R"   Rx   R#   t   np_utilsR$   R%   R/   R&   R'   R(   R)   R*   t   __doctest_skip__t   UserWarningR+   R8   R<   R=   R  Rg   R  RL   R   (    (    (    s2   lib/python2.7/site-packages/astropy/table/table.pyt   <module>   s\   "".			w          6