ó
šßÈ[c           @` së  d  Z  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 d d l 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 m Z d d l m Z d d l m Z d d l m Z m Z d d d d g Z d d „ Z d „  Z  d „  Z! d d d d d g d d „ Z# d d d „ Z$ d d d d d „ Z% d e& d d  „ Z' d d d! „ Z( d" „  Z) d# „  Z* d d d d d g d d d$ „ Z+ d d d d% „ Z, d d d d d& „ Z- d S('   u>   
High-level table operations:

- join()
- hstack()
- vstack()
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsi   (   t   six(   t   zipt   range(   t   deepcopyN(   t   OrderedDictt   Counter(   t   ma(   t   metadatai   (   t   Column(   t	   _np_utils(   t   fix_column_namet   TableMergeErroru   joinu   hstacku   vstacku   uniqueu   warnc         C` sW   t  | d j ƒ } x- | d D]! } t j | | j d | ƒ} q W|  j j | ƒ d  S(   Ni    i   t   metadata_conflicts(   R   t   metaR   t   merget   update(   t   outt   tablesR   t   out_metat   table(    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyt   _merge_table_meta    s    c         ` s¬   d d l  m ‰ m ‰  t |  t j ƒ s4 |  g }  n  t ‡  ‡ f d †  |  Dƒ ƒ se t |  ƒ d k rt t d ƒ ‚ n  g  |  D]' } t | ˆ ƒ r– | n	 ˆ | ƒ ^ q{ }  |  S(   ul   
    Check that tables is a Table or sequence of Tables.  Returns the
    corresponding list of Tables.
    i   (   t   Tablet   Rowc         3` s%   |  ] } t  | ˆ ˆ  f ƒ Vq d  S(   N(   t
   isinstance(   t   .0t   x(   R   R   (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>3   s    i    u:   `tables` arg must be a Table or sequence of Tables or Rows(	   R   R   R   R   t   collectionst   Sequencet   anyt   lent	   TypeError(   R   R   (    (   R   R   s7   lib/python2.7/site-packages/astropy/table/operations.pyt   _get_list_of_tables'   s    14c         ` s‘   |  d j  ‰  x0 |  d D]$ } t | j  ˆ  ƒ r | j  ‰  q q Wt ‡  f d †  |  Dƒ ƒ r t d j g  |  D] } | j  j ^ ql ƒ ƒ ‚ n  ˆ  S(   u¹   
    From a list of input objects ``objs`` get merged output object class.

    This is just taken as the deepest subclass. This doesn't handle complicated
    inheritance schemes.
    i    i   c         3` s"   |  ] } t  ˆ  | j ƒ Vq d  S(   N(   t
   issubclasst	   __class__(   R   t   obj(   t	   out_class(    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>H   s    u   unmergeable object classes {}(   R%   R$   R    t
   ValueErrort   formatt   __name__(   t   objsR&   (    (   R'   s7   lib/python2.7/site-packages/astropy/table/operations.pyt   _get_out_class<   s    	(u   inneru   {col_name}_{table_name}u   1u   2c   
   	   C` s“   d d l  m } t |  | ƒ s. | |  ƒ }  n  t | | ƒ sL | | ƒ } n  t ƒ  } t |  | | | | | | | ƒ }	 t |	 |  | g d | ƒ|	 S(   uf  
    Perform a join of the left table with the right table on specified keys.

    Parameters
    ----------
    left : Table object or a value that will initialize a Table object
        Left side table in the join
    right : Table object or a value that will initialize a Table object
        Right side table in the join
    keys : str or list of str
        Name(s) of column(s) used to match rows of left and right tables.
        Default is to use all columns which are common to both tables.
    join_type : str
        Join type ('inner' | 'outer' | 'left' | 'right'), default is 'inner'
    uniq_col_name : str or None
        String generate a unique output column name in case of a conflict.
        The default is '{col_name}_{table_name}'.
    table_names : list of str or None
        Two-element list of table names used when generating unique output
        column names.  The default is ['1', '2'].
    metadata_conflicts : str
        How to proceed with metadata conflicts. This should be one of:
            * ``'silent'``: silently pick the last conflicting meta-data value
            * ``'warn'``: pick the last conflicting meta-data value, but emit a warning (default)
            * ``'error'``: raise an exception.

    Returns
    -------
    joined_table : `~astropy.table.Table` object
        New table containing the result of the join operation.
    i   (   R   R   (   R   R   R   R   t   _joinR   (
   t   leftt   rightt   keyst	   join_typet   uniq_col_namet   table_namesR   R   t   col_name_mapR   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyt   joinO   s    "	u   outerc         C` s[   t  |  ƒ }  t |  ƒ d k r& |  d St ƒ  } t |  | | | ƒ } t | |  d | ƒ| S(   ux  
    Stack tables vertically (along rows)

    A ``join_type`` of 'exact' means that the tables must all have exactly
    the same column names (though the order can vary).  If ``join_type``
    is 'inner' then the intersection of common columns will be the output.
    A value of 'outer' (default) means the output will have the union of
    all columns, with table values being masked where no common values are
    available.

    Parameters
    ----------
    tables : Table or list of Table objects
        Table(s) to stack along rows (vertically) with the current table
    join_type : str
        Join type ('inner' | 'exact' | 'outer'), default is 'outer'
    metadata_conflicts : str
        How to proceed with metadata conflicts. This should be one of:
            * ``'silent'``: silently pick the last conflicting meta-data value
            * ``'warn'``: pick the last conflicting meta-data value, but emit a warning (default)
            * ``'error'``: raise an exception.

    Returns
    -------
    stacked_table : `~astropy.table.Table` object
        New table containing the stacked data from the input tables.

    Examples
    --------
    To stack two tables along rows do::

      >>> from astropy.table import vstack, Table
      >>> t1 = Table({'a': [1, 2], 'b': [3, 4]}, names=('a', 'b'))
      >>> t2 = Table({'a': [5, 6], 'b': [7, 8]}, names=('a', 'b'))
      >>> print(t1)
       a   b
      --- ---
        1   3
        2   4
      >>> print(t2)
       a   b
      --- ---
        5   7
        6   8
      >>> print(vstack([t1, t2]))
       a   b
      --- ---
        1   3
        2   4
        5   7
        6   8
    i   i    R   (   R#   R!   R   t   _vstackR   (   R   R1   R   R4   R   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyt   vstack„   s    5	c         C` s^   t  |  ƒ }  t |  ƒ d k r& |  d St ƒ  } t |  | | | | ƒ } t | |  d | ƒ| S(   u§  
    Stack tables along columns (horizontally)

    A ``join_type`` of 'exact' means that the tables must all
    have exactly the same number of rows.  If ``join_type`` is 'inner' then
    the intersection of rows will be the output.  A value of 'outer' (default)
    means the output will have the union of all rows, with table values being
    masked where no common values are available.

    Parameters
    ----------
    tables : List of Table objects
        Tables to stack along columns (horizontally) with the current table
    join_type : str
        Join type ('inner' | 'exact' | 'outer'), default is 'outer'
    uniq_col_name : str or None
        String generate a unique output column name in case of a conflict.
        The default is '{col_name}_{table_name}'.
    table_names : list of str or None
        Two-element list of table names used when generating unique output
        column names.  The default is ['1', '2', ..].
    metadata_conflicts : str
        How to proceed with metadata conflicts. This should be one of:
            * ``'silent'``: silently pick the last conflicting meta-data value
            * ``'warn'``: pick the last conflicting meta-data value, but emit a warning (default)
            * ``'error'``: raise an exception.

    Returns
    -------
    stacked_table : `~astropy.table.Table` object
        New table containing the stacked data from the input tables.

    Examples
    --------
    To stack two tables horizontally (along columns) do::

      >>> from astropy.table import Table, hstack
      >>> t1 = Table({'a': [1, 2], 'b': [3, 4]}, names=('a', 'b'))
      >>> t2 = Table({'c': [5, 6], 'd': [7, 8]}, names=('c', 'd'))
      >>> print(t1)
       a   b
      --- ---
        1   3
        2   4
      >>> print(t2)
       c   d
      --- ---
        5   7
        6   8
      >>> print(hstack([t1, t2]))
       a   b   c   d
      --- --- --- ---
        1   3   5   7
        2   4   6   8
    i   i    R   (   R#   R!   R   t   _hstackR   (   R   R1   R2   R3   R   R4   R   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyt   hstackÆ   s    :		u   firstc         C` s€  | d k r t  d ƒ ‚ n  t | t j ƒ r9 | g } n  | d k rQ |  j } n- t t | ƒ ƒ t | ƒ k r~ t  d ƒ ‚ n  |  j r
d } xV | D]M } t	 j
 |  | j ƒ r• | sÏ t  d j | ƒ ƒ ‚ n  | | j | ƒ =q• q• Wt | ƒ d k r
t  d ƒ ‚ q
n  |  j | ƒ } | j j } | d k r>| d	  } n: | d k r[| d
 d
 } n | d	  t	 j | ƒ d
 k } | | S(   uË	  
    Returns the unique rows of a table.

    Parameters
    ----------

    input_table : `~astropy.table.Table` object or a value that
        will initialize a `~astropy.table.Table` object
    keys : str or list of str
        Name(s) of column(s) used to create unique rows.
        Default is to use all columns.
    keep : one of 'first', 'last' or 'none'
        Whether to keep the first or last row for each set of
        duplicates. If 'none', all rows that are duplicate are
        removed, leaving only rows that are already unique in
        the input.
        Default is 'first'.
    silent : boolean
        If `True`, masked value column(s) are silently removed from
        ``keys``. If `False`, an exception is raised when ``keys``
        contains masked value column(s).
        Default is `False`.

    Returns
    -------
    unique_table : `~astropy.table.Table` object
        New table containing only the unique rows of ``input_table``.

    Examples
    --------
    >>> from astropy.table import unique, Table
    >>> import numpy as np
    >>> table = Table(data=[[1,2,3,2,3,3],
    ... [2,3,4,5,4,6],
    ... [3,4,5,6,7,8]],
    ... names=['col1', 'col2', 'col3'],
    ... dtype=[np.int32, np.int32, np.int32])
    >>> table
    <Table length=6>
     col1  col2  col3
    int32 int32 int32
    ----- ----- -----
        1     2     3
        2     3     4
        3     4     5
        2     5     6
        3     4     7
        3     6     8
    >>> unique(table, keys='col1')
    <Table length=3>
     col1  col2  col3
    int32 int32 int32
    ----- ----- -----
        1     2     3
        2     3     4
        3     4     5
    >>> unique(table, keys=['col1'], keep='last')
    <Table length=3>
     col1  col2  col3
    int32 int32 int32
    ----- ----- -----
        1     2     3
        2     5     6
        3     6     8
    >>> unique(table, keys=['col1', 'col2'])
    <Table length=5>
     col1  col2  col3
    int32 int32 int32
    ----- ----- -----
        1     2     3
        2     3     4
        2     5     6
        3     4     5
        3     6     8
    >>> unique(table, keys=['col1', 'col2'], keep='none')
    <Table length=4>
     col1  col2  col3
    int32 int32 int32
    ----- ----- -----
        1     2     3
        2     3     4
        2     5     6
        3     6     8
    >>> unique(table, keys=['col1'], keep='none')
    <Table length=1>
     col1  col2  col3
    int32 int32 int32
    ----- ----- -----
        1     2     3

    u   firstu   lastu   noneu/   'keep' should be one of 'first', 'last', 'none'u   duplicate key namesi    u_   cannot use columns with masked values as keys; remove column '{0}' from keys and rerun unique()uR   no column remained in ``keys``; unique() cannot work with masked value key columnsiÿÿÿÿi   (   u   firstu   lastu   noneN(   R(   R   R   t   string_typest   Nonet   colnamesR!   t   sett   maskedt   npR    t   maskR)   t   indext   group_byt   groupst   indicest   diff(   t   input_tableR0   t   silentt   keept   nkeyst   keyt   grouped_tableRD   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyt   unique  s6    ]	c         ` s´  t  j ‡  f d †  ƒ ‰ g  } | d k r_ g  t t ˆ  ƒ ƒ D] } t j | d ƒ ^ q= } n  xÔ t ˆ  ƒ D]Æ \ } } | | } x­ | j D]¢ ‰ ˆ }	 ˆ | k rÃ ˆ | k r | j	 ˆ ƒ q n] t
 ˆ  ƒ }
 |
 j | ƒ t ‡ f d †  |
 Dƒ ƒ r| j d | d ˆ ƒ }	 n  | j	 |	 ƒ ˆ ˆ |	 | <qŒ Wql Wt | ƒ } g  t j | ƒ D] \ ‰ } | d k rRˆ ^ qR} | r”t d j | ƒ ƒ ‚ n  t ‡ f d †  | Dƒ ƒ ‰ ˆ S(	   u’  
    Find the column names mapping when merging the list of tables
    ``arrays``.  It is assumed that col names in ``common_names`` are to be
    merged into a single column while the rest will be uniquely represented
    in the output.  The args ``uniq_col_name`` and ``table_names`` specify
    how to rename columns in case of conflicts.

    Returns a dict mapping each output column name to the input(s).  This takes the form
    {outname : (col_name_0, col_name_1, ...), ... }.  For key columns all of input names
    will be present, while for the other non-key columns the value will be (col_name_0,
    None, ..) or (None, col_name_1, ..) etc.
    c           ` s   d  g t ˆ  ƒ S(   N(   R;   R!   (    (   t   arrays(    s7   lib/python2.7/site-packages/astropy/table/operations.pyt   <lambda>Ÿ  s    i   c         3` s   |  ] } ˆ  | j  k Vq d  S(   N(   R<   (   R   t   other(   t   name(    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>´  s    t
   table_namet   col_nameuh   Merging column names resulted in duplicates: {0}.  Change uniq_col_name or table_names args to fix this.c         3` s   |  ] } | ˆ  | f Vq d  S(   N(    (   R   RP   (   R4   (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>Ã  s    N(   R   t   defaultdictR;   R   R!   R   t	   text_typet	   enumerateR<   t   appendt   listt   popR    R)   R	   t	   iteritemsR   R   (   RM   t   common_namesR2   R3   t   col_name_listt   iit   idxt   arrayRQ   t   out_namet   otherst   col_name_countt   countt   repeated_names(    (   RM   R4   RP   s7   lib/python2.7/site-packages/astropy/table/operations.pyt   get_col_name_map  s0    5
4	c         C` s4  g  } x't  j | ƒ D]\ } } g  t |  | ƒ D]" \ } } | d k	 r2 | | ^ q2 } g  | D] } | d k	 ra | ^ qa } y t | ƒ }	 Wn2 t k
 rÃ }
 t d j | d |
 j ƒ ƒ ‚ n Xt d „  | Dƒ ƒ } t	 | ƒ d k rt d j | ƒ ƒ ‚ n  | j
 ƒ  } | j t | ƒ |	 | f ƒ q W| S(   u´   
    Find the dtypes descrs resulting from merging the list of arrays' dtypes,
    using the column name mapping ``col_name_map``.

    Return a list of descrs for the output.
    u.   The '{0}' columns have incompatible types: {1}i    c         s` s   |  ] } | j  d  Vq d S(   i   N(   t   shape(   R   t   col(    (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>ã  s    i   u&   Key columns {0!r} have different shapeN(   R   RY   R   R;   t   common_dtypeR   R)   t   _incompat_typesR=   R!   RX   RV   R   (   RM   R4   t
   out_descrsR_   t   in_namest   arrRP   t   in_colst   namest   dtypet   tmet   uniq_shapesRe   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyt
   get_descrsÈ  s    8%	 c         C` sX   y t  j |  ƒ SWn@ t  j k
 rS } t d j | j ƒ ƒ } | j | _ | ‚ n Xd S(   uÉ   
    Use numpy to find the common dtype for a list of columns.

    Only allow columns within the following fundamental numpy data types:
    np.bool_, np.object_, np.number, np.character, np.void
    u#   Columns have incompatible types {0}N(   R   Rg   t   MergeConflictErrorR   R)   Rh   (   t   colst   errRo   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyRg   í  s    	c   (      ` sÀ  | } | d k r* t  d j | ƒ ƒ ‚ n  | d k ry t ‡  f d †  |  j Dƒ ƒ } t | ƒ d k r— t d ƒ ‚ q— n t | t j	 ƒ r— | f } n  xÓ |  d	 f ˆ  d
 f f D]¹ \ }	 }
 xª | D]¢ } | |	 j k ró t d j |
 | ƒ ƒ ‚ n  t
 |	 | d ƒ r7t j |	 | j ƒ r7t d j |
 | ƒ ƒ ‚ n  t |	 | t j ƒ sÃ t  d j | ƒ ƒ ‚ qÃ qÃ Wq° Wt |  ƒ t ˆ  ƒ } } | d k sž| d k r­t  d ƒ ‚ n  t |  ˆ  g | | | ƒ } t |  ˆ  g | ƒ } g  | D] } | d | k rä| ^ qä} t j | | d | ƒ} x2 | D]* } |  | | | | *ˆ  | | | | )q&W| j d | ƒ } | | } t j t g | d | d  k t g f ƒ } t j | ƒ } i d d 6d d 6d d 6d d 6| } t j | | | | ƒ \ } } } } } } |  j sˆ  j rt } n  t | ƒ } t |  ˆ  g ƒ d | ƒ } xZ| D]R\ } } }  | | \ }! }" |! rˆ|" rˆ|  |! ˆ  |" g }# t |# ƒ }$ t
 |$ j d ƒ s¼t d j |$ j ƒ ƒ ‚ n  |$ j j |# | | | ƒ | | <t |$ t  ƒ r!t j! | |  |! j" | ƒ ˆ  |" j" | ƒ ƒ | | (qD| } t j | ƒ rU|  |! j" | ƒ | | | <n  t j | ƒ rDˆ  |" j" | ƒ | | | <qDqDnZ |! r¯|! |  | | f \ } }% }& }' n3 |" rÖ|" ˆ  | | f \ } }% }& }' n t d ƒ ‚ |% | |& | | <| rD| | j# d f d t | | j# ƒ d |' _# |% j rK|' |% | j |& B}' n  y |' | | j (Wq–t  k
 r’t d j | | | j$ j ƒ ƒ ‚ q–XqDqDWt | t% j& ƒ r¼| j' | ƒ n  | S(   uI  
    Perform a join of the left and right Tables on specified keys.

    Parameters
    ----------
    left : Table
        Left side table in the join
    right : Table
        Right side table in the join
    keys : str or list of str
        Name(s) of column(s) used to match rows of left and right tables.
        Default is to use all columns which are common to both tables.
    join_type : str
        Join type ('inner' | 'outer' | 'left' | 'right'), default is 'inner'
    uniq_col_name : str or None
        String generate a unique output column name in case of a conflict.
        The default is '{col_name}_{table_name}'.
    table_names : list of str or None
        Two-element list of table names used when generating unique output
        column names.  The default is ['1', '2'].
    col_name_map : empty dict or None
        If passed as a dict then it will be updated in-place with the
        mapping of output to input column names.

    Returns
    -------
    joined_table : `~astropy.table.Table` object
        New table containing the result of the join operation.
    u   inneru   outeru   leftu   rightu]   The 'join_type' argument should be in 'inner', 'outer', 'left' or 'right' (got '{0}' instead)c         3` s$   |  ] } | ˆ  j  k r | Vq d  S(   N(   R<   (   R   RP   (   R/   (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>(  s    i    u/   No keys in common between left and right tablesu   Leftu   Rightu(   {0} table does not have key column {1!r}u   masku'   {0} key column {1!r} has missing valuesu3   non-ndarray column '{}' not allowed as a key columnu5   input tables for join must both have at least one rowRn   t   orderi   iÿÿÿÿi   i   R>   u   new_likeu-   join unavailable for mixin column type(s): {}u*   Unexpected column names (maybe one is ""?)uM   join requires masking column '{}' but column type {} does not support masking(   u   inneru   outeru   leftu   rightN(   i   ((   R(   R)   R;   t   tupleR<   R!   R   R   R   R:   t   hasattrR?   R    R@   t   ndarrayRd   Rq   t   emptyt   argsortt   concatenatet   Truet   flatnonzeroR   t
   join_innerR>   t   boolR,   t   infot   NotImplementedErrorR*   t   new_likeR$   R   t   wheret   takeRe   R%   R   t   MappingR   ((   R.   R/   R0   R1   R2   R3   R4   R   t   _col_name_mapRk   t	   arr_labelRP   t   len_leftt	   len_rightRi   t   descrt   out_keys_dtypet   out_keysRJ   t   idx_sortt   diffst   idxst   int_join_typeR>   t   n_outt   left_outt	   left_maskt	   right_outt
   right_maskR   R_   Rn   Re   t	   left_namet
   right_nameRs   t   col_clsR^   t	   array_outt
   array_mask(    (   R/   s7   lib/python2.7/site-packages/astropy/table/operations.pyR-   ý  sž    "	%	)		)
,&*			!!0	$c         C` sg  | } | d k r! t  d ƒ ‚ n  t |  ƒ d k r; |  d St t j g  |  D] } | j ^ qK Œ  ƒ } t |  | ƒ } | d k rÉ x< t j | ƒ D]+ } t	 d „  | Dƒ ƒ r‘ t
 d ƒ ‚ q‘ q‘ Wd } n  | d k rt d	 „  t j | ƒ Dƒ ƒ } t | ƒ d k rt
 d
 ƒ ‚ qn  t	 d „  |  Dƒ ƒ } x7 t j | ƒ D]& } t	 d „  | Dƒ ƒ r>t } Pq>q>Wg  |  D] } t | ƒ ^ qo} t | ƒ }	 t |  ƒ d | ƒ }
 x–t j | ƒ D]…\ } } g  t |  | ƒ D]" \ } } | d k	 rÔ| | ^ qÔ} t | ƒ } t | j d ƒ s5t d j | j ƒ ƒ ‚ n  y# | j j | |	 | | ƒ |
 | <Wn1 t j k
 r‹} t
 d j | | j ƒ ƒ ‚ n Xd } x¨ t | |  ƒ D]— \ } } | t | ƒ } | | j k rå| | |
 | | | +nN y t |
 | j | | +Wn3 t  k
 r2t d j | |
 | j j ƒ ƒ ‚ n X| } q¢Wq¸Wt | t j ƒ rc| j  | ƒ n  |
 S(   uœ  
    Stack Tables vertically (by rows)

    A ``join_type`` of 'exact' (default) means that the arrays must all
    have exactly the same column names (though the order can vary).  If
    ``join_type`` is 'inner' then the intersection of common columns will
    be the output.  A value of 'outer' means the output will have the union of
    all columns, with array values being masked where no common values are
    available.

    Parameters
    ----------
    arrays : list of Tables
        Tables to stack by rows (vertically)
    join_type : str
        Join type ('inner' | 'exact' | 'outer'), default is 'outer'
    col_name_map : empty dict or None
        If passed as a dict then it will be updated in-place with the
        mapping of output to input column names.

    Returns
    -------
    stacked_table : `~astropy.table.Table` object
        New table containing the stacked data from the input tables.
    u   inneru   exactu   outeru:   `join_type` arg must be one of 'inner', 'exact' or 'outer'i   i    c         s` s   |  ] } | d  k Vq d  S(   N(   R;   (   R   R   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>É  s    ue   Inconsistent columns in input arrays (use 'inner' or 'outer' join_type to allow non-matching columns)c         s` s7   |  ]- \ } } t  d  „  | Dƒ ƒ r | | f Vq d S(   c         s` s   |  ] } | d  k	 Vq d  S(   N(   R;   (   R   R   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>Ò  s    N(   t   all(   R   RP   Rj   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>Ñ  s    	u&   Input arrays have no columns in commonc         s` s!   |  ] } t  | d  t ƒ Vq d S(   u   maskedN(   t   getattrt   False(   R   Rk   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>Ù  s    c         s` s   |  ] } | d  k Vq d  S(   N(   R;   (   R   R   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>Û  s    R>   u   new_likeu/   vstack unavailable for mixin column type(s): {}u.   The '{0}' columns have incompatible types: {1}uO   vstack requires masking column '{}' but column type {} does not support masking(   u   inneru   exactu   outerN(!   R(   R!   R=   t	   itertoolst   chainR<   Rd   R   t
   itervaluesR    R   R   RY   R|   t   sumR,   R   R;   Rw   R€   R   R)   R*   R‚   R   Rr   Rh   R@   R%   R   R   R…   R   (   RM   R1   R4   R   R†   Rk   Rm   R>   t   lenst   n_rowsR   R_   Rj   RP   Rs   R˜   Rt   t   idx0R^   t   idx1(    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyR6   œ  sd    +	8	#	c         C` sã  | } | d k r! t  d ƒ ‚ n  | d k rb g  t t |  ƒ ƒ D] } d j | d ƒ ^ q@ } n  t |  ƒ t | ƒ k r‰ t  d ƒ ‚ n  t |  ƒ d k r£ |  d St |  g  | | ƒ } g  |  D] } t | ƒ ^ q¿ } | d k rt t | ƒ ƒ d k r
t d	 ƒ ‚ n  d } n  | d k rt | ƒ }	 t t | ƒ ƒ d k rcg  |  D] } | |	  ^ qJ}  n  g  |  D] } |	 ^ qj} n  t	 d
 „  |  Dƒ ƒ pªt t | ƒ ƒ d k }
 t
 | ƒ } t |  ƒ d |
 ƒ } xì t j | ƒ D]Û \ } } xÌ t | |  | ƒ D]¸ \ } } } | d k rqýn  | | k r£t j | ƒ } d | | )| | | | | <y t | | j | )Wqµt  k
 rŸt d j | | | j j ƒ ƒ ‚ qµXqý| | |  | | <qýWqÞWt | t j ƒ rß| j | ƒ n  | S(   u"  
    Stack tables horizontally (by columns)

    A ``join_type`` of 'exact' (default) means that the arrays must all
    have exactly the same number of rows.  If ``join_type`` is 'inner' then
    the intersection of rows will be the output.  A value of 'outer' means
    the output will have the union of all rows, with array values being
    masked where no common values are available.

    Parameters
    ----------
    arrays : List of tables
        Tables to stack by columns (horizontally)
    join_type : str
        Join type ('inner' | 'exact' | 'outer'), default is 'outer'
    uniq_col_name : str or None
        String generate a unique output column name in case of a conflict.
        The default is '{col_name}_{table_name}'.
    table_names : list of str or None
        Two-element list of table names used when generating unique output
        column names.  The default is ['1', '2', ..].

    Returns
    -------
    stacked_table : `~astropy.table.Table` object
        New table containing the stacked data from the input tables.
    u   inneru   exactu   outeru8   join_type arg must be either 'inner', 'exact' or 'outer'u   {0}i   u1   Number of arrays must match number of table_namesi    ui   Inconsistent number of rows in input arrays (use 'inner' or 'outer' join_type to allow non-matching rows)c         s` s!   |  ] } t  | d  t ƒ Vq d S(   u   maskedN(   Rœ   R   (   R   Rk   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pys	   <genexpr>L  s    R>   uO   hstack requires masking column '{}' but column type {} does not support masking(   u   inneru   exactu   outerN(   R(   R;   R   R!   R)   Rd   R=   R   t   minR    t   maxR,   R   RY   R   R?   t   arangeR|   R@   R   R%   R*   R   R   R…   R   (   RM   R1   R2   R3   R4   R†   R\   Rk   t   arr_lenst   min_arr_lenR>   R£   R   R_   Rj   RP   R^   t   arr_lenRD   (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyR8   	  sR    5	 ."
 (.   t   __doc__t
   __future__R    R   R   R   t   externR   t   extern.six.movesR   R   t   copyR   t   warningsR   Rž   R   R	   t   numpyR?   R
   t   utilsR   t   columnR   t    R   t   np_utilsR   R   t   __all__R   R#   R,   R;   R5   R7   R9   R   RL   Rd   Rq   Rg   R-   R6   R8   (    (    (    s7   lib/python2.7/site-packages/astropy/table/operations.pyt   <module>   sJ   "		3BEƒ7	%		œm