a
    ö¦»a„ý  ã                   @   s  d Z ddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
 ddlmZ ddl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m  mZ G d
d„ de
ƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ dƒZG dd„ dƒZ G dd„ deƒZ!G dd„ deƒZ"G dd„ deƒZ#G dd„ deƒZ$e	 %dej&j'vd¡G d d!„ d!eƒƒZ(e	 %dej&j'vd¡G d"d#„ d#eƒƒZ)e	 %d$ej&j'vd%¡G d&d'„ d'eƒƒZ*e	 %d(ej&j'vd)¡G d*d+„ d+eƒƒZ+e	 %d,ej&j'vd-¡G d.d/„ d/eƒƒZ,e	 %d0ej&j'vd1¡G d2d3„ d3eƒƒZ-e	 %d4ej&j'vd5¡G d6d7„ d7eƒƒZ.G d8d9„ d9eƒZ/G d:d;„ d;eƒZ0G d<d=„ d=eƒZ1G d>d?„ d?eƒZ2G d@dA„ dAeƒZ3G dBdC„ dCeƒZ4G dDdE„ dEeƒZ5G dFdG„ dGeƒZ6G dHdI„ dIeƒZ7G dJdK„ dKeƒZ8G dLdM„ dMeƒZ9G dNdO„ dOeƒZ:G dPdQ„ dQeƒZ;G dRdS„ dSeƒZ<G dTdU„ dUeƒZ=ej>j?ej@jAdVkdWdX�ZBG dYdZ„ dZeƒZCG d[d\„ d\eƒZDG d]d^„ d^eƒZEG d_d`„ d`eƒZFG dadb„ dbeƒZGe	 Hej@jAdckdd¡dedf„ ƒZIdgdh„ ZJdidj„ ZKdkdl„ ZLdmdn„ ZMdodp„ ZNdqdr„ ZOej>jPej@jAdsk dtdX�dudv„ ƒZQG dwdx„ dxeƒZRdS )yzü
    Dataset testing operations.

    Tests all dataset operations, including creation, with the exception of:

    1. Slicing operations for read and write, handled by module test_slicing
    2. Type conversion for read and write (currently untested)
é    Né   )ÚutÚTestCase)Úget_data_file_path)ÚFileÚGroupÚDataset)Úis_empty_dataspace)Úh5fÚh5t)ÚH5pyDeprecationWarningc                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚBaseDatasetc                 C   s   t |  ¡ dƒ| _d S )NÚw)r   ÚmktempÚf©Úself© r   úQ/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/h5py/tests/test_dataset.pyÚsetUp%   s    zBaseDataset.setUpc                 C   s   | j r| j  ¡  d S ©N)r   Úcloser   r   r   r   ÚtearDown(   s    zBaseDataset.tearDownN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   $   s   r   c                   @   s   e Zd ZdZdd„ ZdS )ÚTestReprz5
        Feature: repr(Dataset) behaves sensibly
    c                 C   s<   | j  dd¡}|  t|ƒt¡ | j  ¡  |  t|ƒt¡ dS )z( repr() works on live and dead datasets Úfoo©é   N)r   Úcreate_datasetÚassertIsInstanceÚreprÚstrr   ©r   Údsr   r   r   Útest_repr_open2   s    
zTestRepr.test_repr_openN)r   r   r   Ú__doc__r&   r   r   r   r   r   -   s   r   c                   @   st   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Ze eedƒ d¡dd„ ƒZdd„ ZdS )ÚTestCreateShapez@
        Feature: Datasets can be created from a shape only
    c                 C   s    | j  dd¡}|  |jd¡ dS )z Create a scalar dataset r   r   N©r   r    ÚassertEqualÚshape©r   Údsetr   r   r   Útest_create_scalar@   s    z"TestCreateShape.test_create_scalarc                 C   s    | j  dd¡}|  |jd¡ dS )z Create a size-1 dataset r   ©r   Nr)   r,   r   r   r   Útest_create_simpleE   s    z"TestCreateShape.test_create_simplec                 C   s    | j  dd¡}|  |jd¡ dS )z+ Create a size-1 dataset with integer shaper   r   r/   Nr)   r,   r   r   r   Útest_create_integerJ   s    z#TestCreateShape.test_create_integerc                 C   sX   | j  dd¡}|  |jd¡ |  |jd¡ | j  dd¡}|  |jd¡ |  |jd¡ dS )ú Create an extended dataset r   ©é?   r4   Úbar©é   é
   é<   N©r   r    r*   r+   Úsizer,   r   r   r   Útest_create_extendedO   s    z$TestCreateShape.test_create_extendedc                 C   sX   | j  dd¡}|  |jd¡ |  |jd¡ | j  dd¡}|  |jd¡ |  |jd¡ dS )r2   r   r4   r3   r5   r6   r9   Nr:   r,   r   r   r   Útest_create_integer_extendedX   s    z,TestCreateShape.test_create_integer_extendedc                 C   s&   | j  dd¡}|  |jt d¡¡ dS )ú) Confirm that the default dtype is float r   r3   z=f4N©r   r    r*   ÚdtypeÚnpr,   r   r   r   Útest_default_dtypea   s    z"TestCreateShape.test_default_dtypec                 C   s:   |   t¡� | j d¡ W d  ƒ n1 s,0    Y  dS )z  Missing shape raises TypeError r   N©ÚassertRaisesÚ	TypeErrorr   r    r   r   r   r   Útest_missing_shapef   s    z"TestCreateShape.test_missing_shapec                 C   sF   | j jddtjd�}t ¡ dv r2t dt ¡  ¡ |  |j	tj¡ dS )r>   r   r3   ©r@   )Úppc64lez(Storage of long double deactivated on %sN)
r   r    rA   Z
longdoubleÚplatformÚmachineÚpytestÚxfailr*   r@   r,   r   r   r   Útest_long_doublek   s    z TestCreateShape.test_long_doubleÚ
complex256zNo support for complex256c                 C   s0   | j jddt d¡d�}|  |jt d¡¡ dS )r>   r   r3   rN   rG   N)r   r    rA   r@   r*   r,   r   r   r   Útest_complex256r   s    
ÿzTestCreateShape.test_complex256c                 C   s<   | j  dd¡}|  |jd¡ | j  dd¡}|  |jd¡ d S )Ns   foor/   s   bar/baz)é   r)   ©r   r-   Zdset2r   r   r   Útest_name_bytesy   s    zTestCreateShape.test_name_bytesN)r   r   r   r'   r.   r0   r1   r<   r=   rB   rF   rM   r   ÚskipIfÚhasattrrA   rO   rR   r   r   r   r   r(   :   s   		
r(   c                   @   sx   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTestCreateDatazA
        Feature: Datasets can be created from existing data
    c                 C   s0   t  dd¡}| jjd|d�}|  |j|j¡ dS )z- Create a scalar dataset from existing array r   r   r   ©ÚdataN©rA   Úonesr   r    r*   r+   ©r   rW   r-   r   r   r   r.   †   s    z!TestCreateData.test_create_scalarc                 C   s0   t  dd¡}| jjd|d�}|  |j|j¡ dS )z/ Create an extended dataset from existing data r3   r   r   rV   NrX   rZ   r   r   r   r<   Œ   s    z#TestCreateData.test_create_extendedc                 C   s4   | j jdddd�}|  |tj¡ |  d| j v ¡ dS )z1 Create dataset with missing intermediate groups z/foo/bar/baz©r8   r8   z<i4)r+   r@   N)r   r    r!   Úh5pyr   Ú
assertTruer$   r   r   r   Útest_dataset_intermediate_group’   s    z.TestCreateData.test_dataset_intermediate_groupc                 C   sH   t jddd�}| jjdd|d�}|  |jd¡ |  |d | d¡¡ dS )	z8 Create from existing data, and make it fit a new shape é   r   rG   r   ©r8   é   ©r+   rW   .N)rA   Úaranger   r    r*   r+   ÚassertArrayEqualÚreshaperZ   r   r   r   Útest_reshape˜   s    zTestCreateData.test_reshapec                 C   s>   |   t¡�  t| jd jƒ W d  ƒ n1 s00    Y  dS )zE Binding Dataset to a non-DatasetID identifier fails with ValueError ú/N)rD   Ú
ValueErrorr   r   Úidr   r   r   r   Útest_appropriate_low_level_idŸ   s    z,TestCreateData.test_appropriate_low_level_idc                 C   s`   |j  ¡ }t|tjƒsJ ‚| ¡ |ks*J ‚|d u r@| ¡ s\J ‚n| ¡ rLJ ‚| ¡ |ks\J ‚d S r   )ri   Úget_typeÚ
isinstancer   ÚTypeStringIDÚget_csetÚis_variable_strÚget_size)r   r-   ÚcsetÚlengthÚtidr   r   r   Úcheck_h5_string¤   s    
zTestCreateData.check_h5_stringc                    sz   ‡ fdd„}|ˆ j jddd�ƒ |ˆ j jdddgd�ƒ |ˆ j jddgdggd�ƒ |ˆ j jd	tjddgtd
�d�ƒ dS )z= Creating dataset with byte string yields vlen ASCII dataset c                    s   ˆ j | tjd d� d S ©N©rr   )rt   r   Ú
CSET_ASCII©r-   r   r   r   Úcheck_vlen_ascii°   s    z?TestCreateData.test_create_bytestring.<locals>.check_vlen_asciiÚaó   abcrV   Úbó   defÚcÚdrG   N©r   r    rA   ÚarrayÚobject)r   ry   r   r   r   Útest_create_bytestring®   s    ÿz%TestCreateData.test_create_bytestringc                 C   s4   | j jdtjddgdd�d�}| j|tjdd� d S )	Nrz   r{   r}   ZS3rG   rV   ra   rv   )r   r    rA   r�   rt   r   rw   r,   r   r   r   Útest_create_np_s¹   s    zTestCreateData.test_create_np_sc                    sz   ‡ fdd„}|ˆ j jddd�ƒ |ˆ j jdddgd�ƒ |ˆ j jddgdggd�ƒ |ˆ j jd	tjddgtd
�d�ƒ d S )Nc                    s   ˆ j | tjd d� d S ru   )rt   r   Ú	CSET_UTF8rx   r   r   r   Úcheck_vlen_utf8¾   s    z;TestCreateData.test_create_strings.<locals>.check_vlen_utf8rz   ÚabcrV   r|   Údefr~   r   rG   r€   )r   r†   r   r   r   Útest_create_strings½   s    ÿz"TestCreateData.test_create_stringsc                 C   sL   |   t¡�. | jjdtjddgdd�d� W d   ƒ n1 s>0    Y  d S )Nrz   r{   r}   ZU3rG   rV   )rD   rE   r   r    rA   r�   r   r   r   r   Útest_create_np_uÇ   s    zTestCreateData.test_create_np_uc                 C   s*   | j jddd� |  t| j d jƒ¡ d S )Nr   r   rG   )r   r    r]   r	   ri   r   r   r   r   Ú test_empty_create_via_None_shapeË   s    z/TestCreateData.test_empty_create_via_None_shapec                 C   s2   | j jdtjdd�d� |  t| j d jƒ¡ d S )Nr   r   rG   rV   )r   r    r\   ÚEmptyr]   r	   ri   r   r   r   r   Ú!test_empty_create_via_Empty_classÏ   s    z0TestCreateData.test_empty_create_via_Empty_classc                 C   sF   |   t¡�( | jjddt d¡d� W d   ƒ n1 s80    Y  d S )Nr5   r   ra   rb   )rD   rh   r   r    rA   rc   r   r   r   r   Útest_create_incompatible_dataÓ   s    z,TestCreateData.test_create_incompatible_dataN)r   r   r   r'   r.   r<   r^   rf   rj   rt   rƒ   r„   r‰   rŠ   r‹   r�   rŽ   r   r   r   r   rU   €   s   

rU   c                   @   sÔ   e Zd ZdZej dddejdd… ejdd… fddejdd… ejd	d
… fddejd
d…d
d
…f ejd
d
…d
d…f fddejdd
d…df ejd
d
… fg¡dd„ ƒZ	dd„ Z
dd„ Zdd„ Zdd„ Zd
S )ÚTestReadDirectlyzI
        Feature: Read data directly from Dataset into a Numpy array
    ú+source_shape,dest_shape,source_sel,dest_sel©éd   r   r8   é2   r9   ©éF   éZ   N©r_   r8   ©é   r™   r™   ©é   é   é	   ©r7   rP   r7   ra   c           
      C   sn   t jt  |¡dd� |¡}|jd||d�}t j|ddd�}| ¡ }	|| |	|< | |||¡ t j 	||	¡ d S )NÚint64rG   r-   rV   éÿÿÿÿ)
rA   rc   Úproductre   r    ÚfullÚcopyÚread_directÚtestingÚassert_array_equal)
r   Úwritable_fileÚsource_shapeÚ
dest_shapeÚ
source_selÚdest_selZsource_valuesr-   ÚarrÚexpectedr   r   r   Útest_read_directß   s    	z!TestReadDirectly.test_read_directc                 C   sN   |j ddtjddd�d�}tjddd�}| |¡ tj |tjddd�¡ d S )Nr-   ©r8   r8   rŸ   rG   rV   )r    rA   rc   rY   r¤   r¥   r¦   ©r   r§   r-   r¬   r   r   r   Útest_no_selñ   s    
zTestReadDirectly.test_no_selc                 C   sj   |j ddd�}t dd¡}t t¡�2 | |tjdd… tjdd… ¡ W d   ƒ n1 s\0    Y  d S ©	NZedsetrŸ   rG   r‘   r   r8   r“   r9   )r    rA   rY   rK   ÚraisesrE   r¤   Ús_)r   r§   Ú
empty_dsetr¬   r   r   r   Ú
test_empty÷   s    zTestReadDirectly.test_emptyc                 C   sR   |j dddd�}t d¡}t t¡� | |¡ W d   ƒ n1 sD0    Y  d S ©Nr-   r‘   rŸ   rG   ©éÈ   ©r    rA   rY   rK   r³   rE   r¤   r°   r   r   r   Útest_wrong_shapeý   s    
z!TestReadDirectly.test_wrong_shapec                 C   sV   |j dddd�}tjddd�}t t¡� | |¡ W d   ƒ n1 sH0    Y  d S ©Nr-   r[   rŸ   rG   ÚF)Úorderrº   r°   r   r   r   Útest_not_c_contiguous  s    z&TestReadDirectly.test_not_c_contiguous)r   r   r   r'   rK   ÚmarkÚparametrizerA   r´   r®   r±   r¶   r»   r¿   r   r   r   r   r�   Ù   s   .$üþ

r�   c                   @   sÌ   e Zd ZdZej dddejdd… ejdd… fddejdd… ejd	d
… fddejd
d…d
d
…f ejd
d
…d
d…f fddejdd
d…df ejd
d
… fg¡dd„ ƒZ	dd„ Z
dd„ Zdd„ Zd
S )ÚTestWriteDirectlyz>
        Feature: Write Numpy array directly into Dataset
    r�   r‘   r   r8   r“   r9   r”   r–   Nr—   r˜   r™   rš   rž   rP   r7   ra   c           	      C   sl   |j d|ddd�}t t |¡¡ |¡}tj|ddd�}|| ||< | |||¡ tj |d d … |¡ d S )Nr-   Úint32r    ©r@   Ú	fillvaluerG   )	r    rA   rc   r¡   re   r¢   Úwrite_directr¥   r¦   )	r   r§   r¨   r©   rª   r«   r-   r¬   r­   r   r   r   Útest_write_direct  s    	z#TestWriteDirectly.test_write_directc                 C   sd   |j ddd�}t t¡�8 | t d¡tjdd… tjdd… ¡ W d   ƒ n1 sV0    Y  d S r²   )r    rK   r³   rE   rÆ   rA   rY   r´   )r   r§   rµ   r   r   r   r¶     s    zTestWriteDirectly.test_emptyc                 C   sR   |j dddd�}t d¡}t t¡� | |¡ W d   ƒ n1 sD0    Y  d S r·   ©r    rA   rY   rK   r³   rE   rÆ   r°   r   r   r   r»   $  s    
z"TestWriteDirectly.test_wrong_shapec                 C   sV   |j dddd�}tjddd�}t t¡� | |¡ W d   ƒ n1 sH0    Y  d S r¼   rÈ   r°   r   r   r   r¿   *  s    z'TestWriteDirectly.test_not_c_contiguous)r   r   r   r'   rK   rÀ   rÁ   rA   r´   rÇ   r¶   r»   r¿   r   r   r   r   rÂ   	  s   .$üþ
rÂ   c                   @   sP   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚTestCreateRequirezS
        Feature: Datasets can be created only if they don't exist in the file
    c                 C   s.   | j  ddd¡}|  |t¡ |  |jd¡ dS )z& Create new dataset with no conflicts r   r`   r   N)r   Úrequire_datasetr!   r   r*   r+   r,   r   r   r   Útest_create7  s    zTestCreateRequire.test_createc                 C   s0   | j  ddd¡}| j  ddd¡}|  ||¡ dS )z) require_dataset yields existing dataset r   r`   r   N©r   rÊ   r*   rQ   r   r   r   Útest_create_existing=  s    z&TestCreateRequire.test_create_existingc                 C   sˆ   | j  ddd¡}| j  ddd¡}|  ||¡ | j  ddd¡}| j  ddd¡}|  ||¡ | j  ddd¡}| j  ddd¡}|  ||¡ dS )	z; require_dataset with integer shape yields existing datasetr   r8   r   r5   r¯   Zbazs   bazNrÌ   rQ   r   r   r   Útest_create_1DC  s    z TestCreateRequire.test_create_1Dc                 C   sN   | j  ddd¡ |  t¡�  | j  ddd¡ W d  ƒ n1 s@0    Y  dS )z6 require_dataset with shape conflict yields TypeError r   r`   r   )r8   r   N©r   r    rD   rE   rÊ   r   r   r   r   Útest_shape_conflictQ  s    z%TestCreateRequire.test_shape_conflictc                 C   sJ   | j  d¡ |  t¡�  | j  ddd¡ W d  ƒ n1 s<0    Y  dS )z< require_dataset with object type conflict yields TypeError r   r`   r   N)r   Zcreate_grouprD   rE   rÊ   r   r   r   r   Útest_type_conflictW  s    z$TestCreateRequire.test_type_conflictc                 C   sN   | j  ddd¡}|  t¡�  | j  ddd¡ W d  ƒ n1 s@0    Y  dS )zL require_dataset with dtype conflict (strict mode) yields TypeError
        r   r`   r   ZS10NrÏ   r,   r   r   r   Útest_dtype_conflict]  s    z%TestCreateRequire.test_dtype_conflictc                 C   s4   | j  ddd¡}| j jddddd�}|  ||¡ dS )z* require_dataset with exactly dtype match r   r`   r   T©ÚexactN)r   r    rÊ   r*   rQ   r   r   r   Útest_dtype_exactd  s    z"TestCreateRequire.test_dtype_exactc                 C   sH   | j  ddd¡}| j jddddd�}|  ||¡ |  |jt d¡¡ dS )zJ require_dataset with convertible type succeeds (non-strict mode)
        r   r`   Úi4Úi2FrÓ   N)r   r    rÊ   r*   r@   rA   rQ   r   r   r   Útest_dtype_closek  s    z"TestCreateRequire.test_dtype_closeN)r   r   r   r'   rË   rÍ   rÎ   rÐ   rÑ   rÒ   rÕ   rØ   r   r   r   r   rÉ   1  s   rÉ   c                   @   sX   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )ÚTestCreateChunkedzL
        Feature: Datasets can be created by manually specifying chunks
    c                 C   s$   | j jdddd�}|  |jd¡ dS )z Create via chunks tuple r   r‘   r¯   ©r+   ÚchunksN©r   r    r*   rÛ   r,   r   r   r   Útest_create_chunksz  s    z$TestCreateChunked.test_create_chunksc                 C   s$   | j jdddd�}|  |jd¡ dS )z Create via chunks integer r   r‘   r8   rÚ   r¯   NrÜ   r,   r   r   r   Útest_create_chunks_integer  s    z,TestCreateChunked.test_create_chunks_integerc                 C   s@   |   t¡�" | jjdddd� W d  ƒ n1 s20    Y  dS )z& Illegal chunk size raises ValueError r   r‘   r¸   rÚ   N©rD   rh   r   r    r   r   r   r   Útest_chunks_mismatch„  s    z&TestCreateChunked.test_chunks_mismatchc                 C   sB   |   t¡�$ | jjddddd� W d  ƒ n1 s40    Y  dS )z3 Chunked format required for given storage options r   r¯   r’   F)r+   ÚmaxshaperÛ   Nrß   r   r   r   r   Útest_chunks_false‰  s    z#TestCreateChunked.test_chunks_falsec                 C   s@   |   t¡�" | jjdddd� W d  ƒ n1 s20    Y  dS )z> Attempting to create chunked scalar dataset raises TypeError r   r   )r“   rÚ   NrC   r   r   r   r   Útest_chunks_scalarŽ  s    z$TestCreateChunked.test_chunks_scalarc                 C   s6   | j jdddd�}|  |jt¡ |  t|jƒd¡ dS )z Auto-chunking of datasets r   )r™   r’   TrÚ   rP   N)r   r    r!   rÛ   Útupler*   Úlenr,   r   r   r   Útest_auto_chunks“  s    z"TestCreateChunked.test_auto_chunksc                 C   s&   | j jddddd�}|  |jd¡ dS )z7 Auto-chunking with pathologically large element sizes r   ©ra   Z
S100000000T©r+   r@   rÛ   r/   NrÜ   r,   r   r   r   Útest_auto_chunks_abuse™  s    z(TestCreateChunked.test_auto_chunks_abusec                 C   s–   | j jddtjdd�}d|ddd…df< |  t |ddd…df dk¡¡ d	|d< |  t |d d	k¡¡ d
|dd…< |  t |dd… d
k¡¡ dS )z+ Test scalar assignment of chunked dataset r   )ra   r“   r“   )r   r“   r“   rè   r8   r   Né(   é   é   r   rP   )r   r    rA   rÃ   r]   Úallr,   r   r   r   Útest_scalar_assignmentž  s    
ÿ"z(TestCreateChunked.test_scalar_assignmentc                 C   s„   t jtdd��"}| jjdddd� W d  ƒ n1 s60    Y  t jtdd��"}| jjdddd	� W d  ƒ n1 sv0    Y  dS )
z, Auto-chunking of empty datasets not allowedrŒ   )Úmatchr   ZS100T)r@   rÛ   Nr™   ©r@   rá   )rK   r³   rE   r   r    )r   Úerrr   r   r   Útest_auto_chunks_no_shape®  s    0z+TestCreateChunked.test_auto_chunks_no_shapeN)r   r   r   r'   rÝ   rÞ   rà   râ   rã   ræ   ré   rî   rò   r   r   r   r   rÙ   t  s   rÙ   c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚTestCreateFillvaluez>
        Feature: Datasets can be created with fill value
    c                 C   s6   | j jdddd�}|  |d d¡ |  |d d¡ dS )z- Fill value is reflected in dataset contents r   r¯   g      @©rÅ   r   rœ   N)r   r    r*   r,   r   r   r   Útest_create_fillval½  s    z'TestCreateFillvalue.test_create_fillvalc                 C   s4   | j jdddd�}|  |jd¡ |  |jtj¡ dS )z( Fill value is recoverable via property r   r¯   g      @rô   N)r   r    r*   rÅ   ZassertNotIsInstancerA   Úndarrayr,   r   r   r   Útest_propertyÃ  s    z!TestCreateFillvalue.test_propertyc                 C   s    | j  dd¡}|  |jd¡ dS )z0 .fillvalue property works correctly if not set r   r¯   r   N)r   r    r*   rÅ   r,   r   r   r   Útest_property_noneÉ  s    z&TestCreateFillvalue.test_property_nonec                 C   sV   t  ddg¡}t jd|d�d }| jjdd||d�}|  |j|¡ |  |d	 |¡ d
S )z& Fill value works with compound types )rz   Úf4)r|   Úi8r/   rG   r   r   r¯   rÄ   r   N)rA   r@   rY   r   r    r*   rÅ   ZassertAlmostEqual)r   ÚdtÚvr-   r   r   r   Útest_compoundÎ  s
    z!TestCreateFillvalue.test_compoundc                 C   sF   |   t¡�( | jjddddgdd�}W d  ƒ n1 s80    Y  dS )z$ Bogus fill value raises ValueError r   r¯   ©rz   Úi)r|   r   é*   rÄ   Nrß   r,   r   r   r   Útest_excÖ  s    
ÿzTestCreateFillvalue.test_excN)	r   r   r   r'   rõ   r÷   rø   rý   r  r   r   r   r   ró   ·  s   ró   c                   @   s   e Zd ZdZdd„ ZdS )ÚTestCreateNamedTypezC
        Feature: Datasets created from an existing named type
    c                 C   sn   t  d¡| jd< | jjdd| jd d�}|  |jt  d¡¡ |  |j ¡ | jd j¡ |  |j ¡  ¡ ¡ dS )z7 Named type object works and links the dataset to type Úf8ÚtypeÚxr‘   rG   N)	rA   r@   r   r    r*   ri   rk   r]   Z	committedr,   r   r   r   Ú
test_namedã  s
    zTestCreateNamedType.test_namedN)r   r   r   r'   r  r   r   r   r   r  Ý  s   r  ÚgzipzDEFLATE is not installedc                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚTestCreateGzipz=
        Feature: Datasets created with gzip compression
    c                 C   s4   | j jddddd�}|  |jd¡ |  |jd¡ dS )z# Create with explicit gzip options r   ©r™   r_   r  r�   ©ÚcompressionÚcompression_optsN©r   r    r*   r  r  r,   r   r   r   Ú	test_gzipó  s
    ÿzTestCreateGzip.test_gzipc                 C   s2   | j jdddd�}|  |jd¡ |  |jd¡ dS )z+ Create with implicit gzip level (level 4) r   r	  r  ©r  r   Nr  r,   r   r   r   Útest_gzip_implicitú  s    z!TestCreateGzip.test_gzip_implicitc                 C   s    | j jdddd�}|  |jd¡ |  |jd¡ tjjj}zVt	ƒ tjj_|  
t¡�" | j jdddd�}W d  ƒ n1 sx0    Y  W |tjj_n|tjj_0 dS )z. Create with gzip level by specifying integer r   r	  rœ   r  r  N)r   r    r*   r  r  r\   Ú_hlÚdatasetÚ_LEGACY_GZIP_COMPRESSION_VALSrä   rD   rh   )r   r-   Úoriginal_compression_valsr   r   r   Útest_gzip_number   s    
2zTestCreateGzip.test_gzip_numberc                 C   s¾   |   ttf¡�" | jjdddd� W d  ƒ n1 s60    Y  |   t¡�" | jjdddd� W d  ƒ n1 sr0    Y  |   t¡�$ | jjddddd� W d  ƒ n1 s°0    Y  dS )	z= Illegal gzip level (explicit or implicit) raises ValueError r   r	  é   r  Néüÿÿÿr  r
  )rD   rh   ÚRuntimeErrorr   r    r   r   r   r   Útest_gzip_exc  s    00ÿzTestCreateGzip.test_gzip_excN)r   r   r   r'   r  r  r  r  r   r   r   r   r  ì  s
   r  c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestCreateCompressionNumberz?
        Feature: Datasets created with a compression code
    c                 C   sj   t jjj}z2tƒ t jj_| jjddt jjdd�}W |t jj_n|t jj_0 |  	|j
d¡ |  	|jd¡ dS )z^ Create with compression number of gzip (h5py.h5z.FILTER_DEFLATE) and a compression level of 7r   r	  )rœ   r
  r  rœ   N)r\   r  r  r  rä   r   r    Úh5zÚFILTER_DEFLATEr*   r  r  )r   r  r-   r   r   r   Útest_compression_number   s    
z3TestCreateCompressionNumber.test_compression_numberc                 C   s  |   t¡�"}| jjdddd� W d  ƒ n1 s20    Y  |  dt|jƒ¡ |   t¡�"}| jjdddd� W d  ƒ n1 s€0    Y  |  dt|jƒ¡ tjj	j
}zZtƒ tjj	_
|   t¡�& | jjddtjjd� W d  ƒ n1 sê0    Y  W |tjj	_
n|tjj	_
0 dS )	z* Create with invalid compression numbers  r   r	  iüÿÿr  NzInvalid filterr’   zUnknown compression)rD   rh   r   r    ZassertInr#   Ú	exceptionr\   r  r  r  rä   Ú
IndexErrorr  r  )r   Úer  r   r   r   Útest_compression_number_invalid,  s    00
6z;TestCreateCompressionNumber.test_compression_number_invalidN)r   r   r   r'   r  r!  r   r   r   r   r    s   r  ÚlzfzLZF is not installedc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestCreateLZFú<
        Feature: Datasets created with LZF compression
    c                 C   sŽ   | j jdddd�}|  |jd¡ |  |jd¡ t d¡}| j jd|dd�}|  |jd¡ |  |jd¡ | j  ¡  | j d d	 }|  ||¡ dS )
z Create with explicit lzf r   r	  r"  r  Nr’   r5   )rW   r  r   )	r   r    r*   r  r  rA   rc   Úflushrd   )r   r-   ÚtestdataÚreaddatar   r   r   Útest_lzfH  s    

zTestCreateLZF.test_lzfc                 C   sB   |   t¡�$ | jjddddd� W d  ƒ n1 s40    Y  dS )z& Giving lzf options raises ValueError r   r	  r"  r   r
  Nrß   r   r   r   r   Útest_lzf_excX  s    ÿzTestCreateLZF.test_lzf_excN)r   r   r   r'   r(  r)  r   r   r   r   r#  A  s   r#  ÚszipzSZIP is not installedc                   @   s   e Zd ZdZdd„ ZdS )ÚTestCreateSZIPr$  c                 C   s   | j jddddd�}dS )z Create with explicit szip r   r	  r*  )Zecé   r
  N)r   r    r,   r   r   r   Ú	test_szipf  s    ÿzTestCreateSZIP.test_szipN)r   r   r   r'   r-  r   r   r   r   r+  _  s   r+  ÚshufflezSHUFFLE is not installedc                   @   s   e Zd ZdZdd„ ZdS )ÚTestCreateShufflez8
        Feature: Datasets can use shuffling filter
    c                 C   s"   | j jdddd�}|  |j¡ dS )z Enable shuffle filter r   r	  T)r.  N)r   r    r]   r.  r,   r   r   r   Útest_shuffles  s    zTestCreateShuffle.test_shuffleN)r   r   r   r'   r0  r   r   r   r   r/  l  s   r/  Ú
fletcher32zFLETCHER32 is not installedc                   @   s   e Zd ZdZdd„ ZdS )ÚTestCreateFletcher32z=
        Feature: Datasets can use the fletcher32 filter
    c                 C   s"   | j jdddd�}|  |j¡ dS )z Enable fletcher32 filter r   r	  T)r1  N)r   r    r]   r1  r,   r   r   r   Útest_fletcher32  s    z$TestCreateFletcher32.test_fletcher32N)r   r   r   r'   r3  r   r   r   r   r2  y  s   r2  ÚscaleoffsetzSCALEOFFSET is not installedc                   @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )ÚTestCreateScaleOffsetz?
        Feature: Datasets can use the scale/offset filter
    c                 C   sB   |   t¡�$ | jjddtdd�}W d  ƒ n1 s40    Y  dS )z[ Ensure that a scale factor is required for scaleoffset compression of floating point data r   r	  T©r@   r4  N©rD   rh   r   r    Úfloatr,   r   r   r   Ú test_float_fails_without_options‹  s    z6TestCreateScaleOffset.test_float_fails_without_optionsc                 C   sB   |   t¡�$ | jjddtdd�}W d  ƒ n1 s40    Y  dS )z# Check when scaleoffset is negetiver   r	  gš™™™™™¹¿r6  Nr7  r,   r   r   r   Útest_non_integer‘  s    z&TestCreateScaleOffset.test_non_integerc                 C   sB   |   t¡�$ | jjddtdd�}W d  ƒ n1 s40    Y  dS )z% Check when dtype is unsupported typer   r	  Tr6  N)rD   rE   r   r    Úboolr,   r   r   r   Útest_unsupport_dtype—  s    z*TestCreateScaleOffset.test_unsupport_dtypec                 C   sª   d}d}dd|  }t jj|Ž d | }| jjd|t|d�}|jdusJJ ‚||d	< | jj}| j ¡  t	 
|d
¡| _| jd d	 }| j||d|  d� ||k ¡ r¦J ‚dS )z2 Scaleoffset filter works for floating point data r   ©r’   i,  r™   r8   g      à?r   r6  N.Úr)Z	precision)rA   ÚrandomÚrandr   r    r8  r4  Úfilenamer   r\   r   rd   rí   )r   Zscalefacr+   Úranger&  r-   rA  r'  r   r   r   Ú
test_float�  s    
z TestCreateScaleOffset.test_floatc                 C   sŠ   d}d}t jjdd| d |d�}| jjd|tdd	�}|jd
usDJ ‚||d< | jj}| j ¡  t	 
|d¡| _| jd d }|  ||¡ d
S )zB Scaleoffset filter works for integer data with default precision rì   r=  r   rP   r   ©r;   r   Tr6  N.r>  )rA   r?  Úrandintr   r    Úintr4  rA  r   r\   r   rd   ©r   Únbitsr+   r&  r-   rA  r'  r   r   r   Útest_int·  s    
zTestCreateScaleOffset.test_intc                 C   sˆ   d}d}t jjdd| |d�}| jjd|t|d�}|  |jdk¡ ||d< | jj}| j 	¡  t
 |d	¡| _| jd d }|  ||¡ d
S )úD Scaleoffset filter works for integer data with specified precision rì   r=  r   rP   rD  r   r6  .r>  N)rA   r?  rE  r   r    rF  r]   r4  rA  r   r\   r   rd   rG  r   r   r   Útest_int_with_minbitsÌ  s    
z+TestCreateScaleOffset.test_int_with_minbitsc                 C   s”   d}d}t jjdd|d  d |d�}| jjd|t|d�}|  |jdk¡ ||d	< | jj}| j 	¡  t
 |d
¡| _| jd d	 }||k ¡ r�J ‚dS )rJ  rì   r=  r   rP   r   rD  r   r6  .r>  N)rA   r?  rE  r   r    rF  r]   r4  rA  r   r\   r   rí   rG  r   r   r   Útest_int_with_minbits_lossyà  s    
z1TestCreateScaleOffset.test_int_with_minbits_lossyN)r   r   r   r'   r9  r:  r<  rC  rI  rK  rL  r   r   r   r   r5  …  s   r5  c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚTestExternalzB
        Feature: Datasets with the external storage property
    c                 C   s˜   d}t j |¡}|  ¡ }|dtjfg}| jjd||j|d�}||d< |jdusRJ ‚t	|dƒ�}| 
¡ }W d  ƒ n1 sz0    Y  || ¡ ks”J ‚dS )z' Create and access an external dataset ©r7   r’   r   r   )r@   Úexternal.NÚrb)rA   r?  r   r
   Ú	UNLIMITEDr   r    r@   rO  ÚopenÚreadÚtobytes)r   r+   r&  Úext_filerO  r-   ZfidÚcontentsr   r   r   Útest_contentsû  s    &zTestExternal.test_contentsc                 C   s   | j jdd|  ¡ d� dS )z/ External argument may be a file name str only r   rN  ©rO  N)r   r    r   r   r   r   r   Útest_name_str  s    zTestExternal.test_name_strc                 C   s    | j jddt |  ¡ ¡d� dS )z0 External argument may be a file name path only r   rN  rX  N)r   r    ÚpathlibÚPathr   r   r   r   r   Útest_name_path  s    
ÿzTestExternal.test_name_pathc                    sN   |   ¡ ‰ d}t‡ fdd„t|ƒD ƒƒ}| jjdd|d�}t|jƒ|ksJJ ‚dS )z9 External argument may be an iterable of multiple tuples r’   c                 3   s   | ]}ˆ |d  d fV  qdS )éè  Nr   ©Ú.0r  ©rU  r   r   Ú	<genexpr>  ó    z/TestExternal.test_iter_multi.<locals>.<genexpr>ZpoorN  rX  N)r   ÚiterrB  r   r    rå   rO  )r   ÚNrO  r-   r   r`  r   Útest_iter_multi  s
    zTestExternal.test_iter_multic              
   C   s°   d}|   ¡ }t|gft|dgft|dtjgft|fgft|dfgft|dtjdfgft|ddfgffD ]D\}}|  |¡�" | jjd||d� W d  ƒ qf1 s 0    Y  qfdS )z" Test with invalid external lists rN  r   zh5f.UNLIMITEDr   rX  N)r   rE   r
   rQ  rh   rD   r   r    )r   r+   rU  Úexc_typerO  r   r   r   Útest_invalid"  s    

ù	zTestExternal.test_invalidN)	r   r   r   r'   rW  rY  r\  re  rg  r   r   r   r   rM  ÷  s   	rM  c                   @   s2   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ ZdS )ÚTestAutoCreatezP
        Feature: Datasets auto-created from data produce the correct types
    Tc                 C   sB   |j  ¡ }|  t|ƒtjj¡ |  | ¡ |¡ |r>| ¡ s>J ‚d S r   )	ri   rk   r*   r  r\   r   rm   rn   ro   )r   r%   rq   Úvariablers   r   r   r   Úassert_string_type:  s
    
z!TestAutoCreate.assert_string_typec                 C   sx   d| j d< |  | j d tjj¡ ddg| j d< |  | j d tjj¡ tjddgtjd�| j d< |  | j d tjj¡ dS )	z<Assigning byte strings produces a vlen string ASCII dataset s   Hello therer  ó   as   bcÚyrG   ÚzN)r   rj  r\   r   rw   rA   r�   Úobject_r   r   r   r   Útest_vlen_bytesA  s    
zTestAutoCreate.test_vlen_bytesc                 C   s‚   dt dƒ | jd< |  | jd tjj¡ ddg| jd< |  | jd tjj¡ tjddggtjd�| jd< |  | jd tjj¡ d	S )
z?Assigning unicode strings produces a vlen string UTF-8 dataset úHello thereé4   r  rz   Zbcrl  rG   rm  N)	Úchrr   rj  r\   r   r…   rA   r�   rn  r   r   r   r   Útest_vlen_unicodeL  s    z TestAutoCreate.test_vlen_unicodec                 C   sH   t  d¡| jd< | jd }| j|tjjdd� |  |j 	¡  
¡ d¡ dS )zV Assignment of fixed-length byte string produces a fixed-length
        ascii dataset rp  r  F)ri  rë   N)rA   Ústring_r   rj  r\   r   rw   r*   ri   rk   rp   r$   r   r   r   Útest_string_fixedX  s    
z TestAutoCreate.test_string_fixedN)T)r   r   r   r'   rj  ro  rs  ru  r   r   r   r   rh  5  s
   
rh  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestCreateLikec                 C   sV   t  d¡ dd¡| jd< | j d| jd ¡ | jd }|  |jd¡ |  |jd ¡ d S )Né   r›   ZlolZlike_lol)r›   r›   )	rA   rc   re   r   Úcreate_dataset_liker*   r+   ZassertIsrÛ   )r   Zdsliker   r   r   Útest_no_chunksb  s
    
zTestCreateLike.test_no_chunksc                 C   s°   | j jdt d¡dd�}|  dtj |j¡j	¡ | j  
d|¡}|  dtj |j¡j	¡ | j jdt d¡dd�}|  dtj |j¡j	¡ | j  
d	|¡}|  dtj |j¡j	¡ d S )
NZhondarì   T)rW   Útrack_timesr   ZhyundaiZibmFZlenovo)r   r    rA   rc   ÚassertNotEqualr\   Úh5gÚget_objinfoÚ_idÚmtimerx  r*   )r   ÚorigÚsimilarr   r   r   Útest_track_timesi  s    ÿÿzTestCreateLike.test_track_timesc                 C   s@   | j jdddd�}| j  d|¡}|  |jd¡ |  |jd¡ dS )z) Test when other.maxshape != other.shape Úotherr¯   r™   ©rá   Úsim©r™   N)r   r    rx  r*   r+   rá   )r   rƒ  r�  r   r   r   Útest_maxshapev  s    zTestCreateLike.test_maxshapeN)r   r   r   ry  r‚  r‡  r   r   r   r   rv  a  s   rv  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestChunkIteratorc                 C   sD   | j  dd¡}|  t¡� | ¡  W d   ƒ n1 s60    Y  d S )Nr   r   )r   r    rD   rE   Úiter_chunksr,   r   r   r   ry    s    z TestChunkIterator.test_no_chunksc                 C   s®   | j jdddd�}tdddƒftdddƒftdd	dƒftd	d
dƒff}|  t| ¡ ƒt|ƒ¡ tdddƒftdd	dƒftd	ddƒff}|  t| tjdd… ¡ƒt|ƒ¡ d S )Nr   r‘   )é    ©rÛ   r   rŠ  r   é@   é`   r’   r“   éa   ©r   r    Úslicer*   Úlistr‰  rA   r´   ©r   r-   r­   r   r   r   Útest_1d„  s    $ÿ(zTestChunkIterator.test_1dc                 C   s(  | j jdddd�}tdddƒtdddƒftdddƒtdd	dƒftdddƒtdddƒftdddƒtdd	dƒftdd
dƒtdddƒftdd
dƒtdd	dƒftd
d	dƒtdddƒftd
d	dƒtdd	dƒff}|  t| ¡ ƒt|ƒ¡ tdddƒtdddƒff}|  t| tjdd…dd…f ¡ƒt|ƒ¡ d S )Nr   ©r’   r’   )rŠ  rŒ  r‹  r   rŠ  r   rŒ  r’   r�  é0   é4   rê   r“   r�  r’  r   r   r   Útest_2dŒ  s      
ÿ 
ÿ 
ÿüzTestChunkIterator.test_2dN)r   r   r   ry  r“  r—  r   r   r   r   rˆ  ~  s   rˆ  c                   @   sX   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )Ú
TestResizezF
        Feature: Datasets created with "maxshape" may be resized
    c                 C   s2   | j jdddd�}|  |jd¡ |  |jd¡ dS )z  Create dataset with "maxshape" r   r	  ©r™   r9   r„  N©r   r    ZassertIsNotrÛ   r*   rá   r,   r   r   r   rË      s    zTestResize.test_createc                 C   sR   | j jdddd�}|  |jd¡ |  |jd¡ | j jdddd�}|  |jd¡ dS )z6 Create dataset with "maxshape" using integer maxshaper   r†  r™   r„  Nr5   rš  r,   r   r   r   rÎ   ¦  s
    zTestResize.test_create_1Dc                 C   sT   | j jdddd�}|  |jd¡ | d¡ |  |jd¡ | d¡ |  |jd¡ dS )z( Datasets may be resized up to maxshape r   r	  r™  r„  ©r™   r“   N©r   r    r*   r+   Úresizer,   r   r   r   Útest_resize¯  s    

zTestResize.test_resizec                 C   s<   | j jdddd�}|  |jd¡ | d¡ |  |jd¡ dS )z> Datasets may be resized up to maxshape using integer maxshaper   r™   rê   r„  r†  )r_   Nrœ  r,   r   r   r   Útest_resize_1D¸  s    
zTestResize.test_resize_1Dc                 C   sJ   | j jdddd�}|  t¡� | d¡ W d  ƒ n1 s<0    Y  dS )z. Resizing past maxshape triggers an exception r   r	  r™  r„  )r™   r•   N)r   r    rD   Ú	Exceptionr�  r,   r   r   r   Útest_resize_over¿  s    zTestResize.test_resize_overc                 C   sF   | j  dd¡}|  t¡� | d¡ W d  ƒ n1 s80    Y  dS )z/ Resizing non-chunked dataset raises TypeError r   r	  r™  N)r   r    rD   rE   r�  r,   r   r   r   Útest_resize_nonchunkedÅ  s    z!TestResize.test_resize_nonchunkedc                 C   s2   | j jdddd�}|jddd� |  |jd¡ d	S )
z Resize specified axis r   r	  r™  r„  r“   r   ©Zaxisr›  N)r   r    r�  r*   r+   r,   r   r   r   Útest_resize_axisË  s    zTestResize.test_resize_axisc                 C   sN   | j jdddd�}|  t¡� |jddd� W d  ƒ n1 s@0    Y  dS )	z  Illegal axis raises ValueError r   r	  r™  r„  r“   rP   r£  N)r   r    rD   rh   r�  r,   r   r   r   Útest_axis_excÑ  s    zTestResize.test_axis_excc                 C   s2   | j jdddd�}|  |jd¡ |  |jd¡ dS )z? Allow zero-length initial dims for unlimited axes (issue 111) r   )é   r   )r¦  Nr„  N)r   r    r*   r+   rá   r,   r   r   r   Útest_zero_dim×  s    zTestResize.test_zero_dimN)r   r   r   r'   rË   rÎ   rž  rŸ  r¡  r¢  r¤  r¥  r§  r   r   r   r   r˜  š  s   		r˜  c                   @   s   e Zd ZdZdd„ ZdS )Ú	TestDtypezD
        Feature: Dataset dtype is available as .dtype property
    c                 C   s(   | j  ddd¡}|  |jt d¡¡ dS )z Retrieve dtype from dataset r   ©r›   ú|S10Nr?   r,   r   r   r   Ú
test_dtypeä  s    zTestDtype.test_dtypeN)r   r   r   r'   r«  r   r   r   r   r¨  Þ  s   r¨  c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestLenzG
        Feature: Size of first axis is available via Python's len
    c                 C   s"   | j  dd¡}|  t|ƒd¡ dS )z Python len() (under 32 bits) r   )é8  r¦  r­  N)r   r    r*   rå   r,   r   r   r   Útest_lenð  s    zTestLen.test_lenc                 C   s~   | j  dd¡}|  |jd¡ tjdkrZ|  t¡� t|ƒ W d  ƒ qj1 sN0    Y  n|  t|ƒd¡ |  | ¡ d¡ dS )z Python len() vs Dataset.len() r   )ì        r¦  iÿÿÿNr¯  )	r   r    r*   r+   ÚsysÚmaxsizerD   ÚOverflowErrorrå   r,   r   r   r   Útest_len_bigõ  s    
(zTestLen.test_len_bigN)r   r   r   r'   r®  r³  r   r   r   r   r¬  ê  s   r¬  c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestIterz;
        Feature: Iterating over a dataset yields rows
    c                 C   sX   t jddd� d¡}| jjd|d�}t||ƒD ]$\}}|  t|ƒd¡ |  ||¡ q.dS )	z& Iterating over a dataset yields rows r_   r   rG   r`   r   rV   ra   N)	rA   rc   re   r   r    Úzipr*   rå   rd   )r   rW   r-   r  rl  r   r   r   Ú	test_iter  s
    zTestIter.test_iterc                 C   sL   | j jddd�}|  t¡� dd„ |D ƒ W d  ƒ n1 s>0    Y  dS )z0 Iterating over scalar dataset raises TypeError r   r   )r+   c                 S   s   g | ]}|‘qS r   r   r^  r   r   r   Ú
<listcomp>  rb  z-TestIter.test_iter_scalar.<locals>.<listcomp>N)r   r    rD   rE   r,   r   r   r   Útest_iter_scalar  s    zTestIter.test_iter_scalarN)r   r   r   r'   r¶  r¸  r   r   r   r   r´    s   r´  c                   @   sx   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTestStringszr
        Feature: Datasets created with vlen and fixed datatypes correctly
        translate to and from HDF5
    c                 C   sn   t jdd�}| jjdd|d�}|j ¡ }|  t|ƒt jj	¡ |  | 
¡ t jj¡ t  |j¡}|  |jd¡ dS )z3 Vlen bytes dataset maps to vlen ascii in the file Úascii©Úencodingr  r‘   rG   N)r\   Ústring_dtyper   r    ri   rk   r*   r  r   rm   rn   rw   Úcheck_string_dtyper@   r¼  ©r   rû   r%   rs   Zstring_infor   r   r   ro    s    
zTestStrings.test_vlen_bytesc                 C   sj   t  ¡ }| jjdd|d�}|j ¡ }|  t|ƒt jj	¡ |  | 
¡ t jj¡ t  |j¡}|  |jd¡ dS )z5 Vlen unicode dataset maps to vlen utf-8 in the file r  r‘   rG   úutf-8N)r\   r½  r   r    ri   rk   r*   r  r   rm   rn   r…   r¾  r@   r¼  r¿  r   r   r   rs  '  s    
zTestStrings.test_vlen_unicodec                 C   s˜   t  d¡}| jjdd|d�}|j ¡ }|  t|ƒtj	j
¡ |  | ¡ ¡ |  | ¡ d¡ |  | ¡ tj	j¡ t |j¡}|  |jd¡ |  |jd¡ dS )zK Fixed-length bytes dataset maps to fixed-length ascii in the file
        rª  r  r‘   rG   r8   rº  N)rA   r@   r   r    ri   rk   r*   r  r\   r   rm   ZassertFalsero   rp   rn   rw   r¾  r¼  rr   r¿  r   r   r   Útest_fixed_ascii1  s    

zTestStrings.test_fixed_asciic                 C   s  t jddd�}| jjdd|d�}|j ¡ }|  | ¡ t jj	¡ d}| 
d¡|d< ||d	< ||g|d
d…< tj||gtd�|dd…< tj| 
d¡gd
 |d�|dd…< |  t¡�* tj||gdd�|dd…< W d   ƒ n1 sÞ0    Y  tj |d d… tj| 
d¡gd dd�¡ d S )NrÀ  r›   )r¼  rr   r  r‘   rG   õ   cÃ¹r   r   rP   r   r7   é   ÚUr8   ÚS)r\   r½  r   r    ri   rk   r*   rn   r   r…   ÚencoderA   r�   r‚   rD   rE   r¥   r¦   )r   rû   r%   rs   Úsr   r   r   Útest_fixed_utf8?  s    
"8zTestStrings.test_fixed_utf8c                 C   sJ   t  d¡}|  t¡�" | jjdd|d�}W d  ƒ n1 s<0    Y  dS )zA Fixed-length unicode datasets are unsupported (raise TypeError) z|U10r  r‘   rG   N)rA   r@   rD   rE   r   r    ©r   rû   r%   r   r   r   Útest_fixed_unicodeO  s    
zTestStrings.test_fixed_unicodec                 C   sR   t jdd�}| jjdd|d�}d}||d< |d }|  t|ƒt¡ |  ||¡ dS )	zN writing and reading to vlen bytes dataset preserves type and content
        rº  r»  r  r‘   rG   ó   Helloïr   N)r\   r½  r   r    r*   r  Úbytes©r   rû   r%   rW   Úoutr   r   r   Útest_roundtrip_vlen_bytesU  s    z%TestStrings.test_roundtrip_vlen_bytesc                 C   sR   t  d¡}| jjdd|d�}d}||d< |d }|  t|ƒt j¡ |  ||¡ dS )z[ Writing to and reading from fixed-length bytes dataset preserves
        type and content rª  r  r‘   rG   rË  r   N)rA   r@   r   r    r*   r  rt  rÍ  r   r   r   Útest_roundtrip_fixed_bytes`  s    
z&TestStrings.test_roundtrip_fixed_bytesc                 C   s^   t  ¡ }| jjdd|d�}d}||d< |  |d t¡ | ¡ d }|  |t¡ |  ||¡ d S )Nr  r¯   rG   õ   fÃ ilter   )	r\   r½  r   r    r!   rÌ  Úasstrr#   r*   rÍ  r   r   r   Útest_retrieve_vlen_unicodek  s    z&TestStrings.test_retrieve_vlen_unicodec                 C   sÊ   | j jddt ¡ d�}d}||d< | d¡}|  t¡� |d }W d   ƒ n1 sT0    Y  |  | dd¡d d¡ |  | d	¡d |¡ |  d
t	| ¡ ƒ¡ t
j | ¡ d d… t
j|gtd�¡ d S )Nr  r¯   rG   rÑ  r   rº  ÚignoreZfilteúlatin-1r8   r   )r   r    r\   r½  rÒ  rD   ÚUnicodeDecodeErrorr*   r{  rå   rA   r¥   r¦   r�   r‚   )r   r%   rW   Zstrwrap1rÎ  r   r   r   Ú
test_asstru  s    
&ÿzTestStrings.test_asstrc                 C   sÈ   t jdd�}| jjdd|d�}d}tj| d¡|d�|d< |  |d tj¡ | 	¡ d }|  |t
¡ |  ||¡ |  | 	d	d
¡d d¡ |  | 	d¡d |¡ tj | 	¡ d d… tj|gtd�¡ d S )Nr›   rv   r  r¯   rG   rÂ  rÀ  r   rº  rÔ  r~   rÕ  r   )r\   r½  r   r    rA   r�   rÆ  r!   Úbytes_rÒ  r#   r*   r{  r¥   r¦   r‚   rÍ  r   r   r   Útest_asstr_fixed�  s    ÿzTestStrings.test_asstr_fixedc                 C   sV   t  d¡}| jjdd|d�}d}|  t¡� ||d< W d  ƒ n1 sH0    Y  dS )zGEncoding error when writing a non-ASCII string to an ASCII vlen datasetrº  r  r‘   rG   rÑ  r   N)r\   r½  r   r    rD   ÚUnicodeEncodeError)r   rû   r%   rW   r   r   r   Útest_unicode_write_error£  s
    
z$TestStrings.test_unicode_write_errorc                 C   s\   t  ¡ }| jjdd|d�}dtdƒ  d¡}||d< |d }|  t|ƒt¡ |  ||¡ dS )	zJ Writing valid utf-8 byte strings to a unicode vlen dataset is OK
        r  r‘   rG   rp  rq  Úutf8r   N)	r\   r½  r   r    rr  rÆ  r*   r  rÌ  rÍ  r   r   r   Útest_unicode_write_bytes«  s    z$TestStrings.test_unicode_write_bytesc                 C   sV   t  d¡}| jjdd|d�}d}||d< |d }|  t|ƒt¡ |  || d¡¡ dS )z: Writing an ascii str to ascii vlen dataset is OK
        rº  r  r‘   rG   zASCII stringr   N)r\   r½  r   r    r*   r  rÌ  rÆ  rÍ  r   r   r   Útest_vlen_bytes_write_ascii_str¶  s    
z+TestStrings.test_vlen_bytes_write_ascii_strN)r   r   r   r'   ro  rs  rÁ  rÈ  rÊ  rÏ  rÐ  rÓ  r×  rÙ  rÛ  rÝ  rÞ  r   r   r   r   r¹    s   


r¹  c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚTestCompoundz:
        Feature: Compound types correctly round-trip
    c              
   C   s°   t  dt jfdt jfdt jfdt jfdt jfdt jfdt jfg¡}t jd|d	�}|jD ]}t j d¡d
 ||< qV|| jd< | jd d }|  	t  
||k¡¡ |  |j|j¡ dS )z: Compound types are read back in correct order (issue 236)ÚweightZcputimeZwalltimeZparents_offsetZ	n_parentsÚstatusÚendpoint_type©r,  rG   r’   Útest.N)rA   r@   Úfloat64Zuint32Úuint8rö   Úfieldsr?  r   r]   rí   r*   )r   rû   r&  ÚkeyÚoutdatar   r   r   Útest_rtÈ  s    ú

zTestCompound.test_rtc                 C   s´   t  dt jdffdt jfg¡}t jd|d�}|jD ] }t jj|| jd�d ||< q2| jj	dd|d�}|jD ]}|| ||< ql| jd d	 }|  
t  ||k¡¡ |  |j|j¡ d S )
Nrà  ra   râ  rã  rG   rD  r’   rä  .)rA   r@   rå  ræ  rö   rç  r?  r+   r   r    r]   rí   r*   )r   rû   r&  rè  r%   ré  r   r   r   Útest_assignÜ  s    ÿ

zTestCompound.test_assignc                 C   sÎ   t  dt jfdt jfdt jfg¡}t jd|d�}|jD ]}t j d¡d ||< q6|| jd< t j | jd  ddg¡d d … |ddg ¡ t j | jd  d¡d d … |d ¡ t	| jd  d¡ƒdksÊJ ‚d S )	Nr  rl  rm  rã  rG   r’   rä  r,  )
rA   r@   rå  rö   rç  r?  r   r¥   r¦   rå   )r   rû   r&  rè  r   r   r   Útest_fieldsí  s     ý

$ÿÿzTestCompound.test_fieldsN)r   r   r   r'   rê  rë  rì  r   r   r   r   rß  Â  s   rß  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestSubarrayc                 C   sl   | j jdddd�}g d¢|d< tj |d d … g d¢g¡ g d¢g|d d …< tj |d d … g d¢g¡ d S ©Nrz   r/   Z3int8rG   ©r   rP   ra   r   )r   r›   r7   )r   r    rA   r¥   r¦   r$   r   r   r   Útest_write_list  s
    zTestSubarray.test_write_listc                 C   sx   | j jdddd�}t g d¢¡|d< tj |d d … g d¢g¡ t g d¢g¡|d d …< tj |d d … g d¢g¡ d S rî  )r   r    rA   r�   r¥   r¦   r$   r   r   r   Útest_write_array  s
    zTestSubarray.test_write_arrayN)r   r   r   rð  rñ  r   r   r   r   rí    s   rí  c                   @   s,   e Zd ZdZddddœZdd„ Zdd	„ Zd
S )ÚTestEnumzM
        Feature: Enum datatype info is preserved, read/write as integer
    r   r   r   )ÚREDÚGREENÚBLUEc                 C   sD   t j| jdd�}| jjdd|d�}|j}t  |¡}|  || j¡ dS )z= Enum datasets can be created and type correctly round-trips rÿ   ©Zbasetyper  r”  rG   N)r\   Ú
enum_dtypeÚEDICTr   r    r@   Zcheck_enum_dtyper*   )r   rû   r%   Zdt2Zdict2r   r   r   rË   !  s
    
zTestEnum.test_createc                 C   sp   t j| jdd�}| jjdd|d�}d|d< d|dd	d	…f< |  |d d¡ |  |dd	d	…f tjd
dd�¡ d	S )z/ Enum datasets can be read/written as integers rÖ   rö  r  r”  rG   r   )é#   é%   r   N)dr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )	r\   r÷  rø  r   r    r*   rd   rA   r�   rÉ  r   r   r   Útest_readwrite)  s    zTestEnum.test_readwriteN)r   r   r   r'   rø  rË   rû  r   r   r   r   rò    s   rò  c                   @   s:   e Zd ZdZdd„ Ze eedƒd¡dd„ ƒZ	dd	„ Z
d
S )Ú
TestFloatszA
        Test support for mini and extended-precision floats
    c                 C   sJ   | j jdd|d�}|  |j|¡ tjd|d�}||d< |  |d |¡ d S )Nr  r‘   rG   .)r   r    r*   r@   rA   rY   rd   )r   rû   r-   rW   r   r   r   Ú	_exectest9  s
    zTestFloats._exectestÚfloat16zNumPy float16 support requiredc                 C   s   |   t d¡¡ dS )z Mini-floats round trip rþ  N)rý  rA   r@   r   r   r   r   Ú	test_mini@  s    zTestFloats.test_minic                 C   s<   t tdƒr"|  tjjt d¡¡ n|  tjjt d¡¡ dS )z Test mapping for float16 rþ  z<f2z<f4N)rT   rA   r*   r   Z
IEEE_F16LEr@   r   r   r   r   Útest_mini_mappingF  s    
zTestFloats.test_mini_mappingN)r   r   r   r'   rý  r   Ú
skipUnlessrT   rA   rÿ  r   r   r   r   r   rü  3  s
   
rü  c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestTrackTimesz"
        Feature: track_times
    c                 C   s2   | j jdddd�}tj |j¡j}|  d|¡ dS )zC check that when track_times=False, the time stamp=0 (Jan 1, 1970) r   r   F©rz  r   N)r   r    r\   r|  r}  r~  r  r*   )r   r%   Zds_mtimer   r   r   Útest_disable_track_timesT  s    z'TestTrackTimes.test_disable_track_timesc                 C   s@   |   t¡�" | jjdddd� W d  ƒ n1 s20    Y  dS )z3 check that when give track_times an invalid value r   r   Únullr  NrC   r   r   r   r   Útest_invalid_track_timesZ  s    z'TestTrackTimes.test_invalid_track_timesN)r   r   r   r'   r  r  r   r   r   r   r  N  s   r  c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestZeroShapez7
        Features of datasets with (0,)-shape axes
    c                 C   s|   | j jdddd�}|  |jt |¡j¡ | j jdddd�}|  |jt |¡j¡ | j jdd	d
d�}|  |jt |¡j¡ dS )z1 Empty datasets can be converted to NumPy arrays r  r   Nr„  rl  ©r   r   rm  ©r   r   )NN)r   r    r*   r+   rA   r�   r$   r   r   r   Útest_array_conversionf  s    z#TestZeroShape.test_array_conversionc                 C   s~   ddg}| j jdd|dd�}tjd|d�}|  |d j|j¡ |  |d j|j¡ |  |d	 j|j¡ |  |d	 j|j¡ d
S )z- Slicing into empty datasets works correctly )rz   r   )r|   rÿ   r  r  r   rð   rG   .r   N)r   r    rA   Úemptyr*   r+   r@   )r   rû   r%   r¬   r   r   r   Útest_readingq  s    zTestZeroShape.test_readingN)r   r   r   r'   r
  r  r   r   r   r   r  `  s   r  )r   r8   r7   z+Issue with empty region refs in HDF5 1.10.6)Úreasonc                   @   s@   e Zd ZdZdd„ Zdd„ Zedd„ ƒZedd	„ ƒZd
d„ Z	dS )ÚTestRegionRefsz3
        Various features of region references
    c                 C   s@   t  | ¡ t d¡ d¡| _| jjd| jd�| _| j| jd< d S )Ni'  r”  r  rV   .)	r   r   rA   rc   re   rW   r   r    r-   r   r   r   r   r   ˆ  s    
zTestRegionRefs.setUpc                 C   s@   t jdd…ddd…f }| jj| }|  | j| | j| ¡ dS )z4 Region references can be used as slicing arguments rw  rù  r8   r’   r›   N)rA   r´   r-   Ú	regionrefrd   rW   ©r   ZslicÚrefr   r   r   Útest_create_refŽ  s    zTestRegionRefs.test_create_refc                 C   s,   | j jd d… }| j | }|jdks(J ‚d S )Nr   )r-   r  r;   )r   r  rÎ  r   r   r   Útest_empty_region”  s    
z TestRegionRefs.test_empty_regionc                 C   s–   | j jdddd�}tj tjj¡}| ¡  tj |jdtjj	|¡}|| t 
t d¡¡ks^J ‚| ¡  tj |jdtjj	|¡}|| |d ks’J ‚d S )NZscalarç      ð?rù   ©rW   r@   ó   .r   )r   r    r\   Zh5sÚcreateZSCALARZselect_noneZh5rri   ZDATASET_REGIONrŒ   rA   r@   Z
select_all)r   r%   Zsidr  r   r   r   Útest_scalar_dataset›  s    z"TestRegionRefs.test_scalar_datasetc                 C   sX   t jdd…ddd…f }| jj| }|  | jj |¡| jj¡ |  | jj |¡d¡ dS )z, Region reference shape and selection shape rw  rù  r8   r’   r›   )r8   é   N)rA   r´   r-   r  r*   r+   Z	selectionr  r   r   r   Útest_ref_shapeª  s    zTestRegionRefs.test_ref_shapeN)
r   r   r   r'   r   r  Úempty_regionref_xfailr  r  r  r   r   r   r   r  ‚  s   

r  c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú
TestAstypez(.astype() wrapper & context manager
    c              	   C   sþ   | j jdddd�}t d¡|d< tjdd��¢}t d	¡ | d
¡�* |  |d tjdd
d�¡ W d   ƒ n1 sr0    Y  | d¡�*}|  |d tjddd�¡ W d   ƒ n1 s¶0    Y  W d   ƒ n1 sÔ0    Y  dd„ |D ƒt	gd ksúJ ‚d S )Nr  r‘   r×   rG   r’   .T)ÚrecordÚalwaysr  rù   c                 S   s   g | ]
}|j ‘qS r   )Úcategory)r_  r   r   r   r   r·  Â  rb  z.TestAstype.test_astype_ctx.<locals>.<listcomp>rP   )
r   r    rA   rc   ÚwarningsÚcatch_warningsÚsimplefilterÚastyperd   r   )r   r-   Zwarn_recZf4dsr   r   r   Útest_astype_ctxµ  s    
8VzTestAstype.test_astype_ctxc                 C   sL   | j jdddd�}t d¡|d< | d¡d d … }|  |tjddd�¡ d S ©Nr  r‘   r×   rG   r’   .rù   )r   r    rA   rc   r#  rd   )r   r-   r¬   r   r   r   Útest_astype_wrapperÄ  s    zTestAstype.test_astype_wrapperc                 C   s:   | j jdddd�}t d¡|d< |  dt| d¡ƒ¡ d S r%  )r   r    rA   rc   r*   rå   r#  r,   r   r   r   Útest_astype_wrapper_lenË  s    z"TestAstype.test_astype_wrapper_lenN)r   r   r   r'   r$  r&  r'  r   r   r   r   r  ²  s   r  c                   @   s   e Zd ZdZdd„ ZdS )ÚTestScalarCompoundzl
        Retrieval of a single field from a scalar compound dataset should
        strip the field info
    c                 C   s:   t  dg¡}| jjdd|d�}|  |d jt  d¡¡ d S )Nrþ   r  r   rG   rz   rÿ   )rA   r@   r   r    r*   )r   rû   r-   r   r   r   Útest_scalar_compoundØ  s    z'TestScalarCompound.test_scalar_compoundN)r   r   r   r'   r)  r   r   r   r   r(  Ñ  s   r(  c                   @   sf   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zddd„Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚTestVlenc                 C   sR  t  t¡}| jjdd|d�}t d¡|d< t d¡|d< g d¢|d< t d¡|d< |  |d t d¡¡ |  |d t d¡¡ |  |d t g d¢¡¡ |  |d t d¡¡ tjt d	¡t d
¡gt	d�|dd…< |  |d t d	¡¡ |  |d t d
¡¡ t t d¡t d¡g¡|dd…< |  |d t d¡¡ |  |d t d¡¡ d S )NÚvlenr   rG   ra   r   r   rï  rP   r›   r   )
r\   Ú
vlen_dtyperF  r   r    rA   rc   rd   r�   r‚   rÉ  r   r   r   rI  à  s     
&"zTestVlen.test_intc                 C   s6   t  t¡}| jjdd|d�}| j dd|d j¡ d S )Nr+  r/   rG   Úvlen2r   )r\   r,  rF  r   r    r@   rÉ  r   r   r   Útest_reuse_from_otherò  s    
zTestVlen.test_reuse_from_otherc                 C   sl   dt fdt t ¡fg}| jjdd|d�}| jj}| j ¡  t |d¡| _| j dd| jd d d j¡ d S )Nrz   r|   r+  r/   rG   r-  r   )	rF  r\   r,  r   r    rA  r   r   r@   )r   rû   r%   Úfnamer   r   r   Útest_reuse_struct_from_other÷  s    
z%TestVlen.test_reuse_struct_from_otherc                 C   s@  t  t¡}| jjdd|d�}t ddg¡|d< t dg¡|d< g d¢|d	< |  |d t ddg¡¡ |  |d t dg¡¡ |  |d	 t g d
¢¡¡ tjg d¢t d¡gt	d�|dd	…< |  |d t d¡¡ |  |d t d¡¡ t t g d¢¡t g d¢¡g¡|dd	…< |  |d t d¡¡ |  |d t d¡¡ d S )Nr+  rç   rG   gffffffö?ç333333ó?r   r   )r1  rP   ra   rP   rï  )çš™™™™™¹?gš™™™™™ñ?gÍÌÌÌÌÌ @gÍÌÌÌÌÌ@r   r   r›   )r2  r1  çš™™™™™@)gš™™™™™É?r1  r3  ra   )
r\   r,  rF  r   r    rA   r�   rd   rc   r‚   rÉ  r   r   r   Útest_convertÿ  s     
$ÿzTestVlen.test_convertc                 C   s®   t  t¡}| jjdd|d�}t d¡|d< tjt d¡t d¡gt d¡t d¡ggtd�|d d …d d …f< t t d¡t d¡gt d¡t d¡gg¡|d d …d d …f< d S )Nr+  )rP   rP   rG   r   r	  ra   rP   )	r\   r,  rF  r   r    rA   rc   r�   r‚   rÉ  r   r   r   Útest_multidim  s    
ÿÿÿzTestVlen.test_multidimr+  c                 C   sP  t  |¡}| jj|d|d�}tjg d¢|d�}tjg d¢|d�}tjg d¢t d¡d�}| |¡}g d¢}	tj|	|d�}
g d¢}tj||d�}||d	< ||d
< ||d< |	|d< ||d< |  ||d	 ¡ |  ||d
 ¡ |  ||d ¡ |  |
|d ¡ |  ||d ¡ tjddg|d�}
|
dd… |d	< |  |
|d	 ¡ | j 	¡  | j 
¡  dS )z¿
        Helper for testing various vlen numpy data types.
        :param np_dt: Numpy datatype to test
        :param dataset_name: String name of the dataset to create for testing.
        r©  rG   )r  ç       @g      >@)g33333Y@gÍÌÌÌÌi@gfffff†X@g      %Àg     ÀrÀ)r   rP   rÃ  rÃ   )r  r6  g      Œ@ç        g      à¿)r    iœÿÿÿr   r   i'  r•   r   r   rP   ra   r   g333333Ó?r3  N)r\   r,  r   r    rA   r�   r@   r#  rd   r%  r   )r   Únp_dtZdataset_namerû   r%   Zarray_0Zarray_1Zarray_2Zcasted_array_2Zlist_3Zlist_array_3Zlist_4Zlist_array_4r   r   r   Ú_help_float_testing  s2    


zTestVlen._help_float_testingc                 C   s   t  d¡}|  |¡ d S )Nrþ  ©rA   r@   r9  ©r   r8  r   r   r   Útest_numpy_float16I  s    
zTestVlen.test_numpy_float16c                 C   s   t  d¡}|  |¡ d S )NÚfloat32r:  r;  r   r   r   Útest_numpy_float32M  s    
zTestVlen.test_numpy_float32c                 C   s   t  d¡}|  |¡ d S )Nrå  r:  r;  r   r   r   Útest_numpy_float64_from_dtypeQ  s    
z&TestVlen.test_numpy_float64_from_dtypec                 C   s   t j}|  |¡ d S r   )rA   rå  r9  r;  r   r   r   Útest_numpy_float64_2U  s    zTestVlen.test_numpy_float64_2c                 C   s  | j jddt d¡d� t g d¢¡}|ddd… | j d d< t| j d d |ddd… kƒs„J | j d d › d	|ddd… › �ƒ‚| j jd
dt d¡d� t g d¢¡}|ddd… | j d
 d< t| j d
 d |ddd… kƒ�s
J | j d
 d › d	|ddd… › �ƒ‚dS )z4Test that non-contiguous arrays are stored correctlyZncr¯   r;  rG   )TFTTFFFNrP   r   z != Znc2Zint8)rP   r   r   r›   r    ra   rœ   )r   r    r\   r,  rA   r�   rí   )r   r  rl  r   r   r   Útest_non_contiguous_arraysY  s    Fz#TestVlen.test_non_contiguous_arraysN)r+  )r   r   r   rI  r.  r0  r4  r5  r9  r<  r>  r?  r@  rA  r   r   r   r   r*  ß  s   	
0r*  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestLowOpenc                 C   s   | j  dd¡}|j ¡ }dS )z Test H5Dget_access_plist r   r   N)r   r    ri   Zget_access_plist)r   r%   Zp_listr   r   r   Útest_get_access_listj  s    z TestLowOpen.test_get_access_listc                 C   sH   t j t jj¡}| j dd¡}~t j | jjd|¡}|  	|t jj
¡ dS )z# Test the dapl keyword to h5d.open r  r‘   ó   xN)r\   Zh5pr  ZDATASET_ACCESSr   r    Zh5drR  ri   r!   Z	DatasetID)r   Zdaplr-   Zdsidr   r   r   Ú	test_daplo  s
    zTestLowOpen.test_daplN)r   r   r   rC  rE  r   r   r   r   rB  h  s   rB  )r   r8   r›   z#chunk info requires  HDF5 >= 1.10.5c               	   C   sj  ddl m}  | ƒ }t |d¡�2}|jddddd� d	|d d d …< W d   ƒ n1 sV0    Y  | d¡ t |d
¡�Þ}|d j}| ¡ dks’J ‚tdƒD ]`}t	t
 t
 |d¡¡d ƒ}| |¡}|j|ksÐJ ‚|jdksÞJ ‚|jd usìJ ‚|jdksšJ ‚qš| d¡}|jdk�sJ ‚|jdk�s&J ‚|jd u�s6J ‚|jdk�sFJ ‚W d   ƒ n1 �s\0    Y  d S )Nr   ©ÚBytesIOr   rä  r”  r[   rÖ   )r+   rÛ   r@   r   r>  r’   r8   r	  )ÚiorG  r\   r   r    Úseekri   Zget_num_chunksrB  rä   rA   r�   Zunravel_indexZget_chunk_infoZchunk_offsetZfilter_maskZbyte_offsetr;   Zget_chunk_info_by_coord)rG  ÚbufÚfoutÚfinr%   ÚjÚoffsetÚsir   r   r   Útest_get_chunk_detailsx  s*    .



rP  c                 C   s.   | j ddd�}|jd u sJ ‚|jd u s*J ‚d S )Nr  rÃ   rG   )r    r+   rá   )r§   r%   r   r   r   Útest_empty_shape–  s    rQ  c                  C   sÄ   ddl m}  | ƒ }t |d¡�}|jddd� W d   ƒ n1 sB0    Y  | d¡ t |d¡�N}|d jd u svJ ‚|d j ¡ d u sŒJ ‚|d j 	¡ dks¢J ‚W d   ƒ n1 s¶0    Y  d S )Nr   rF  r   r  ræ  rG   r>  )
rH  rG  r\   r   r    rI  rÛ   ri   Z
get_offsetZget_storage_size)rG  rJ  rK  rL  r   r   r   Útest_zero_storage_sizeœ  s    ,
rR  c                 C   sœ   t  t j¡jt  t j¡jd g}| jd|t jd�}|jt  t j¡ksHJ ‚t j |d d … t j	|t jd�¡ ||d d …< t j |d d … t j	|t jd�¡ d S )Nr   r  r  rG   )
rA   ZiinforŸ   Úmaxr    Zuint64r@   r¥   r¦   r�   )r§   rW   r%   r   r   r   Útest_python_int_uint64ª  s     "rT  c                 C   s<   | j ddtjd�}tjjddd�}||d d …g d¢df< d S )	NrW   )r›   r]  rP   rG   éÿ   )r›   ra   rP   rD  )r   rP   r   .)r    rA   ræ  r?  rE  )r§   r¬   Úblockr   r   r   Útest_setitem_fancy_indexing¸  s    rW  c                  C   sD   t tdƒƒ�$} | d d dks"J ‚W d   ƒ n1 s60    Y  d S )Nzvlen_string_dset.h5ZDS1r   s   Parting©r   r   ©r   r   r   r   Útest_vlen_spacepad¿  s    rZ  c                  C   sD   t tdƒƒ�$} | d d dks"J ‚W d   ƒ n1 s60    Y  d S )Nzvlen_string_dset_utc.h5Zds1r   s   2009-12-20T10:16:18.662409ZrX  rY  r   r   r   Útest_vlen_nulltermÄ  s    r[  )r   r8   ra   z>Appears you cannot pass an unknown filter id for HDF5 < 1.10.3c                 C   s0   d}| j ddtj|dd�}t|ƒ|jv s,J ‚d S )Né   rW   r[   T)r+   r@   r  Zallow_unknown_filter)r    rA   ræ  r#   Ú_filters)r§   Zfake_filter_idr%   r   r   r   Útest_allow_unknown_filterÉ  s    
þr^  c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestCommutativez|
    Test the symmetry of operators, at least with the numpy types.
    Issue: https://github.com/h5py/h5py/issues/1947
    c                 C   s¬   d}| j jd|ttjj|Ž d�}t |d ¡}t ||k||kk¡sHJ ‚t ||k||kk¡sbJ ‚d}t |¡| }t ||k||kk¡sŽJ ‚t ||k||kk¡s¨J ‚dS )z‹
        Create a h5py dataset, extract one element convert to numpy
        Check that it returns symmetric response to == and !=
        ©r’   r   rä  ©r@   rW   r   gü©ñÒMbP?N)	r   r    r8  rA   r?  r@  rå  rí   Znanmax)r   r+   r-   ÚvalÚdeltaÚnvalr   r   r   Útest_numpy_commutativeÜ  s    
ÿz&TestCommutative.test_numpy_commutativec                 C   sT   d}| j jd|ttjj|Ž d�}tdƒ}||k||kks<J ‚||k||kksPJ ‚dS )z¦
        Create a h5py dataset and check basetype compatibility.
        Check that operation is symmetric, even if it is potentially
        not meaningful.
        r`  rä  ra  r7  N)r   r    r8  rA   r?  r@  )r   r+   r-   rb  r   r   r   Útest_basetype_commutativeô  s    
ÿz)TestCommutative.test_basetype_commutativeN)r   r   r   r'   re  rf  r   r   r   r   r_  ×  s   r_  )Sr'   rZ  r°  ÚnumpyrA   rI   rK   r   Úcommonr   r   Ú
data_filesr   r\   r   r   r   Zh5py._hl.baser	   r
   r   Zh5py.h5py_warningsr   Zh5py._hl.selectionsr  Ú
selectionsÚselr   r   r(   rU   r�   rÂ   rÉ   rÙ   ró   r  rS   ÚfiltersrÆ  r  r  r#  r+  r/  r2  r5  rM  rh  rv  rˆ  r˜  r¨  r¬  r´  r¹  rß  rí  rò  rü  r  r  rÀ   rL   ÚversionZhdf5_version_tupler  r  r  r(  r*  rB  r  rP  rQ  rR  rT  rW  rZ  r[  Zskipifr^  r_  r   r   r   r   Ú<module>
   s    		FY0(CC&,'q>,D -E
þ0 
ÿ

þ

