ó
šßÈ[c           @   s   d  Z  d „  Z d S(   sÒ   
This module is for functions that do tricky things with Numpy arrays and dtypes
that are not normally supported in Numpy (but can work in limited cases
relevant to FITS) or that otherwise require workarounds.
c         C   s'  |  j  ƒ  \ } } } | d d !\ } } | j ƒ  } d } | d	 k s^ t | ƒ t | ƒ k rm t d ƒ ‚ n  xh t | | ƒ D]W \ } }	 | | }
 t | |	 |
 d j ƒ } |	 |
 d k r} |
 d |	 f | | <q} q} Wd j | ƒ } | d  | | f | d } | | | d Œ } | j	 | ƒ | S(
   s„  
    Given a Numpy struct dtype object an a list of integer offsets, with one
    offset per field in the dtype, returns a new dtype where each field has the
    given offset.

    All offsets must be non-negative integers, but otherwise have no
    restrictions, and may overlap, per the usual rules for creating struct
    dtypes.  The new dtype will have an itemsize equal to the offset of the
    right-most field plus the width of that field.

    One restriction of this function is that it must not be used with object
    arrays--incorrect offsets may lead to invalid pointers in the arrays.
    However, this function is really only meant for use by astropy.io.fits and
    object arrays are not supported for FITS data anyhow.

    This function is used primarily to get around a shortcoming in Numpy that
    it is currently impossible to create dtypes with arbitrary offsets, *and*
    that have zero-width fields.  Both of these features are needed for full
    FITS support.  However, this will be fixed in a future version of Numpy at
    which point use of this hack can be deprecated.  See
    https://github.com/numpy/numpy/pull/6430
    i   i   i    sf   Dtype must be a structured dtype, and length of offsets list must be the same as the number of fields.i   s   |V{0}i   i   N(
   t
   __reduce__t   copyt   Nonet   lent
   ValueErrort   zipt   maxt   itemsizet   formatt   __setstate__(   t   dtypet   offsetst   clst   argst   statet   namest   fieldsR   t   namet   offsett   fieldt   new_typespect	   new_statet	   new_dtype(    (    s;   lib/python2.7/site-packages/astropy/io/fits/_numpy_hacks.pyt   realign_dtype   s"    $
N(   t   __doc__R   (    (    (    s;   lib/python2.7/site-packages/astropy/io/fits/_numpy_hacks.pyt   <module>   s   