σ
\c           @@  s  d  Z  d d l 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
 m Z m Z d d l	 m Z d d l m Z d	 e f d
     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d S(   s{   
    Attribute data transfer testing module

    Covers all data read/write and type-conversion operations for attributes.
i    (   t   absolute_importNi   (   t   TestCaset   ut(   t   h5at   h5st   h5t(   t   File(   t   is_empty_dataspacet	   BaseAttrsc           B@  s   e  Z d    Z d   Z RS(   c         C@  s   t  |  j   d  |  _ d  S(   Nt   w(   R   t   mktempt   f(   t   self(    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   setUp   s    c         C@  s   |  j  r |  j  j   n  d  S(   N(   R   t   close(   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   tearDown"   s    	(   t   __name__t
   __module__R   R   (    (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyR      s   	t
   TestScalarc           B@  s    e  Z d  Z d   Z d   Z RS(   sB   
        Feature: Scalar types map correctly to array scalars
    c         C@  sI   t  j d d t  j |  j j d <|  j j d } |  j | t  j  d S(   s)    Integers are read as correct NumPy type i   t   dtypet   xN(   t   npt   arrayt   int8R   t   attrst   assertIsInstance(   R   t   out(    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_int,   s    "c         C@  s   t  j d
 d g  } t  j d d | } | |  j j d <|  j j d } |  j | t  j  |  j | |  |  j | d | d  d	 S(   s)    Compound scalars are read as numpy.void t   at   it   bR   i   gΝΜΜΜΜΜ@R   R   N(   R   R   (   R   R   (   i   gΝΜΜΜΜΜ@(   R   R   R   R   R   R   t   voidt   assertEqual(   R   t   dtt   dataR   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_compound2   s    (   R   R   t   __doc__R   R#   (    (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyR   &   s   	t	   TestArrayc           B@  s    e  Z d  Z d   Z d   Z RS(   sK   
        Feature: Non-scalar types are correctly retrieved as ndarrays
    c         C@  s_   t  j d d d } | |  j j d <|  j j d } |  j | t  j  |  j | j d  d S(   s/    Single-element arrays are correctly recovered i   R   R   R   N(   i   (   i   (   R   t   ndarrayR   R   R   R    t   shape(   R   R"   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_singleB   s
    c         C@  s   t  j d
 d d } d | (d | d d +| |  j j d <|  j j d } |  j | t  j  |  j | j d  |  j | |  d	 S(   s'    Rank-1 arrays are correctly recovered i*   R   R   g      E@g     Gΐi
   i#   R   N(   i*   (   i*   (   R   R&   R   R   R   R    R'   t   assertArrayEqual(   R   R"   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt
   test_multiJ   s    (   R   R   R$   R(   R*   (    (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyR%   <   s   	t	   TestTypesc           B@  sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   sF   
        Feature: All supported types can be stored in attributes
    c         C@  s­   t  j t  j t  j t  j t  j t  j t  j t  j f } xp | D]h } t  j	 d d | } d | d <| |  j
 j d <|  j
 j d } |  j | j |  |  j | |  q= Wd S(   s    Storage of integer types i   R   i*   .R   N(   i   (   R   R   t   int16t   int32t   int64t   uint8t   uint16t   uint32t   uint64R&   R   R   R    R   R)   (   R   t   dtypesR!   R"   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyR   [   s    
c         C@  s   t  d   d D  } xp | D]h } t j d d | } d | d	 <| |  j j d
 <|  j j d
 } |  j | j |  |  j | |  q Wd S(   s!    Storage of floating point types c         s@  s   |  ] } t  j |  Vq d  S(   N(   R   R   (   t   .0R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pys	   <genexpr>i   s    s   <f4s   >f4s   <f8s   >f8i   R   gfffff&E@.R   N(   s   <f4s   >f4s   <f8s   >f8(   i   (   t   tupleR   R&   R   R   R    R   R)   (   R   R3   R!   R"   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt
   test_floatg   s    
c         C@  s   t  d   d D  } xp | D]h } t j d d | } d | d
 <| |  j j d <|  j j d } |  j | j |  |  j | |  q Wd S(   s    Storage of complex types c         s@  s   |  ] } t  j |  Vq d  S(   N(   R   R   (   R4   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pys	   <genexpr>u   s    s   <c8s   >c8s   <c16s   >c16i   R   y        ΝΜΜΜΜΜΐg33333σA@.R   N(   s   <c8s   >c8s   <c16s   >c16(   i   y33333σA@ΝΜΜΜΜΜΐ(   R5   R   R&   R   R   R    R   R)   (   R   R3   R!   R"   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_complexs   s    
c         C@  s   t  d   d D  } xx | D]p } t j d d | } d | d <| |  j j d <|  j j d } |  j | j |  |  j | d	 | d	  q Wd
 S(   s!    Storage of fixed-length strings c         s@  s   |  ] } t  j |  Vq d  S(   N(   R   R   (   R4   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pys	   <genexpr>   s    s   |S1s   |S10i   R   t   h.R   i    N(   s   |S1s   |S10(   i   (   R5   R   R&   R   R   R    R   (   R   R3   R!   R"   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_string   s    
c         C@  s   t  j d d t  j } t t f | d <| |  j j d <|  j j d } |  j | j | j  |  j | d | d  |  j | d | d  d S(	   s    Storage of NumPy booleans i   R   .R   i    i   N(   i   (	   R   R&   t   bool_t   Truet   FalseR   R   R    R   (   R   R"   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt	   test_bool   s    c         C@  s   t  j d t  } t j d d | } d | d <| |  j j d <|  j j d } |  j | j |  |  j | d | d  |  j | d	 | d	  d
 S(   s#    Storage of vlen byte string arrayst   vleni   R   t   Hellos   Hi there!  This is HDF5!.R   i    i   N(   i   (   R?   s   Hi there!  This is HDF5!(	   t   h5pyt   special_dtypet   bytesR   R&   R   R   R    R   (   R   R!   R"   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_vlen_string_array   s    
c         C@  sΌ   d |  j  j d <|  j  j d } |  j | d  |  j t |  t  t j j |  j  j d  } | j	   } |  j t |  t j
 j  |  j | j   t j
 j  |  j | j    d S(   s@    Storage of variable-length byte string scalars (auto-creation) R?   R   N(   R   R   R    t   typeRB   R@   R   t   opent   idt   get_typeR   t   TypeStringIDt   get_csett
   CSET_ASCIIt
   assertTruet   is_variable_str(   R   R   t   aidt   tid(    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_string_scalar£   s    c         C@  sα   d t  j d  d |  j j d <|  j j d } |  j | d t  j d  d  |  j t |  t  j  t j j	 |  j j
 d  } | j   } |  j t |  t j j  |  j | j   t j j  |  j | j    d S(   s<    Storage of variable-length unicode strings (auto-creation) u   Helloi@#  u   !!R   N(   t   sixt   unichrR   R   R    RD   t	   text_typeR@   R   RE   RF   RG   R   RH   RI   t	   CSET_UTF8RK   RL   (   R   R   RM   RN   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_unicode_scalar²   s    !!(   R   R   R$   R   R6   R7   R9   R=   RC   RO   RT   (    (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyR+   U   s   							t	   TestEmptyc           B@  sP   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   c         C@  sx   t  j |   t j t j  } t j j   } | j d  t	 j |  j
 j d | |  } t j t j d   |  _ d  S(   Ni
   R   t   S10(   R   R   R   t   createt   NULLR   t   C_S1t   copyt   set_sizeR   R   RF   R@   t   EmptyR   R   t	   empty_obj(   R   t   sidRN   RM   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyR   Γ   s    c         C@  s!   |  j  |  j |  j j d  d  S(   NR   (   R    R]   R   R   (   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt	   test_readΛ   s    c         C@  s<   |  j  |  j j d <|  j t t j |  j j d    d  S(   Nt   y(   R]   R   R   RK   R   R   RE   RF   (   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt
   test_writeΠ   s    c         C@  s0   |  j  t   |  j j j d d  Wd  QXd  S(   NR   i   (   t   assertRaisest   IOErrorR   R   t   modify(   R   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_modifyΤ   s    c         C@  s2   t  |  j j j    } |  j |  j g |  d  S(   N(   t   listR   R   t   valuesR    R]   (   R   Rg   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_valuesΨ   s    c         C@  s8   t  |  j j j    } |  j d |  j f g |  d  S(   Nu   x(   Rf   R   R   t   itemsR    R]   (   R   Ri   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt
   test_itemsί   s    c         C@  s5   t  t j |  j j   } |  j |  j g |  d  S(   N(   Rf   RP   t
   itervaluesR   R   R    R]   (   R   Rg   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_itervaluesε   s    c         C@  s;   t  t j |  j j   } |  j d |  j f g |  d  S(   Nu   x(   Rf   RP   t	   iteritemsR   R   R    R]   (   R   Ri   (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   test_iteritemsλ   s    (
   R   R   R   R_   Ra   Re   Rh   Rj   Rl   Rn   (    (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyRU   Α   s   							t   TestWriteExceptionc           B@  s   e  Z d  Z d   Z RS(   sH   
        Ensure failed attribute writes don't leave garbage behind.
    c         C@  sV   d } y | |  j  j d <Wn t k
 r- n X|  j t   |  j  j d Wd QXd S(   s0    ValueError on string write wipes out attribute s   Hello \HelloR   N(   R   R   t
   ValueErrorRb   t   KeyError(   R   t   s(    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyRa   ψ   s    (   R   R   R$   Ra   (    (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyRo   ς   s   (   R$   t
   __future__R    RP   t   numpyR   t   commonR   R   R@   R   R   R   R   t   h5py._hl.baseR   R   R   R%   R+   RU   Ro   (    (    (    s=   lib/python2.7/site-packages/h5py/tests/old/test_attrs_data.pyt   <module>   s   	l1