ó
¾÷Xc           @@  sg   d  Z  d d l m Z d d l Z d d l m Z d „  Z d „  Z d e	 f d	 „  ƒ  YZ
 d
 „  Z d S(   s7   
    Implements a portion of the selection operations.
i    (   t   absolute_importNi   (   t   h5sc         @  sÑ   t  | ƒ d k r ˆ  } n| ˆ  j d k r9 t d ƒ ‚ n^ t ‡  f d †  | Dƒ ƒ rd t d ƒ ‚ n3 t j g  | D] } | ˆ  j | d f ^ qq ƒ } t  | ƒ d k rÁ | j | d d } n | } | | f S(   s„    Returns a 2-tuple containing:

    1. Output dataset dtype
    2. Dtype containing HDF5-appropriate description of destination
    i    s+   Field names only allowed for compound typesc         3@  s   |  ] } | ˆ  j  k Vq d  S(   N(   t   names(   t   .0t   x(   t   dataset_dtype(    s2   /tmp/pip-build-isqEY4/h5py/h5py/_hl/selections2.pys	   <genexpr>    s    s#   Field does not appear in this type.i   N(   t   lenR   t   Nonet
   ValueErrort   anyt   npt   dtypet   fields(   R   R   t   format_dtypet   namet   output_dtype(    (   R   s2   /tmp/pip-build-isqEY4/h5py/h5py/_hl/selections2.pyt   read_dtypes   s    	3c         C@  sw   |  j  d k r t d ƒ ‚ n  | d k r3 d } n$ | t f k rK d } n t d ƒ ‚ |  j ƒ  } | j ƒ  | | f S(   s“    Returns a 2-tuple containing:

    1. Output dataset shape
    2. HDF5 dataspace containing source selection.

    Works for scalar datasets.
    s1   Illegal selection function for non-scalar datasets-   Illegal slicing argument for scalar dataspace(    (    N(    (   t   shapet   RuntimeErrorR   t   EllipsisR   t	   get_spacet
   select_all(   t   dsidt   argst	   out_shapet   source_space(    (    s2   /tmp/pip-build-isqEY4/h5py/h5py/_hl/selections2.pyt   read_selections_scalar0   s    			
t   ScalarReadSelectionc           B@  s    e  Z d  Z d „  Z d „  Z RS(   s5   
        Implements slicing for scalar datasets.
    c         C@  sa   | d k r d  |  _ n' | t f k r3 d |  _ n t d ƒ ‚ t j t j ƒ |  _ | |  _ d  S(   Ns-   Illegal slicing argument for scalar dataspace(    (    (	   R   t   mshapeR   R   R   t   createt   SCALARt   mspacet   fspace(   t   selfR    R   (    (    s2   /tmp/pip-build-isqEY4/h5py/h5py/_hl/selections2.pyt   __init__R   s    c         c@  s"   |  j  j ƒ  |  j |  j  f Vd  S(   N(   R   R   R    (   R!   (    (    s2   /tmp/pip-build-isqEY4/h5py/h5py/_hl/selections2.pyt   __iter__]   s    (   t   __name__t
   __module__t   __doc__R"   R#   (    (    (    s2   /tmp/pip-build-isqEY4/h5py/h5py/_hl/selections2.pyR   L   s   	c         C@  s)   |  j  d k r t |  | ƒ St ƒ  ‚ d S(   sr    Top-level dispatch function for reading.
    
    At the moment, only supports reading from scalar datasets.
    N(    (   R   R   t   NotImplementedError(   R    R   (    (    s2   /tmp/pip-build-isqEY4/h5py/h5py/_hl/selections2.pyt   select_reada   s    (   R&   t
   __future__R    t   numpyR
   t    R   R   R   t   objectR   R(   (    (    (    s2   /tmp/pip-build-isqEY4/h5py/h5py/_hl/selections2.pyt   <module>   s   		