
[c           @` s  d  d l  m Z m Z m Z m Z d d l m Z d d l m Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l m Z d  d l Z d  d l m Z y d  d l m Z Wn e k
 r e Z n Xd d	 l m Z m Z d d
 l m Z d d l 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$ d d l% m& Z& d d l' m( Z( m) Z) e$ j*   Z+ d e, f d     YZ- e	 j. d e-  d   Z/ e0 e j1 e j2 e j3 e j4 e j5 e j6 e j7 e j8 e j9 e j: e j; g  Z< e= d  Z> d e j? f d     YZ@ d e f d     YZA d e( e j? f d     YZB d eB f d      YZC d! eC e) e jD f d"     YZE d S(#   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsi   (   t   six(   t   zipN(   t   deepcopy(   t   ma(   t   MaskedArrayFutureWarning(   t   Unitt   Quantity(   t   color_print(   t   MetaData(   t   BaseColumnInfot   dtype_info_name(   t   dtype_bytes_or_chars(   t   rangei   (   t   groups(   t   pprint(   t   fix_column_name(   t   _ColumnGetitemShimt   _MaskedColumnGetitemShimt   StringTruncateWarningc           B` s   e  Z d  Z RS(   u%  
    Warning class for when a string column is assigned a value
    that gets truncated because the base (numpy) string length
    is too short.

    This does not inherit from AstropyWarning because we want to use
    stacklevel=2 to show the user where the issue occurred in their code.
    (   t   __name__t
   __module__t   __doc__(    (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR   +   s   u   alwaysc         C` s?   d d l  m } g  t |   D] } t | j  j |  ^ q S(   Ni   (   t   conf(   t    R   R   t   strt   auto_colnamet   format(   t   n_colsR   t   i(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   _auto_names;   s    c         C` s   t  |  t  r |  j   S|  j j } |  j j } d |  j _ g  |  j _ z t |  d  rg |  j   n	 t |   } |  j | _ | r t | p g   n g  | j _ x$ | j j D] } | j	 |  |  q WWd | |  j _ | |  j _ X| S(   u  
    Mixin-safe version of Column.copy() (with copy_data=True).

    Parameters
    ----------
    col : Column or mixin column
        Input column
    copy_indices : bool
        Copy the column ``indices`` attribute

    Returns
    -------
    col : Copy of input column
    u   copyN(
   t
   isinstancet
   BaseColumnt   copyt   infot   parent_tablet   indicest   Nonet   hasattrR   t   replace_col(   t   colt   copy_indicesR&   R'   t   newcolt   index(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   col_copyI   s    
'$t
   FalseArrayc           B` s5   e  Z d  Z d   Z d   Z e j r3 d   Z n  RS(   u  
    Boolean mask array that is always False.

    This is used to create a stub ``mask`` property which is a boolean array of
    ``False`` used by default for mixin columns and corresponding to the mixin
    column data shape.  The ``mask`` looks like a normal numpy array but an
    exception will be raised if ``True`` is assigned to any element.  The
    consequences of the limitation are most obvious in the high-level table
    operations.

    Parameters
    ----------
    shape : tuple
        Data shape
    c         C` s%   t  j | d t  j j |   } | S(   Nt   dtype(   t   npt   zerost   boolt   view(   t   clst   shapet   obj(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   __new__   s    !c         C` s@   t  j |  } t  j |  r< t d j |  j j    n  d  S(   Nu+   Cannot set any element of {0} class to True(   R2   t   asarrayt   anyt
   ValueErrorR   t	   __class__R   (   t   selft   itemt   val(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   __setitem__   s    	c         C` s   |  j  t | |  |  d  S(   N(   RA   t   slice(   R>   t   startt   stopR@   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   __setslice__   s    (   R   R   R   R9   RA   R   t   PY2RE   (    (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR0   s   s
   			t
   ColumnInfoc           B` s,   e  Z d  Z e j Z e Z d d d  Z	 RS(   u   
    Container for meta information like name, description, format.

    This is required when the object is used as a mixin column within a table,
    but can be used as a general way to store meta information.
    u   warnc         C` s+   |  j  | | | d  } |  j d | |  S(   u  
        Return a new Column instance which is consistent with the
        input ``cols`` and has ``length`` rows.

        This is intended for creating an empty column object whose elements can
        be set in-place for table operations like join or vstack.

        Parameters
        ----------
        cols : list
            List of input columns
        length : int
            Length of the output column object
        metadata_conflicts : str ('warn'|'error'|'silent')
            How to handle metadata conflicts
        name : str
            Output column name

        Returns
        -------
        col : Column (or subclass)
            New instance of this class consistent with ``cols``

        u   metau   unitu   formatu   descriptiont   length(   u   metau   unitu   formatu   description(   t   merge_cols_attributest   _parent_cls(   R>   t   colsRH   t   metadata_conflictst   namet   attrs(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   new_like   s    	N(
   R   R   R   R   t
   attr_namest   attrs_from_parentt   Truet   _supports_indexingR(   RO   (    (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRG      s   	R#   c           B` s  e  Z e   Z d  d  d  d! d  d  d  d  d  e e d  Z e d    Z	 e d    Z
 e
 j d    Z
 e   Z d d  e d  Z d   Z d   Z d	   Z d  d
  Z e d    Z e j d    Z e d    Z d   Z d   Z e d    Z d  e e e e d  Z d  e e e d  Z d  e e d  Z e d    Z e j d    Z e j d    Z g  d  Z e d    Z d   Z d   Z  d   Z! e d    Z" g  d  Z# d   Z$ e% d    Z& RS("   i    c         C` s  | d  k r< t j |  j | f } t j | d | } nt | t  r t | d  r t j | j	 d | d |
 } | d  k r | j
 } n  | d  k r | p | j } n  | d  k r | j } n  |	 d  k r t | j  }	 n  | d  k r| j } qnt | t  r| d  k rAt j | d | d |
 } | j } n$ t j | j |  d | d |
 } | d  k r| j j
 } n  | d  k r| j j } n  |	 d  k rt | j j  }	 qnO t j rt j |  j d k r|  j |  } n  t j | d | d |
 } | j |   } t |  | _ | | _ | | _ | | _
 |	 | _ d  | _ | rwt t | d g    n g  | _ x! | j D] } | j | |  qW| S(   NR1   u   _nameR$   u   Su   indices(   R(   R2   R1   R   R3   R"   R#   R)   t   arrayt   datat   descriptiont   unitR   R   t   metaRM   R
   t   toR%   R   RF   t   chart   _encode_strR5   R   t   _namet   _parent_tablet   getattrR'   R*   (   R6   RU   RM   R1   R7   RH   RV   RW   R   RX   R$   R,   t	   self_dataR>   R.   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR9      sP    $"					'c         C` s   |  j  t j  S(   N(   R5   R2   t   ndarray(   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRU      s    c         C` s!   |  j  d  k r d  S|  j    Sd  S(   N(   R]   R(   (   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR&      s    c         C` s.   | d  k r d  |  _ n t j |  |  _ d  S(   N(   R(   R]   t   weakreft   ref(   R>   t   table(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR&     s    u   Cc         C` s~   | d k r0 |  j } | r0 | j |  } q0 n  | j |  j  } | j |   t |  t  rm | j | _ n  |  j	 |  | S(   um  
        Return a copy of the current instance.

        If ``data`` is supplied then a view (reference) of ``data`` is used,
        and ``copy_data`` is ignored.

        Parameters
        ----------
        order : {'C', 'F', 'A', 'K'}, optional
            Controls the memory layout of the copy. 'C' means C-order,
            'F' means F-order, 'A' means 'F' if ``a`` is Fortran contiguous,
            'C' otherwise. 'K' means match the layout of ``a`` as closely
            as possible. (Note that this function and :func:numpy.copy are very
            similar, but have different default values for their order=
            arguments.)  Default is 'C'.
        data : array, optional
            If supplied then use a view of ``data`` instead of the instance
            data.  This allows copying the instance attributes and meta.
        copy_data : bool, optional
            Make a copy of the internal numpy array instead of using a
            reference.  Default is True.

        Returns
        -------
        col : Column or MaskedColumn
            Copy of the current column (same type as original)
        N(
   R(   RU   R$   R5   R=   t   __array_finalize__R"   t   MaskedColumnt   _maskt   _copy_groups(   R>   t   orderRU   t	   copy_datat   out(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR$   
  s    	c         C` s   d
 } d   t  | | d  D } | d  } t |  t j  rH t j n t j } | j |  |  x* | j   D] \ } } t |  | |  qn Wd	 |  _
 d	 S(   u   
        Restore the internal state of the Column/MaskedColumn for pickling
        purposes.  This requires that the last element of ``state`` is a
        5-tuple that has Column-specific state values.
        u   _nameu   unitu   formatu   descriptionu   metau   indicesc         S` s   i  |  ] \ } } | |  q S(    (    (   t   .0RM   R@   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pys
   <dictcomp>>  s   	 iN(   u   _nameu   unitu   formatu   descriptionu   metau   indices(   R   R"   R   t   MaskedArrayR2   R`   t   __setstate__t   itemst   setattrR(   R]   (   R>   t   statet   namesRN   t   super_classRM   R@   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRm   6  s    
$c         C` s   t  |  t j  r t j n t j } | j |   \ } } } |  j |  j |  j |  j	 |  j
 |  j f } | | f } | | | f S(   u   
        Return a 3-tuple for pickling a Column.  Use the super-class
        functionality but then add in a 5-tuple of Column-specific values
        that get used in __setstate__.
        (   R"   R   Rl   R2   R`   t
   __reduce__RM   RW   R   RV   RX   R'   (   R>   Rr   t   reconstruct_funct   reconstruct_func_argsRp   t   column_state(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRs   M  s    $c         C` sy   | d  k r d  St j t t |   j  rD t t |   j |  n  d  |  _ t |  d  sh g  |  _ n  |  j	 |  d  S(   Nu   indices(
   R(   R   t   callablet   superR#   Rd   R&   R)   R'   t   _copy_attrs(   R>   R8   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRd   ]  s    	c         C` sk   t  t |   j | |  } |  j | j k sX t | t  rc | d k	 rc | d t k rc | j d S| Sd S(   u  
        __array_wrap__ is called at the end of every ufunc.

        Normally, we want a Column object back and do not have to do anything
        special. But there are two exceptions:

        1) If the output shape is different (e.g. for reduction ufuncs
           like sum() or mean()), a Column still linking to a parent_table
           makes little sense, so we return the output viewed as the
           column content (ndarray or MaskedArray).
           For this case, we use "[()]" to select everything, and to ensure we
           convert a zero rank array to a scalar. (For some reason np.sum()
           returns a zero rank scalar array while np.mean() returns a scalar;
           So the [()] is needed for this case.

        2) When the output is created by any function that returns a boolean
           we also want to consistently return an array rather than a column
           (see #1446 and #1685)
        i    N(    (   Rx   R#   t   __array_wrap__R7   R"   R(   t   _comparison_functionsRU   (   R>   t   out_arrt   context(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRz   m  s    c         C` s   |  j  S(   u*   
        The name of this column.
        (   R\   (   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRM     s    c         C` sJ   t  |  } |  j d  k	 r= |  j } | j j |  j |  n  | |  _ d  S(   N(   R   R&   R(   t   columnst   _rename_columnRM   R\   (   R>   R@   Rc   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRM     s
    	c         C` s   |  j  |  j j |  j d f S(   u   Array-interface compliant full description of the column.

        This returns a 3-tuple (name, type, shape) that can always be
        used in a structured array dtype definition.
        i   (   RM   R1   R   R7   (   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   descr  s    c         c` sG   |  j  j } x4 | |  d d t d t d t d i  D] } | Vq4 Wd S(   u   
        Return an iterator that yields the string-formatted values of this
        column.

        Returns
        -------
        str_vals : iterator
            Column values formatted as strings
        it	   show_namet	   show_unitt
   show_dtypet   outsN(   t
   _formattert   _pformat_col_itert   False(   R>   R   t   str_val(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   iter_str_vals  s    c         ` sG   t    t  s t d   n  d	 } t    f d   | D  } | S(
   u{  Compare the column attributes of ``col`` to this object.

        The comparison attributes are: ``name``, ``unit``, ``dtype``,
        ``format``, ``description``, and ``meta``.

        Parameters
        ----------
        col : Column
            Comparison column

        Returns
        -------
        equal : boolean
            True if all attributes are equal
        u8   Comparison `col` must be a Column or MaskedColumn objectu   nameu   unitu   dtypeu   formatu   descriptionu   metac         3` s-   |  ]# } t   |  t    |  k Vq d  S(   N(   R^   (   Rk   t   x(   R+   R>   (    s3   lib/python2.7/site-packages/astropy/table/column.pys	   <genexpr>  s    (   u   nameu   unitu   dtypeu   formatu   descriptionu   meta(   R"   R#   R<   t   all(   R>   R+   RN   t   equal(    (   R+   R>   s3   lib/python2.7/site-packages/astropy/table/column.pyt   attrs_equal  s
    c         C` s   |  j  d  k r t S|  j  j S(   N(   R&   R(   t	   FORMATTERt	   formatter(   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR     s    c   	      C` s=   |  j  j } | |  | d | d | d | d | \ } } | S(   u  Return a list of formatted string representation of column values.

        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 will be
        determined using the ``astropy.conf.max_lines`` configuration
        item. If a negative value of ``max_lines`` is supplied then
        there is no line limit applied.

        Parameters
        ----------
        max_lines : int
            Maximum lines of output (header + data rows)

        show_name : bool
            Include column name. Default is True.

        show_unit : bool
            Include a header row for unit. Default is False.

        show_dtype : bool
            Include column dtype. Default is False.

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

        Returns
        -------
        lines : list
            List of lines with header and formatted column values

        R   R   R   t   html(   R   t   _pformat_col(	   R>   t	   max_linesR   R   R   R   R   t   linesR   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   pformat  s
    "c      	   C` s   |  j  j } | |  | d | d | d | \ } } | d } x@ t |  D]2 \ }	 }
 |	 | k  rr t |
 d  qJ t |
  qJ Wd S(   u   Print a formatted string representation of column values.

        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 will be
        determined using the ``astropy.conf.max_lines`` configuration
        item. If a negative value of ``max_lines`` is supplied then
        there is no line limit applied.

        Parameters
        ----------
        max_lines : int
            Maximum number of values in output

        show_name : bool
            Include column name. Default is True.

        show_unit : bool
            Include a header row for unit. Default is False.

        show_dtype : bool
            Include column dtype. Default is True.
        R   R   R   u   n_headeru   redN(   R   R   t	   enumerateR   t   print(   R>   R   R   R   R   R   R   R   t   n_headerR    t   line(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR     s    
c         C` s,   |  j  j } | |  d | d | d | d S(   u  Interactively browse column 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.

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

        show_unit : bool
            Include a header row for unit. Default is False.

        R   R   R   N(   R   t   _more_tabcol(   R>   R   R   R   R   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   more  s    c         C` s   |  j  S(   u  
        The unit associated with this column.  May be a string or a
        `astropy.units.UnitBase` instance.

        Setting the ``unit`` property does not change the values of the
        data.  To perform a unit conversion, use ``convert_unit_to``.
        (   t   _unit(   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRW   ;  s    	c         C` s1   | d  k r d  |  _ n t | d d |  _ d  S(   Nt   parse_strictu   silent(   R(   R   R	   (   R>   RW   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRW   F  s    c         C` s   d  |  _ d  S(   N(   R(   R   (   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRW   M  s    c         C` sM   |  j  d k r t d   n  |  j  j | |  j d | |  j (| |  _  d S(   u  
        Converts the values of the column in-place from the current
        unit to the given unit.

        To change the unit associated with this column without
        actually changing the data values, simply set the ``unit``
        property.

        Parameters
        ----------
        new_unit : str or `astropy.units.UnitBase` instance
            The unit to convert to.

        equivalencies : list of equivalence pairs, optional
           A list of equivalence pairs to try if the unit are not
           directly convertible.  See :ref:`unit_equivalencies`.

        Raises
        ------
        astropy.units.UnitsError
            If units are inconsistent
        u   No unit set on columnt   equivalenciesN(   RW   R(   R<   RY   RU   (   R>   t   new_unitR   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   convert_unit_toQ  s
    	c         C` s+   t  |  d  s$ t j |   |  _ n  |  j S(   Nu   _groups(   R)   R   t   ColumnGroupst   _groups(   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR   n  s    c         C` s   t  j |  |  S(   u  
        Group this column by the specified ``keys``

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

        The ``keys`` input to ``group_by`` must be a numpy array with the
        same length as this column.

        Parameters
        ----------
        keys : numpy array
            Key grouping object

        Returns
        -------
        out : Column
            New column with groups attribute set accordingly
        (   R   t   column_group_by(   R>   t   keys(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   group_byt  s    c         C` sv   |  j  rB t |  j  d  rr t j | d |  j  j j | _ qr n0 t |  d  rr t j | d |  j j | _ n  d S(   uA   
        Copy current groups into a copy of self ``out``
        u   _groupsR'   N(   R&   R)   R   R   R   t   _indices(   R>   Rj   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRg     s
    	'c         C` s   t  j |   j   S(   N(   R2   R:   t   __repr__(   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR     s    c         C` s   t  |  d t d |  j d d S(   u   
        A view of this table column as a `~astropy.units.Quantity` object with
        units given by the Column's `unit` parameter.
        R$   R1   Rh   u   A(   R
   R   R1   (   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   quantity  s    	c         K` s   |  j  j | |  S(   u  
        Converts this table column to a `~astropy.units.Quantity` object with
        the requested units.

        Parameters
        ----------
        unit : `~astropy.units.Unit` or str
            The unit to convert to (i.e., a valid argument to the
            :meth:`astropy.units.Quantity.to` method).
        equivalencies : list of equivalence pairs, optional
            Equivalencies to use for this conversion.  See
            :meth:`astropy.units.Quantity.to` for more details.

        Returns
        -------
        quantity : `~astropy.units.Quantity`
            A quantity object with the contents of this column in the units
            ``unit``.
        (   R   RY   (   R>   RW   R   t   kwargs(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRY     s    c         C` sR   x0 d D]( } t  | | d  } t |  | |  q Wt t  | d i    |  _ d S(   uA   
        Copy key column attributes from ``obj`` to self
        u   nameu   unitu   formatu   descriptionu   metaN(   u   nameu   unitu   formatu   description(   R^   R(   Ro   R   RX   (   R>   R8   t   attrR@   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRy     s    c         C` s   t  |  t  r! |  j d  }  n t  |  t  s |  t j j k rE n{ t j |   } | j j	 d k r t j	 j | d d } t  |  t j j
  r t j j | d |  j d t } q n  | }  |  S(   um   
        Encode anything that is unicode-ish as utf-8.  This method is only
        called for Py3+.
        u   utf-8u   Ut   encodingt   maskR$   (   R"   R   t   encodet   bytesR2   R   t   maskedR:   R1   RZ   Rl   RT   R   R   (   t   valuet   arr(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR[     s    !'N(    ('   R   R   R   RX   R(   R   RR   R9   t   propertyRU   R&   t   setterRG   R%   R$   Rm   Rs   Rd   Rz   RM   R   R   R   R   R   R   R   RW   t   deleterR   R   R   Rg   R   R   RY   Ry   t   staticmethodR[   (    (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR#      sH   		4	,			
			'#					t   Columnc           B` sj  e  Z d  Z d d d d d d d d d e e d  Z d   Z e d  Z d   Z	 d   Z
 d   Z e j sx e Z n  d   Z e j r e Z n  d	   Z d
   Z e j r d   Z n  d   Z e d  Z e d  Z e d  Z e d  Z e d  Z e d  Z d d  Z e j Z e j Z e j Z e j Z e j  Z  e j! Z! e j" Z" e j# Z# e j$ Z$ RS(   u
	  Define a data column for use in a Table object.

    Parameters
    ----------
    data : list, ndarray or None
        Column data values
    name : str
        Column name and key for reference within Table
    dtype : numpy.dtype compatible value
        Data type for column
    shape : tuple or ()
        Dimensions of a single row element in the column data
    length : int or 0
        Number of row elements in column data
    description : str or None
        Full description of column
    unit : str or None
        Physical unit
    format : str or None or function or callable
        Format string for outputting column values.  This can be an
        "old-style" (``format % value``) or "new-style" (`str.format`)
        format specification string or a function or any callable object that
        accepts a single value and returns a string.
    meta : dict-like or None
        Meta-data associated with the column

    Examples
    --------
    A Column can be created in two different ways:

    - Provide a ``data`` value but not ``shape`` or ``length`` (which are
      inferred from the data).

      Examples::

        col = Column(data=[1, 2], name='name')  # shape=(2,)
        col = Column(data=[[1, 2], [3, 4]], name='name')  # shape=(2, 2)
        col = Column(data=[1, 2], name='name', dtype=float)
        col = Column(data=np.array([1, 2]), name='name')
        col = Column(data=['hello', 'world'], name='name')

      The ``dtype`` argument can be any value which is an acceptable
      fixed-size data-type initializer for the numpy.dtype() method.  See
      `<https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html>`_.
      Examples include:

      - Python non-string type (float, int, bool)
      - Numpy non-string type (e.g. np.float32, np.int64, np.bool)
      - Numpy.dtype array-protocol type strings (e.g. 'i4', 'f8', 'S15')

      If no ``dtype`` value is provide then the type is inferred using
      ``np.array(data)``.

    - Provide ``length`` and optionally ``shape``, but not ``data``

      Examples::

        col = Column(name='name', length=5)
        col = Column(name='name', dtype=int, length=10, shape=(3,4))

      The default ``dtype`` is ``np.float64``.  The ``shape`` argument is the
      array shape of a single cell in the column.
    i    c         C` s   t  | t  r0 t j | j  r0 t d   n  t t |   j |  d | d | d | d | d | d | d | d	 | d
 |	 d |
 d | } | S(   Nu;   Cannot convert a MaskedColumn with masked value to a ColumnRU   RM   R1   R7   RH   RV   RW   R   RX   R$   R,   (	   R"   Re   R2   R;   R   t	   TypeErrorRx   R   R9   (   R6   RU   RM   R1   R7   RH   RV   RW   R   RX   R$   R,   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR9     s    !'c         C` s   t  |  t  r+ | d k r+ t d   n  t t |   j | |  | d k r t |  j j t	 j
  r y |  j j |   } Wn t k
 r q X| |  k	 r |  j j |  j |  q n  d  S(   Nu   masku5   cannot set mask value to a column in non-masked Tableu   unit(   R"   Re   t   AttributeErrorRx   R   t   __setattr__t
   issubclassR1   t   typeR2   t   numberR&   t   _convert_col_for_tablet   replace_columnRM   (   R>   R?   R   t	   converted(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR   *  s    $c      
   C` s  |  j  d k r t |  j    S|  j j g } |  j d  k rC d  n t |  j  } |  j  d k rg d  n
 |  j d } x d |  j	 f d t
 |  j  f d | f d | f d |  j f d |  j f d	 t |   f f D]4 \ } } | d  k	 r | j d
 j | |   q q Wd d j |  d } | rFd d l m } | |  } n  |  j j |  d t d t d t d | \ }	 }
 | d j |	  } t j rt | t j  r| j d  } n  | S(   Ni    i   u   nameu   dtypeu   shapeu   unitu   formatu   descriptionu   lengthu	   {0}={1!r}u   <u    u   >
i   (   t
   xml_escapeR   R   t   show_lengthR   u   
u   utf-8(   t   ndimt   reprR?   R=   R   RW   R(   R   R7   RM   R   R1   R   RV   t   lent   appendt   joint   utils.xml.writerR   R   R   R   R   RF   R"   t	   text_typeR   (   R>   R   t
   descr_valsRW   R7   R   R@   R   R   t
   data_linesR   Rj   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   _base_repr_8  s0    $"		 	'c         C` s   |  j  d t  S(   NR   (   R   RR   (   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   _repr_html_Z  s    c         C` s   |  j  d t  S(   NR   (   R   R   (   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR   ]  s    c         C` sD   |  j  d k r t |  j    S|  j j |   \ } } d j |  S(   Ni    u   
(   R   R   R?   R   R   R   (   R>   R   R   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   __unicode__`  s    c         C` s   t  j |   j d  S(   Nu   utf-8(   R   R   R   (   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt	   __bytes__j  s    c         C` s   t  j | d |  j j } | j d k r. d St  j j |  j   } t |  j  } | | k r t	 j
 d j |  t d d n  d S(   u{   
        Emit a warning if any elements of ``value`` will be truncated when
        ``value`` is assigned to self.
        R1   i    NuL   truncated right side string(s) longer than {} character(s) during assignmentt
   stackleveli   (   R2   t
   asanyarrayR1   R   t   sizeRZ   t   str_lent   maxR   t   warningst   warnR   R   (   R>   R   t   value_str_lent   self_str_len(    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   _check_string_truncateo  s    c         C` s   t  j r. |  j j d k r. |  j |  } n  t |  j j t j  rV |  j	 |  n  |  j
 j | | t |    | |  j | <d  S(   Nu   S(   R   RF   R1   RZ   R[   R   R   R2   t	   characterR   R%   t   adjust_indicesR   RU   (   R>   R.   R   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRA     s    c         C` s   |  j  t | |  |  d  S(   N(   RA   RB   (   R>   RC   RD   R   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRE     s    c         ` sJ   i d d 6d d 6d d 6d d 6d d 6d d 6      f d   } | S(   u   
        Make comparison methods which encode the ``other`` object to utf-8
        in the case of a bytestring dtype for Py3+.
        u   __eq__u   __ne__u   __lt__u   __gt__u   __le__u   __ge__c         ` s     } t  |  t  r^ |  j j d k r^ t  | t  r^ | j j d k r^ | |  }  }  } n  t j r |  j j d k r |  j |  } n  t |  j	 |  |  S(   Nu   Uu   S(
   R"   Re   R1   t   kindR   RF   RZ   R[   R^   RU   (   R>   t   othert   op(   t   opert   swapped_oper(    s3   lib/python2.7/site-packages/astropy/table/column.pyt   _compare  s    !!	(    (   R   R   (    (   R   R   s3   lib/python2.7/site-packages/astropy/table/column.pyt   _make_compare  s    
u   __eq__u   __ne__u   __gt__u   __lt__u   __ge__u   __le__c         C` s   |  j  j d k r: t j |  | d d | } | | | <n3 t j | d |  j  } t j |  | | d | } | j |  j  } | j |   | S(   u  
        Insert values before the given indices in the column and return
        a new `~astropy.table.Column` object.

        Parameters
        ----------
        obj : int, slice or sequence of ints
            Object that defines the index or indices before which ``values`` is
            inserted.
        values : array_like
            Value(s) to insert.  If the type of ``values`` is different
            from that of quantity, ``values`` is converted to the matching type.
            ``values`` should be shaped so that it can be broadcast appropriately
        axis : int, optional
            Axis along which to insert ``values``.  If ``axis`` is None then
            the column array is flattened before insertion.  Default is 0,
            which will insert a row.

        Returns
        -------
        out : `~astropy.table.Column`
            A copy of column with ``values`` and ``mask`` inserted.  Note that the
            insertion does not occur in-place: a new column is returned.
        u   Ot   axisR1   N(	   R1   R   R2   t   insertR(   R:   R5   R=   Rd   (   R>   R8   t   valuesR   RU   Rj   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR     s    N(    (%   R   R   R   R(   R   RR   R9   R   R   R   R   R   R   RF   t   __str__R   R   RA   RE   R   t   __eq__t   __ne__t   __gt__t   __lt__t   __ge__t   __le__R   R#   RM   RW   R$   R   R   R   R   R   RY   (    (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR     sH   ?		"												#)								Re   c           B` s   e  Z d  Z d
 d
 d
 d
 d
 d d d
 d
 d
 d
 e e d  Z e d    Z e j	 d    Z e d    Z
 d
 d  Z d
 d d  Z d   Z d	   Z e j Z e j Z e j Z e j Z e j Z e j Z RS(   u
  Define a masked data column for use in a Table object.

    Parameters
    ----------
    data : list, ndarray or None
        Column data values
    name : str
        Column name and key for reference within Table
    mask : list, ndarray or None
        Boolean mask for which True indicates missing or invalid data
    fill_value : float, int, str or None
        Value used when filling masked column elements
    dtype : numpy.dtype compatible value
        Data type for column
    shape : tuple or ()
        Dimensions of a single row element in the column data
    length : int or 0
        Number of row elements in column data
    description : str or None
        Full description of column
    unit : str or None
        Physical unit
    format : str or None or function or callable
        Format string for outputting column values.  This can be an
        "old-style" (``format % value``) or "new-style" (`str.format`)
        format specification string or a function or any callable object that
        accepts a single value and returns a string.
    meta : dict-like or None
        Meta-data associated with the column

    Examples
    --------
    A MaskedColumn is similar to a Column except that it includes ``mask`` and
    ``fill_value`` attributes.  It can be created in two different ways:

    - Provide a ``data`` value but not ``shape`` or ``length`` (which are
      inferred from the data).

      Examples::

        col = MaskedColumn(data=[1, 2], name='name')
        col = MaskedColumn(data=[1, 2], name='name', mask=[True, False])
        col = MaskedColumn(data=[1, 2], name='name', dtype=float, fill_value=99)

      The ``mask`` argument will be cast as a boolean array and specifies
      which elements are considered to be missing or invalid.

      The ``dtype`` argument can be any value which is an acceptable
      fixed-size data-type initializer for the numpy.dtype() method.  See
      `<https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html>`_.
      Examples include:

      - Python non-string type (float, int, bool)
      - Numpy non-string type (e.g. np.float32, np.int64, np.bool)
      - Numpy.dtype array-protocol type strings (e.g. 'i4', 'f8', 'S15')

      If no ``dtype`` value is provide then the type is inferred using
      ``np.array(data)``.  When ``data`` is provided then the ``shape``
      and ``length`` arguments are ignored.

    - Provide ``length`` and optionally ``shape``, but not ``data``

      Examples::

        col = MaskedColumn(name='name', length=5)
        col = MaskedColumn(name='name', dtype=int, length=10, shape=(3,4))

      The default ``dtype`` is ``np.float64``.  The ``shape`` argument is the
      array shape of a single cell in the column.
    i    c         C` sH  | d  k rE t | d t  } | t k	 rl t j | d | } ql n' | t j j k r` t } n t |  } t | d | d | d | d | d |	 d |
 d	 | d
 | d | d | 
} t j	 j
 |  d | d | } | d  k rt | d d   d  k	 r| j j | j  } n  | | _ d  | _ x! | j D] } | j | |  q*W| S(   Nu   maskR$   R1   R7   RH   RM   RW   R   RV   RX   R,   RU   R   u
   fill_value(   R(   R^   R   R2   RT   R   t   nomaskR   R#   Rl   R9   R1   R   t
   fill_valueR&   R'   R*   (   R6   RU   RM   R   R   R1   R7   RH   RV   RW   R   RX   R$   R,   R_   R>   R.   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR9   A  s$    	
!$		c         C` s
   |  j    S(   N(   t   get_fill_value(   R>   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR   r  s    c         C` s   d |  _ |  j |  d S(   u   Set fill value both in the masked column view and in the parent table
        if it exists.  Setting one or the other alone doesn't work.N(   R(   t   _fill_valuet   set_fill_value(   R>   R@   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR   v  s    	c         C` s"   |  j  t j  } |  j | _ | S(   N(   R5   R   Rl   R   (   R>   Rj   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRU     s    c         C` s   | d k r |  j } n  t t |   j |  } |  j d k	 rK |  j j n t } | d |  j d | d |  j d |  j	 d |  j
 d t |  j   } | S(   u  Return a copy of self, with masked values filled with a given value.

        Parameters
        ----------
        fill_value : scalar; optional
            The value to use for invalid entries (`None` by default).  If
            `None`, the ``fill_value`` attribute of the array is used
            instead.

        Returns
        -------
        filled_column : Column
            A copy of ``self`` with masked entries replaced by `fill_value`
            (be it the function argument or the attribute of ``self``).
        RM   RU   RW   R   RV   RX   N(   R(   R   Rx   Re   t   filledR&   R   RM   RW   R   RV   R   RX   (   R>   R   RU   t
   column_clsRj   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR     s    !c   
      C` s>  |  j  } |  j j d k rF t j | j  | d d | } | | | <n6 t j | d |  j } t j | j  | | d | } | d k r |  j j d k r t } q t j | j	 d t j
 } n  t j | j | | d | } t j j | d | d t } | j |  j  }	 d |	 _ g  |	 _ |	 j |   |  j |	 _ |	 S(   u  
        Insert values along the given axis before the given indices and return
        a new `~astropy.table.MaskedColumn` object.

        Parameters
        ----------
        obj : int, slice or sequence of ints
            Object that defines the index or indices before which ``values`` is
            inserted.
        values : array_like
            Value(s) to insert.  If the type of ``values`` is different
            from that of quantity, ``values`` is converted to the matching type.
            ``values`` should be shaped so that it can be broadcast appropriately
        mask : boolean array_like
            Mask value(s) to insert.  If not supplied then False is used.
        axis : int, optional
            Axis along which to insert ``values``.  If ``axis`` is None then
            the column array is flattened before insertion.  Default is 0,
            which will insert a row.

        Returns
        -------
        out : `~astropy.table.MaskedColumn`
            A copy of column with ``values`` and ``mask`` inserted.  Note that the
            insertion does not occur in-place: a new masked column is returned.
        u   OR   R1   R   R$   N(   RU   R1   R   R2   R   R(   R:   R   R3   R7   R4   R   R   RT   R5   R=   R&   R'   Ry   R   (
   R>   R8   R   R   R   t   self_mat   new_datat   new_maskt   new_maRj   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyR     s$    				c         C` sM   | j  |  j  k rI d  | _ | j |  j k r9 g  | _ n  | j |   n  | S(   N(   R=   R(   R&   R'   Ry   (   R>   Rj   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   _copy_attrs_slice  s    	c         C` s   t  j r. |  j j d k r. |  j |  } n  t |  j j t j  r} t j	 j
 | d |  j j } |  j | j d   n  |  j j | | t |    t d  k r t	 j j |  | |  n9 t j   + t j d t  t	 j j |  | |  Wd  QXd  S(   Nu   SR1   u    u   ignore(   R   RF   R1   RZ   R[   R   R   R2   R   R   R   R   R   R%   R   R   R   R(   Rl   RA   R   t   catch_warningst   simplefilter(   R>   R.   R   (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRA     s    N(    (   R   R   R   R(   R   RR   R9   R   R   R   RU   R   R   R   RA   R#   RM   R$   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyRe     s$   F	.9							(F   t
   __future__R    R   R   R   t   externR   t   extern.six.movesR   R   Ra   t   reR$   R   t   numpyR2   R   t   numpy.ma.coreR   t   ImportErrorR(   t   unitsR	   R
   t   utils.consoleR   t   utils.metadataR   t   utils.data_infoR   R   t
   utils.miscR   R   R   R   R   t   np_utilsR   t   _column_mixinsR   R   t   TableFormatterR   t   UserWarningR   R   R!   t   sett   greatert   greater_equalt   lesst
   less_equalt	   not_equalR   t   isfinitet   isinft   isnant   signt   signbitR{   RR   R/   R`   R0   RG   R#   R   Rl   Re   (    (    (    s3   lib/python2.7/site-packages/astropy/table/column.pyt   <module>   sN   "
	'*)  " 