3
_½µ_Rì  ã               @   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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Zddljj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eƒ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eƒZ!ej"dej#j$kdƒG dd „ d eƒƒZ%ej"dej#j$kdƒG d!d"„ d"eƒƒZ&ej"d#ej#j$kd$ƒG d%d&„ d&eƒƒZ'ej"d'ej#j$kd(ƒG d)d*„ d*eƒƒZ(ej"d+ej#j$kd,ƒG d-d.„ d.eƒƒZ)ej"d/ej#j$kd0ƒG d1d2„ d2eƒƒZ*ej"d3ej#j$kd4ƒG d5d6„ d6eƒƒZ+G d7d8„ d8eƒZ,G d9d:„ d:eƒZ-G d;d<„ d<eƒZ.G d=d>„ d>eƒZ/G d?d@„ d@eƒZ0G dAdB„ dBeƒZ1G dCdD„ dDeƒZ2G dEdF„ dFeƒZ3G dGdH„ dHeƒZ4G dIdJ„ dJeƒZ5G dKdL„ dLeƒZ6G dMdN„ dNeƒZ7G dOdP„ dPeƒZ8G dQdR„ dReƒZ9G dSdT„ dTeƒZ:ej;j<ej=j>dwkdWdX�Z?G dYdZ„ dZeƒZ@G d[d\„ d\eƒZAG d]d^„ d^eƒZBG d_d`„ d`eƒZCG dadb„ dbeƒZDejEej=j>dxkddƒdedf„ ƒZFdgdh„ ZGdidj„ ZHdkdl„ ZIdmdn„ ZJdodp„ ZKdqdr„ ZLej;jMej=j>dyk dtdX�dudv„ ƒZNdS )zzü
    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Úh5tc               @   s   e Zd Zdd„ Zdd„ ZdS )ÚBaseDatasetc             C   s   t | jƒ dƒ| _d S )NÚw)r   ÚmktempÚf)Úself© r   ú9/tmp/pip-install-xpigntgx/h5py/h5py/tests/test_dataset.pyÚsetUp#   s    zBaseDataset.setUpc             C   s   | j r| j jƒ  d S )N)r   Úclose)r   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 jddƒ}| jt|ƒtƒ | j jƒ  | jt|ƒtƒ dS )z( repr() works on live and dead datasets Úfooé   N)r   )r   Úcreate_datasetÚassertIsInstanceÚreprÚstrr   )r   Údsr   r   r   Útest_repr_open0   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j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 jdf ƒ}| j|jf ƒ dS )z Create a scalar dataset r   N)r   r   ÚassertEqualÚshape)r   Údsetr   r   r   Útest_create_scalar>   s    z"TestCreateShape.test_create_scalarc             C   s    | j jddƒ}| j|jdƒ dS )z Create a size-1 dataset r   r   N)r   )r   )r   r   r$   r%   )r   r&   r   r   r   Útest_create_simpleC   s    z"TestCreateShape.test_create_simplec             C   s    | j jddƒ}| j|jdƒ dS )z+ Create a size-1 dataset with integer shaper   r   N)r   )r   r   r$   r%   )r   r&   r   r   r   Útest_create_integerH   s    z#TestCreateShape.test_create_integerc             C   sX   | j jddƒ}| j|jd	ƒ | j|jdƒ | j jdd
ƒ}| j|jdƒ | j|jdƒ dS )z Create an extended dataset r   é?   Úbaré   é
   é<   N)r*   )r*   )r,   r-   )r,   r-   )r   r   r$   r%   Úsize)r   r&   r   r   r   Útest_create_extendedM   s    z$TestCreateShape.test_create_extendedc             C   sX   | j jddƒ}| j|jdƒ | j|jdƒ | j jdd	ƒ}| j|jd
ƒ | j|jdƒ dS )z Create an extended dataset r   r*   r+   r,   r-   r.   N)r*   )r,   r-   )r,   r-   )r   r   r$   r%   r/   )r   r&   r   r   r   Útest_create_integer_extendedV   s    z,TestCreateShape.test_create_integer_extendedc             C   s&   | j jddƒ}| j|jtjdƒƒ dS )z) Confirm that the default dtype is float r   r*   z=f4N)r*   )r   r   r$   ÚdtypeÚnp)r   r&   r   r   r   Útest_default_dtype_   s    z"TestCreateShape.test_default_dtypec          	   C   s&   | j tƒ� | jjdƒ W dQ R X dS )z  Missing shape raises TypeError r   N)ÚassertRaisesÚ	TypeErrorr   r   )r   r   r   r   Útest_missing_shaped   s    z"TestCreateShape.test_missing_shapec             C   sF   | j jddtjd�}tjƒ dkr2tjdtjƒ  ƒ | j|j	tjƒ dS )	z) Confirm that the default dtype is float r   r*   )r2   Úppc64lez(Storage of long double deactivated on %sN)r*   )r8   )
r   r   r3   Z
longdoubleÚplatformÚmachineÚpytestÚxfailr$   r2   )r   r&   r   r   r   Útest_long_doublei   s    z TestCreateShape.test_long_doubleÚ
complex256zNo support for complex256c             C   s0   | j jddtjdƒd�}| j|jtjdƒƒ dS )z) Confirm that the default dtype is float r   r*   r>   )r2   N)r*   )r   r   r3   r2   r$   )r   r&   r   r   r   Útest_complex256p   s    
zTestCreateShape.test_complex256c             C   s<   | j jddƒ}| j|jdƒ | j jddƒ}| j|jdƒ d S )	Ns   foor   s   bar/bazé   )r   )r   )r@   )r@   )r   r   r$   r%   )r   r&   Údset2r   r   r   Útest_name_bytesw   s    zTestCreateShape.test_name_bytesN)r   r   r   r"   r'   r(   r)   r0   r1   r4   r7   r=   r   ÚskipIfÚhasattrr3   r?   rB   r   r   r   r   r#   8   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 jf dƒ}| jjd|d�}| j|j|jƒ dS )z- Create a scalar dataset from existing array r   r   )ÚdataN)r3   Úonesr   r   r$   r%   )r   rF   r&   r   r   r   r'   „   s    z!TestCreateData.test_create_scalarc             C   s0   t jddƒ}| jjd|d�}| j|j|jƒ dS )z/ Create an extended dataset from existing data r*   r   r   )rF   N)r*   )r3   rG   r   r   r$   r%   )r   rF   r&   r   r   r   r0   Š   s    z#TestCreateData.test_create_extendedc             C   s4   | j jdddd�}| j|tjƒ | jd| j kƒ dS )z1 Create dataset with missing intermediate groups z/foo/bar/bazr-   z<i4)r%   r2   N)r-   r-   )r   r   r   Úh5pyr   Ú
assertTrue)r   r    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|jdƒ | j|d |jdƒƒ d	S )z8 Create from existing data, and make it fit a new shape é   r   )r2   r   r-   é   )r%   rF   .N)r-   rL   )r-   rL   )r-   rL   )r3   Úaranger   r   r$   r%   ÚassertArrayEqualÚreshape)r   rF   r&   r   r   r   Útest_reshape–   s    zTestCreateData.test_reshapec          
   C   s*   | j tƒ� t| jd jƒ W dQ R X dS )zE Binding Dataset to a non-DatasetID identifier fails with ValueError ú/N)r5   Ú
ValueErrorr   r   Úid)r   r   r   r   Útest_appropriate_low_level_id�   s    z,TestCreateData.test_appropriate_low_level_idc             C   sb   |j jƒ }t|tjƒst‚|jƒ |ks*t‚|d kr@|jƒ s^t‚n|jƒ  sNt‚|jƒ |ks^t‚d S )N)	rS   Úget_typeÚ
isinstancer   ÚTypeStringIDÚAssertionErrorÚ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)r]   )r_   r   Ú
CSET_ASCII)r&   )r   r   r   Úcheck_vlen_ascii®   s    z?TestCreateData.test_create_bytestring.<locals>.check_vlen_asciiÚas   abc)rF   Úbs   defÚcÚd)r2   N)r   r   r3   ÚarrayÚobject)r   ra   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 )	Nrb   s   abcs   defZS3)r2   )rF   rL   )r]   )r   r   r3   rf   r_   r   r`   )r   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 )N)r]   )r_   r   Ú	CSET_UTF8)r&   )r   r   r   Úcheck_vlen_utf8¼   s    z;TestCreateData.test_create_strings.<locals>.check_vlen_utf8rb   Úabc)rF   rc   Údefrd   re   )r2   )r   r   r3   rf   rg   )r   rk   r   )r   r   Útest_create_strings»   s    z"TestCreateData.test_create_stringsc             C   s8   | j tƒ�$ | jjdtjddgdd�d� W d Q R X d S )Nrb   s   abcs   defZU3)r2   )rF   )r5   r6   r   r   r3   rf   )r   r   r   r   Útest_create_np_uÅ   s    zTestCreateData.test_create_np_uc             C   s*   | j jddd� | jt| j d jƒƒ d S )Nr   r   )r2   )r   r   rI   r	   rS   )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� | jt| j d jƒƒ d S )Nr   r   )r2   )rF   )r   r   rH   ÚEmptyrI   r	   rS   )r   r   r   r   Ú!test_empty_create_via_Empty_classÍ   s    z0TestCreateData.test_empty_create_via_Empty_classc             C   s2   | j tƒ� | jjddtjdƒd� W d Q R X d S )Nr+   r   rL   )r%   rF   )r5   rR   r   r   r3   rM   )r   r   r   r   Útest_create_incompatible_dataÑ   s    z,TestCreateData.test_create_incompatible_dataN)r   r   r   r"   r'   r0   rJ   rP   rT   r_   rh   ri   rn   ro   rp   rr   rs   r   r   r   r   rE   ~   s   

rE   c               @   s   e Zd ZdZdd„ ZdS )ÚTestReadDirectlyzI
        Feature: Read data directly from Dataset into a Numpy array
    c             C   sÖ   | j jdddd�}| j jddd�}tjdƒ}tjdƒ}| jtƒ�( |j|tjdd… tjd	d
… ƒ W d Q R X |j|tjdd… tjd	d
… ƒ x |d	d
… D ]}| j|dƒ qžW | jtƒ� |j|ƒ W d Q R X d S )Nr&   éd   Úint64)r2   ÚedsetéÈ   r   r-   é2   r.   )ru   )ru   )rx   )	r   r   r3   rG   r5   r6   Zread_directÚs_r$   )r   r&   Ú
empty_dsetÚarrÚarr2Úer   r   r   Útest_read_directÝ   s    

,"z!TestReadDirectly.test_read_directN)r   r   r   r"   r   r   r   r   r   rt   ×   s   rt   c               @   s   e Zd ZdZdd„ ZdS )ÚTestWriteDirectlyz>
        Feature: Write Numpy array directly into Dataset
    c             C   sÖ   | j jdddd�}| j jddd�}tjdƒ}tjdƒ}| jtƒ�( |j|tjdd	… tjd
d… ƒ W d Q R X |j|tjdd	… tjd
d… ƒ x |d
d… D ]}| j|dƒ qžW | jtƒ� |j|ƒ W d Q R X d S )Nr&   ru   Úint32)r2   rw   rv   rx   r   r-   ry   r.   r   )ru   )ru   )rx   )	r   r   r3   rG   r5   r6   Zwrite_directrz   r$   )r   r&   r{   r|   r}   r~   r   r   r   Útest_write_directõ   s    

,"z#TestWriteDirectly.test_write_directN)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 jdddƒ}| j|tƒ | j|jdƒ dS )z& Create new dataset with no conflicts r   r-   rL   r   N)r-   rL   )r-   rL   )r   Úrequire_datasetr   r   r$   r%   )r   r&   r   r   r   Útest_create  s    zTestCreateRequire.test_createc             C   s0   | j jdddƒ}| j jdddƒ}| j||ƒ dS )z) require_dataset yields existing dataset r   r-   rL   r   N)r-   rL   )r-   rL   )r   r„   r$   )r   r&   rA   r   r   r   Útest_create_existing  s    z&TestCreateRequire.test_create_existingc             C   sˆ   | j jdddƒ}| j jdddƒ}| j||ƒ | j jdddƒ}| j jdddƒ}| j||ƒ | j jdddƒ}| j jdd	dƒ}| j||ƒ dS )
z; require_dataset with integer shape yields existing datasetr   r-   r   r+   Zbazs   bazN)r-   )r-   )r   r„   r$   )r   r&   rA   r   r   r   Útest_create_1D  s    z TestCreateRequire.test_create_1Dc             C   s:   | j jdddƒ | jtƒ� | j jdddƒ W dQ R X dS )	z6 require_dataset with shape conflict yields TypeError r   r-   rL   r   r   N)r-   rL   )r-   r   )r   r   r5   r6   r„   )r   r   r   r   Útest_shape_conflict(  s    z%TestCreateRequire.test_shape_conflictc             C   s6   | j jdƒ | jtƒ� | j jdddƒ W dQ R X dS )z< require_dataset with object type conflict yields TypeError r   r-   rL   r   N)r-   rL   )r   Zcreate_groupr5   r6   r„   )r   r   r   r   Útest_type_conflict.  s    z$TestCreateRequire.test_type_conflictc             C   s:   | j jdddƒ}| jtƒ� | j jdddƒ W dQ R X dS )	zL require_dataset with dtype conflict (strict mode) yields TypeError
        r   r-   rL   r   ZS10N)r-   rL   )r-   rL   )r   r   r5   r6   r„   )r   r&   r   r   r   Útest_dtype_conflict4  s    z%TestCreateRequire.test_dtype_conflictc             C   s4   | j jdddƒ}| j jdd	ddd�}| j||ƒ dS )
z* require_dataset with exactly dtype match r   r-   rL   r   T)ÚexactN)r-   rL   )r-   rL   )r   r   r„   r$   )r   r&   rA   r   r   r   Útest_dtype_exact;  s    z"TestCreateRequire.test_dtype_exactc             C   sH   | j jdd	dƒ}| j jdd
ddd�}| j||ƒ | j|jtjdƒƒ dS )zJ require_dataset with convertible type succeeds (non-strict mode)
        r   r-   rL   Úi4Úi2F)r‹   N)r-   rL   )r-   rL   )r   r   r„   r$   r2   r3   )r   r&   rA   r   r   r   Útest_dtype_closeB  s    z"TestCreateRequire.test_dtype_closeN)r   r   r   r"   r…   r†   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S )ÚTestCreateChunkedzL
        Feature: Datasets can be created by manually specifying chunks
    c             C   s$   | j jdddd�}| j|jdƒ dS )	z Create via chunks tuple r   ru   r-   )r%   ÚchunksN)ru   )r-   )r-   )r   r   r$   r‘   )r   r&   r   r   r   Útest_create_chunksQ  s    z$TestCreateChunked.test_create_chunksc             C   s$   | j jdddd�}| j|jdƒ dS )z Create via chunks integer r   ru   r-   )r%   r‘   N)ru   )r-   )r   r   r$   r‘   )r   r&   r   r   r   Útest_create_chunks_integerV  s    z,TestCreateChunked.test_create_chunks_integerc             C   s,   | j tƒ� | jjdddd� W dQ R X dS )z& Illegal chunk size raises ValueError r   ru   rx   )r%   r‘   N)ru   )rx   )r5   rR   r   r   )r   r   r   r   Útest_chunks_mismatch[  s    z&TestCreateChunked.test_chunks_mismatchc             C   s.   | j tƒ� | jjddddd� W dQ R X dS )z3 Chunked format required for given storage options r   r-   ru   F)r%   Úmaxshaper‘   N)r-   )r5   rR   r   r   )r   r   r   r   Útest_chunks_false`  s    z#TestCreateChunked.test_chunks_falsec             C   s,   | j tƒ� | jjdf dd� W dQ R X dS )z> Attempting to create chunked scalar dataset raises TypeError r   ry   )r%   r‘   N)ry   )r5   r6   r   r   )r   r   r   r   Útest_chunks_scalare  s    z$TestCreateChunked.test_chunks_scalarc             C   s6   | j jdddd�}| j|jtƒ | jt|jƒdƒ dS )	z Auto-chunking of datasets r   é   ru   T)r%   r‘   r@   N)r˜   ru   )r   r   r   r‘   Útupler$   Úlen)r   r&   r   r   r   Útest_auto_chunksj  s    z"TestCreateChunked.test_auto_chunksc             C   s&   | j jddddd�}| j|jd	ƒ dS )
z7 Auto-chunking with pathologically large element sizes r   rL   Z
S100000000T)r%   r2   r‘   r   N)rL   )r   )r   r   r$   r‘   )r   r&   r   r   r   Útest_auto_chunks_abusep  s    z(TestCreateChunked.test_auto_chunks_abusec             C   s–   | j jddtjdd�}d|ddd…df< | jtj|ddd…df dkƒƒ d	|d< | jtj|d d	kƒƒ d
|dd…< | jtj|dd… d
kƒƒ dS )z+ Test scalar assignment of chunked dataset r   rL   ry   r   )r%   r2   r‘   r-   Né(   é   é   r   r@   )rL   ry   ry   )r   ry   ry   )r   r   r3   r�   rI   Úall)r   r&   r   r   r   Útest_scalar_assignmentu  s    
"z(TestCreateChunked.test_scalar_assignmentc             C   s\   t jtdd��}| jjdddd� W dQ R X t jtdd��}| jjdddd	� W dQ R X dS )
z, Auto-chunking of empty datasets not allowedrq   )Úmatchr   ZS100T)r2   r‘   Nr˜   )r2   r•   )r;   Zraisesr6   r   r   )r   Úerrr   r   r   Útest_auto_chunks_no_shape…  s    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�   K  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�}| j|d dƒ | j|d dƒ dS )	z- Fill value is reflected in dataset contents r   r-   g      @)Ú	fillvaluer   é   N)r-   )r   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|jdƒ | j|jtjƒ dS )z( Fill value is recoverable via property r   r-   g      @)r¦   N)r-   )r   r   r$   r¦   ZassertNotIsInstancer3   Úndarray)r   r&   r   r   r   Útest_propertyš  s    z!TestCreateFillvalue.test_propertyc             C   s    | j jddƒ}| j|jdƒ dS )z0 .fillvalue property works correctly if not set r   r-   r   N)r-   )r   r   r$   r¦   )r   r&   r   r   r   Útest_property_none   s    z&TestCreateFillvalue.test_property_nonec             C   sV   t jddgƒ}t jd|d�d }| jjdd||d
�}| j|j|ƒ | j|d |ƒ dS )z& Fill value works with compound types rb   Úf4rc   Úi8r   )r2   r   r   r-   )r2   r¦   r   N)rb   r¬   )rc   r­   )r   )r-   )r3   r2   rG   r   r   r$   r¦   ZassertAlmostEqual)r   ÚdtÚvr&   r   r   r   Útest_compound¥  s
    z!TestCreateFillvalue.test_compoundc             C   s2   | j tƒ� | jjdd
ddgdd�}W d	Q R X d	S )z# Bogus fill value raises TypeError r   r-   rb   Úirc   r   é*   )r2   r¦   N)r-   )rb   r±   )rc   r   )r5   rR   r   r   )r   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 jdƒ| jd< | jjdd| jd d�}| j|jt jdƒƒ | j|jjƒ | jd jƒ | j|jjƒ jƒ ƒ dS )z7 Named type object works and links the dataset to type Úf8ÚtypeÚxru   )r2   N)ru   )	r3   r2   r   r   r$   rS   rU   rI   Z	committed)r   r&   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|jdƒ | j|jdƒ dS )	z# Create with explicit gzip options r   r˜   rK   r¹   é	   )ÚcompressionÚcompression_optsN)r˜   rK   )r   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|jdƒ | j|jdƒ dS )	z+ Create with implicit gzip level (level 4) r   r˜   rK   r¹   )r¼   r   N)r˜   rK   )r   r   r$   r¼   r½   )r   r&   r   r   r   Útest_gzip_implicitÑ  s    z!TestCreateGzip.test_gzip_implicitc             C   s‚   | j jdddd�}| j|jdƒ | j|jdƒ tjjj}z8t	ƒ tjj_| j
tƒ� | j jdd	dd�}W dQ R X W d|tjj_X dS )
z. Create with gzip level by specifying integer r   r˜   rK   r§   )r¼   r¹   N)r˜   rK   )r˜   rK   )r   r   r$   r¼   r½   rH   Ú_hlÚdatasetÚ_LEGACY_GZIP_COMPRESSION_VALSr™   r5   rR   )r   r&   Úoriginal_compression_valsr   r   r   Útest_gzip_number×  s    
 zTestCreateGzip.test_gzip_numberc             C   s‚   | j ttfƒ� | jjdd
dd� W dQ R X | j tƒ� | jjdddd� W dQ R X | j tƒ� | jjddddd	� W dQ R X dS )z= Illegal gzip level (explicit or implicit) raises ValueError r   r˜   rK   é   )r¼   Nr   r¹   )r¼   r½   )r˜   rK   )r˜   rK   éüÿÿÿ)r˜   rK   )r5   rR   ÚRuntimeErrorr   r   )r   r   r   r   Útest_gzip_excå  s    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   s`   t jjj}z(tƒ t jj_| jjddt jjd	d�}W d|t jj_X | j	|j
dƒ | j	|jdƒ dS )
z^ Create with compression number of gzip (h5py.h5z.FILTER_DEFLATE) and a compression level of 7r   r˜   rK   r§   )r¼   r½   Nr¹   )r˜   rK   )r§   )rH   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Ì   | j tƒ�}| jjdd
dd� W dQ R X | jdt|jƒƒ | j tƒ�}| jjdddd� W dQ R X | jd	t|jƒƒ tjj	j
}z<tƒ tjj	_
| j tƒ� | jjddtjjd� W dQ R X W d|tjj	_
X dS )z* Create with invalid compression numbers  r   r˜   rK   iç  )r¼   NzInvalid filterru   zUnknown compression)r˜   rK   iüÿÿ)r˜   rK   )r˜   rK   )r5   rR   r   r   ZassertInr   Ú	exceptionrH   rÀ   rÁ   rÂ   r™   Ú
IndexErrorrÊ   rË   )r   r~   rÃ   r   r   r   Útest_compression_number_invalid  s    
$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 )ÚTestCreateLZFz<
        Feature: Datasets created with LZF compression
    c             C   sŽ   | j jdd
dd�}| j|jdƒ | j|jdƒ tjdƒ}| j jd|dd	�}| j|jdƒ | j|jdƒ | j jƒ  | j d f  }| j||ƒ dS )z Create with explicit lzf r   r˜   rK   rÐ   )r¼   Nru   r+   )rF   r¼   )r˜   rK   )	r   r   r$   r¼   r½   r3   rM   ÚflushrN   )r   r&   ÚtestdataÚreaddatar   r   r   Útest_lzf  s    

zTestCreateLZF.test_lzfc             C   s.   | j tƒ� | jjddddd� W dQ R X dS )	z& Giving lzf options raises ValueError r   r˜   rK   rÐ   r   )r¼   r½   N)r˜   rK   )r5   rR   r   r   )r   r   r   r   Útest_lzf_exc/  s    zTestCreateLZF.test_lzf_excN)r   r   r   r"   rÕ   rÖ   r   r   r   r   rÑ     s   rÑ   ÚszipzSZIP is not installedc               @   s   e Zd ZdZdd„ ZdS )ÚTestCreateSZIPz<
        Feature: Datasets created with LZF compression
    c             C   s   | j jdd	dd
d�}dS )z Create with explicit szip r   r˜   rK   r×   Úecé   )r¼   r½   N)r˜   rK   )rÙ   rÚ   )r   r   )r   r&   r   r   r   Ú	test_szip=  s    zTestCreateSZIP.test_szipN)r   r   r   r"   rÛ   r   r   r   r   rØ   6  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|jƒ dS )z Enable shuffle filter r   r˜   rK   T)rÜ   N)r˜   rK   )r   r   rI   rÜ   )r   r&   r   r   r   Útest_shuffleJ  s    zTestCreateShuffle.test_shuffleN)r   r   r   r"   rÞ   r   r   r   r   rÝ   C  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|jƒ dS )z Enable fletcher32 filter r   r˜   rK   T)rß   N)r˜   rK   )r   r   rI   rß   )r   r&   r   r   r   Útest_fletcher32V  s    z$TestCreateFletcher32.test_fletcher32N)r   r   r   r"   rá   r   r   r   r   rà   P  s   rà   Ú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   s.   | j tƒ� | jjddtdd�}W dQ R X dS )z[ Ensure that a scale factor is required for scaleoffset compression of floating point data r   r˜   rK   T)r2   râ   N)r˜   rK   )r5   rR   r   r   Úfloat)r   r&   r   r   r   Ú test_float_fails_without_optionsb  s    z6TestCreateScaleOffset.test_float_fails_without_optionsc             C   s.   | j tƒ� | jjddtdd�}W dQ R X dS )	z# Check when scaleoffset is negetiver   r˜   rK   gš™™™™™¹?)r2   râ   N)r˜   rK   gš™™™™™¹¿)r5   rR   r   r   rä   )r   r&   r   r   r   Útest_non_integerh  s    z&TestCreateScaleOffset.test_non_integerc             C   s.   | j tƒ� | jjddtdd�}W dQ R X dS )z% Check when dtype is unsupported typer   r˜   rK   T)r2   râ   N)r˜   rK   )r5   r6   r   r   Úbool)r   r&   r   r   r   Útest_unsupport_dtypen  s    z*TestCreateScaleOffset.test_unsupport_dtypec             C   s¬   d}d}dd|  }t jj|Ž d | }| jjd|t|d�}|jd	k	sJt‚||d
< | jj}| jj	ƒ  t
j|dƒ| _| jd d
 }| j||d|  d� ||kjƒ  s¨t‚d	S )z2 Scaleoffset filter works for floating point data r   ru   é,  r˜   r-   g      à?r   )r2   râ   N.Úr)Z	precision)ru   ré   )r3   ÚrandomZrandr   r   rä   râ   rX   Úfilenamer   rH   r   rN   r    )r   Zscalefacr%   ÚrangerÓ   r&   rì   rÔ   r   r   r   Ú
test_floatt  s    
z TestCreateScaleOffset.test_floatc             C   sŠ   d}d}t jjdd| d |d�}| jjd|td	d
�}|jdk	sDt‚||d< | jj}| jj	ƒ  t
j|dƒ| _| jd d }| j||ƒ dS )zB Scaleoffset filter works for integer data with default precision rŸ   ru   é,  r   r@   r   )r/   r   T)r2   râ   N.rê   )ru   rï   )r3   rë   Úrandintr   r   Úintrâ   rX   rì   r   rH   r   rN   )r   Únbitsr%   rÓ   r&   rì   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|jdkƒ ||d	< | jj}| jj	ƒ  t
j|d
ƒ| _| jd d	 }| j||ƒ dS )zD Scaleoffset filter works for integer data with specified precision rŸ   ru   é,  r   r@   )r/   r   )r2   râ   .rê   N)ru   rô   )r3   rë   rð   r   r   rñ   rI   râ   rì   r   rH   r   rN   )r   rò   r%   rÓ   r&   rì   rÔ   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|jdkƒ ||d
< | jj}| jj	ƒ  t
j|dƒ| _| jd d
 }||kjƒ  s’t‚dS )zD Scaleoffset filter works for integer data with specified precision rŸ   ru   é,  r   r@   r   )r/   r   )r2   râ   .rê   N)ru   rö   )r3   rë   rð   r   r   rñ   rI   râ   rì   r   rH   r   r    rX   )r   rò   r%   rÓ   r&   rì   rÔ   r   r   r   Útest_int_with_minbits_lossy·  s    
z1TestCreateScaleOffset.test_int_with_minbits_lossyN)r   r   r   r"   rå   ræ   rè   rî   ró   rõ   r÷   r   r   r   r   rã   \  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 )ÚTestExternalzB
        Feature: Datasets with the external storage property
    c          	   C   s„   d	}t jj|ƒ}| jƒ }|dtjfg}| jjd||j|d�}||d< |jdk	sRt	‚t
|dƒ�}|jƒ }W dQ R X ||jƒ ks€t	‚dS )
z' Create and access an external dataset r,   ru   r   r   )r2   Úexternal.NÚrb)r,   ru   )r3   rë   r   r
   Ú	UNLIMITEDr   r   r2   rù   rX   ÚopenÚreadÚtobytes)r   r%   rÓ   Úext_filerù   r&   ZfidÚcontentsr   r   r   Útest_contentsÒ  s    zTestExternal.test_contentsc             C   s   | j jdd| jƒ d� dS )z/ External argument may be a file name str only r   r,   ru   )rù   N)r,   ru   )r   r   r   )r   r   r   r   Útest_name_strå  s    zTestExternal.test_name_strc             C   s    | j jddtj| jƒ ƒd� dS )z0 External argument may be a file name path only r   r,   ru   )rù   N)r,   ru   )r   r   ÚpathlibÚPathr   )r   r   r   r   Útest_name_pathê  s    
zTestExternal.test_name_pathc                sN   | j ƒ ‰ d}t‡ fdd„t|ƒD ƒƒ}| jjdd|d�}t|jƒ|ksJt‚dS )	z9 External argument may be an iterable of multiple tuples ru   c             3   s   | ]}ˆ |d  d fV  qdS )iè  Nr   )Ú.0r·   )rÿ   r   r   ú	<genexpr>õ  s    z/TestExternal.test_iter_multi.<locals>.<genexpr>Zpoor,   )rù   N)r,   ru   )r   Úiterrí   r   r   rš   rù   rX   )r   ÚNrù   r&   r   )rÿ   r   Útest_iter_multið  s
    zTestExternal.test_iter_multic             C   s    d}| j ƒ }xŽ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gD ]0\}}| j|ƒ� | jjd||d� W dQ R X qhW dS )	z" Test with invalid external lists r,   ru   r   zh5f.UNLIMITEDr   )rù   N)r,   ru   )r   r6   r
   rû   rR   r5   r   r   )r   r%   rÿ   Úexc_typerù   r   r   r   Útest_invalidù  s    

zTestExternal.test_invalidN)	r   r   r   r"   r  r  r  r
  r  r   r   r   r   rø   Î  s   	rø   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 jƒ }| jt|ƒtjjƒ | j|jƒ |ƒ |r>|jƒ s>t	‚d S )N)
rS   rU   r$   r¶   rH   r   rW   rY   rZ   rX   )r   r    r\   Úvariabler^   r   r   r   Úassert_string_type  s
    
z!TestAutoCreate.assert_string_typec             C   sx   d| j d< | j| j d tjjƒ ddg| j d< | j| j d tjjƒ tjddgtjd�| j d< | j| j d tjjƒ dS )	z<Assigning byte strings produces a vlen string ASCII dataset s   Hello therer·   ó   as   bcÚy)r2   ÚzN)r   r  rH   r   r`   r3   rf   Úobject_)r   r   r   r   Útest_vlen_bytes  s    
zTestAutoCreate.test_vlen_bytesc             C   s‚   dt dƒ | jd< | j| jd tjjƒ ddg| jd< | j| jd tjjƒ tjddggtjd�| jd< | j| jd tjjƒ d	S )
z?Assigning unicode strings produces a vlen string UTF-8 dataset zHello therei4   r·   rb   Zbcr  )r2   r  N)	Úchrr   r  rH   r   rj   r3   rf   r  )r   r   r   r   Útest_vlen_unicode#  s    z TestAutoCreate.test_vlen_unicodec             C   sH   t jdƒ| jd< | jd }| j|tjjdd� | j|jj	ƒ j
ƒ dƒ dS )zV Assignment of fixed-length byte string produces a fixed-length
        ascii dataset zHello therer·   F)r  rž   N)r3   Ústring_r   r  rH   r   r`   r$   rS   rU   r[   )r   r    r   r   r   Útest_string_fixed/  s    
z TestAutoCreate.test_string_fixedN)T)r   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d„ ZdS )ÚTestCreateLikec             C   sV   t jdƒjddƒ| jd< | jjd| jd ƒ | jd }| j|jdƒ | j|jd ƒ d S )Né   é   ZlolZlike_lol)r  r  )	r3   rM   rO   r   Úcreate_dataset_liker$   r%   ZassertIsr‘   )r   Zdsliker   r   r   Útest_no_chunks9  s
    
zTestCreateLike.test_no_chunksc             C   s°   | j jdtjdƒdd�}| jdtjj|jƒj	ƒ | j j
d|ƒ}| jdtjj|jƒj	ƒ | j jdtjdƒdd�}| jdtjj|jƒj	ƒ | j j
d	|ƒ}| jdtjj|jƒj	ƒ d S )
NZhondarŸ   T)rF   Útrack_timesr   ZhyundaiZibmFZlenovo)r   r   r3   rM   ÚassertNotEqualrH   Úh5gÚget_objinfoÚ_idÚmtimer  r$   )r   ÚorigÚsimilarr   r   r   Útest_track_times@  s    zTestCreateLike.test_track_timesc             C   s@   | j jdddd�}| j jd|ƒ}| j|jdƒ | j|jd	ƒ dS )
z) Test when other.maxshape != other.shape Úotherr-   r˜   )r•   ÚsimN)r-   )r-   )r˜   )r   r   r  r$   r%   r•   )r   r'  r%  r   r   r   Útest_maxshapeM  s    zTestCreateLike.test_maxshapeN)r   r   r   r  r&  r)  r   r   r   r   r  8  s   r  c               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestChunkIteratorc          	   C   s0   | j jdf ƒ}| jtƒ� |jƒ  W d Q R X d S )Nr   )r   r   r5   r6   Úiter_chunks)r   r&   r   r   r   r  V  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}| jt|jƒ ƒt|ƒƒ td	ddƒftdddƒftdd
dƒff}| jt|jtjd	d
… ƒƒt|ƒƒ d S )Nr   ru   é    )r‘   r   r   é@   é`   ry   éa   )ru   )r,  )r   r   Úslicer$   Úlistr+  r3   rz   )r   r&   Úexpectedr   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}| jt|jƒ ƒt|ƒƒ td	d
dƒtdddƒff}| jt|jtjd	d
…dd…f ƒƒt|ƒƒ d S )Nr   ru   r,  r-  )r‘   r   r   r.  é0   é4   r�   ry   )ru   ru   )r,  r-  )r   r   r0  r$   r1  r+  r3   rz   )r   r&   r2  r   r   r   Útest_2dc  s     " " zTestChunkIterator.test_2dN)r   r   r   r  r3  r6  r   r   r   r   r*  U  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|jdƒ | j|jd	ƒ dS )
z  Create dataset with "maxshape" r   r˜   rK   r.   )r•   N)r˜   rK   )r˜   r.   )r˜   r.   )r   r   ÚassertIsNotr‘   r$   r•   )r   r&   r   r   r   r…   w  s    zTestResize.test_createc             C   sR   | j jdddd�}| j|jdƒ | j|jdƒ | j jdddd�}| j|jdƒ dS )	z6 Create dataset with "maxshape" using integer maxshaper   r˜   )r•   Nr+   )r˜   )r˜   )r˜   )r   r   r8  r‘   r$   r•   )r   r&   r   r   r   r‡   }  s
    zTestResize.test_create_1Dc             C   sT   | j jddd	d�}| j|jd
ƒ |jdƒ | j|jdƒ |jdƒ | j|jdƒ dS )z( Datasets may be resized up to maxshape r   r˜   rK   r.   )r•   ry   N)r˜   rK   )r˜   r.   )r˜   rK   )r˜   ry   )r˜   ry   )r˜   r.   )r˜   r.   )r   r   r$   r%   Úresize)r   r&   r   r   r   Útest_resize†  s    

zTestResize.test_resizec             C   s<   | j jdddd�}| j|jdƒ |jdƒ | j|jd	ƒ dS )
z> Datasets may be resized up to maxshape using integer maxshaper   r˜   r�   )r•   rK   N)r˜   )rK   )rK   )r   r   r$   r%   r9  )r   r&   r   r   r   Útest_resize_1D�  s    
zTestResize.test_resize_1Dc          
   C   s6   | j jddd	d�}| jtƒ� |jd
ƒ W dQ R X dS )z. Resizing past maxshape triggers an exception r   r˜   rK   r.   )r•   éF   N)r˜   rK   )r˜   r.   )r˜   r<  )r   r   r5   Ú	Exceptionr9  )r   r&   r   r   r   Útest_resize_over–  s    zTestResize.test_resize_overc          
   C   s2   | j jddƒ}| jtƒ� |jdƒ W dQ R X dS )z/ Resizing non-chunked dataset raises TypeError r   r˜   rK   r.   N)r˜   rK   )r˜   r.   )r   r   r5   r6   r9  )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|jdƒ d	S )z Resize specified axis r   r˜   rK   r.   )r•   ry   r   )ÚaxisN)r˜   rK   )r˜   r.   )r˜   ry   )r   r   r9  r$   r%   )r   r&   r   r   r   Útest_resize_axis¢  s    zTestResize.test_resize_axisc             C   s:   | j jdd
dd�}| jtƒ� |jddd� W d	Q R X d	S )z  Illegal axis raises ValueError r   r˜   rK   r.   )r•   ry   r@   )r@  N)r˜   rK   )r˜   r.   )r   r   r5   rR   r9  )r   r&   r   r   r   Útest_axis_exc¨  s    zTestResize.test_axis_excc             C   s2   | j jdddd�}| j|jdƒ | j|jd	ƒ dS )
z? Allow zero-length initial dims for unlimited axes (issue 111) r   é   r   N)r•   )rC  r   )rC  N)rC  r   )rC  N)r   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?  rA  rB  rD  r   r   r   r   r7  q  s   		r7  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 jdddƒ}| j|jtjdƒƒ dS )z Retrieve dtype from dataset r   r  z|S10N)r  )r   r   r$   r2   r3   )r   r&   r   r   r   Ú
test_dtype»  s    zTestDtype.test_dtypeN)r   r   r   r"   rF  r   r   r   r   rE  µ  s   rE  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 jddƒ}| jt|ƒdƒ dS )z Python len() (under 32 bits) r   é8  rC  N)rH  rC  )r   r   r$   rš   )r   r&   r   r   r   Útest_lenÇ  s    zTestLen.test_lenc             C   sj   | j jdd	ƒ}| j|jdƒ tjdkrF| jtƒ� t|ƒ W dQ R X n| jt|ƒdƒ | j|jƒ dƒ dS )z Python len() vs Dataset.len() r   r@   é!   rC  é   r   Nì        )rL  rC  ì        )rM  rC  l        iÿÿÿl        l        )	r   r   r$   r%   ÚsysÚmaxsizer5   ÚOverflowErrorrš   )r   r&   r   r   r   Útest_len_bigÌ  s    
zTestLen.test_len_bigN)r   r   r   r"   rI  rQ  r   r   r   r   rG  Á  s   rG  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   s\   t jddd�jd	ƒ}| jjd|d�}x2t||ƒD ]$\}}| jt|ƒdƒ | j||ƒ q0W dS )
z& Iterating over a dataset yields rows rK   r   )r2   r-   rL   r   )rF   N)r-   rL   )	r3   rM   rO   r   r   Úzipr$   rš   rN   )r   rF   r&   r·   r  r   r   r   Ú	test_iterÞ  s
    zTestIter.test_iterc          	   C   s8   | j jdf d�}| jtƒ� dd„ |D ƒ W dQ R X dS )z0 Iterating over scalar dataset raises TypeError r   )r%   c             S   s   g | ]}|‘qS r   r   )r  r·   r   r   r   ú
<listcomp>ê  s    z-TestIter.test_iter_scalar.<locals>.<listcomp>N)r   r   r5   r6   )r   r&   r   r   r   Útest_iter_scalaræ  s    zTestIter.test_iter_scalarN)r   r   r   r"   rT  rV  r   r   r   r   rR  Ø  s   rR  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jƒ }| jt|ƒt jj	ƒ | j|j
ƒ t jjƒ t j|jƒ}| j|jdƒ dS )z3 Vlen bytes dataset maps to vlen ascii in the file Úascii)Úencodingr·   ru   )r2   N)ru   )rH   Ústring_dtyper   r   rS   rU   r$   r¶   r   rW   rY   r`   Úcheck_string_dtyper2   rY  )r   r®   r    r^   Ústring_infor   r   r   r  ô  s    
zTestStrings.test_vlen_bytesc             C   sj   t jƒ }| jjdd|d�}|jjƒ }| jt|ƒt jj	ƒ | j|j
ƒ t jjƒ t j|jƒ}| j|jdƒ dS )z5 Vlen unicode dataset maps to vlen utf-8 in the file r·   ru   )r2   zutf-8N)ru   )rH   rZ  r   r   rS   rU   r$   r¶   r   rW   rY   rj   r[  r2   rY  )r   r®   r    r^   r\  r   r   r   r  þ  s    
zTestStrings.test_vlen_unicodec             C   s˜   t jdƒ}| jjdd|d�}|jjƒ }| jt|ƒtj	j
ƒ | j|jƒ ƒ | j|jƒ dƒ | j|jƒ tj	jƒ tj|jƒ}| j|jdƒ | j|jdƒ dS )	zK Fixed-length bytes dataset maps to fixed-length ascii in the file
        z|S10r·   ru   )r2   r-   rX  N)ru   )r3   r2   r   r   rS   rU   r$   r¶   rH   r   rW   ZassertFalserZ   r[   rY   r`   r[  rY  r]   )r   r®   r    r^   r\  r   r   r   Útest_fixed_ascii  s    

zTestStrings.test_fixed_asciic             C   s  t jddd�}| jjdd|d�}|jjƒ }| j|jƒ t jj	ƒ d}|j
dƒ|d< ||d	< ||g|d
d…< tj||gtd�|dd…< tj|j
dƒgd
 |d�|dd…< | jtƒ�  tj||gdd�|dd…< W d Q R X tjj|d d… tj|j
dƒgd dd�ƒ d S )Nzutf-8r  )rY  r]   r·   ru   )r2   u   cÃ¹r   r   r@   r   r,   é   ÚUr-   ÚS)ru   )rH   rZ  r   r   rS   rU   r$   rY   r   rj   Úencoder3   rf   rg   r5   r6   ÚtestingÚassert_array_equal)r   r®   r    r^   Úsr   r   r   Útest_fixed_utf8  s    
"$zTestStrings.test_fixed_utf8c             C   s6   t jdƒ}| jtƒ� | jjdd|d�}W dQ R X dS )zA Fixed-length unicode datasets are unsupported (raise TypeError) z|U10r·   ru   )r2   N)ru   )r3   r2   r5   r6   r   r   )r   r®   r    r   r   r   Útest_fixed_unicode&  s    
zTestStrings.test_fixed_unicodec             C   sR   t jdd�}| jjdd	|d�}d}||d< |d }| jt|ƒtƒ | j||ƒ dS )
zN writing and reading to vlen bytes dataset preserves type and content
        rX  )rY  r·   ru   )r2   s   Helloïr   N)ru   )rH   rZ  r   r   r$   r¶   Úbytes)r   r®   r    rF   Úoutr   r   r   Útest_roundtrip_vlen_bytes,  s    z%TestStrings.test_roundtrip_vlen_bytesc             C   sR   t jdƒ}| jjdd|d�}d}||d< |d }| jt|ƒt jƒ | j||ƒ dS )	z[ Writing to and reading from fixed-length bytes dataset preserves
        type and content z|S10r·   ru   )r2   s   Helloïr   N)ru   )r3   r2   r   r   r$   r¶   r  )r   r®   r    rF   rh  r   r   r   Útest_roundtrip_fixed_bytes7  s    
z&TestStrings.test_roundtrip_fixed_bytesc             C   s^   t jƒ }| jjdd|d�}d}||d< | j|d tƒ |jƒ d }| j|tƒ | j||ƒ d S )Nr·   r-   )r2   u   fÃ ilter   )r-   )	rH   rZ  r   r   r   rg  Úasstrr   r$   )r   r®   r    rF   rh  r   r   r   Útest_retrieve_vlen_unicodeB  s    z&TestStrings.test_retrieve_vlen_unicodec             C   s¢   | j jddtjƒ d�}d}||d< |jdƒ}| jtƒ� |d }W d Q R X | j|jddƒd dƒ | j|jd	ƒd |ƒ t	j
j|jƒ d d
… t	j|gtd�ƒ d S )Nr·   r-   )r2   u   fÃ ilter   rX  ÚignoreZfiltezlatin-1r   )r-   )r   r   rH   rZ  rk  r5   ÚUnicodeDecodeErrorr$   r  r3   rb  rc  rf   rg   )r   r    rF   Zstrwrap1rh  r   r   r   Ú
test_asstrL  s    
zTestStrings.test_asstrc             C   sÈ   t jdd�}| jjdd|d�}d}tj|jdƒ|d�|d< | j|d tjƒ |j	ƒ d }| j|t
ƒ | j||ƒ | j|j	d	d
ƒd dƒ | j|j	dƒd |ƒ tjj|j	ƒ d d… tj|gtd�ƒ d S )Nr  )r]   r·   r-   )r2   u   cÃ¹zutf-8r   rX  rm  rd   zlatin-1r   )r-   )rH   rZ  r   r   r3   rf   ra  r   Zbytes_rk  r   r$   r  rb  rc  rg   )r   r®   r    rF   rh  r   r   r   Útest_asstr_fixed`  s    zTestStrings.test_asstr_fixedc          
   C   sB   t jdƒ}| jjdd|d�}d}| jtƒ� ||d< W dQ R X dS )	zGEncoding error when writing a non-ASCII string to an ASCII vlen datasetrX  r·   ru   )r2   u   fÃ ilter   N)ru   )rH   rZ  r   r   r5   ÚUnicodeEncodeError)r   r®   r    rF   r   r   r   Útest_unicode_write_errorv  s
    
z$TestStrings.test_unicode_write_errorc             C   s\   t jƒ }| jjdd	|d�}dtdƒ jdƒ}||d< |d }| jt|ƒtƒ | j||ƒ dS )
zJ Writing valid utf-8 byte strings to a unicode vlen dataset is OK
        r·   ru   )r2   zHello therei4   Úutf8r   N)ru   )	rH   rZ  r   r   r  ra  r$   r¶   rg  )r   r®   r    rF   rh  r   r   r   Útest_unicode_write_bytes~  s    z$TestStrings.test_unicode_write_bytesc             C   sV   t jdƒ}| jjdd|d�}d}||d< |d }| jt|ƒtƒ | j||jdƒƒ dS )	z: Writing an ascii str to ascii vlen dataset is OK
        rX  r·   ru   )r2   zASCII stringr   N)ru   )rH   rZ  r   r   r$   r¶   rg  ra  )r   r®   r    rF   rh  r   r   r   Útest_vlen_bytes_write_ascii_str‰  s    
z+TestStrings.test_vlen_bytes_write_ascii_strN)r   r   r   r"   r  r  r]  re  rf  ri  rj  rl  ro  rp  rr  rt  ru  r   r   r   r   rW  í  s   


rW  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 j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	�}x"|jD ]}t jjdƒd
 ||< qXW || jd< | jd d }| j	t j
||kƒƒ | j|j|jƒ dS )z: Compound types are read back in correct order (issue 236)ÚweightZcputimeZwalltimeZparents_offsetZ	n_parentsÚstatusÚendpoint_typerÚ   )r2   ru   Útest.N)rÚ   )rÚ   )r3   r2   Úfloat64Zuint32Úuint8r©   Úfieldsrë   r   rI   r    r$   )r   r®   rÓ   ÚkeyÚoutdatar   r   r   Útest_rt›  s    
zTestCompound.test_rtc             C   s¼   t jdt jdffdt jfgƒ}t jd
|d�}x*|jD ] }t jj|| jd�d ||< q4W | jj	dd|d�}x|jD ]}|| ||< qrW | jd d	 }| j
t j||kƒƒ | j|j|jƒ d S )Nrw  rL   ry  rÚ   )r2   )r/   ru   rz  .)rÚ   )rÚ   )r3   r2   r{  r|  r©   r}  rë   r%   r   r   rI   r    r$   )r   r®   rÓ   r~  r    r  r   r   r   Útest_assign¯  s     zTestCompound.test_assignc             C   s¶   t jdt jfdt jfdt jfgƒ}t jd|d�}x"|jD ]}t jjd	ƒd ||< q8W || jd< t jj| jd jddgƒd d … |ddg ƒ t jj| jd jdƒd d … |d ƒ d S )
Nr·   r  r  rÚ   )r2   ru   rz  )rÚ   )rÚ   )	r3   r2   r{  r©   r}  rë   r   rb  rc  )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   rv  •  s   rv  c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestSubarrayc             C   st   | j jdddd�}dddg|d< tjj|d d … dddggƒ dd	d
gg|d d …< tjj|d d … dd	d
ggƒ d S )Nrb   r   Ú3int8)r2   r@   rL   r   r   r  r,   )r   )r   r   r3   rb  rc  )r   r    r   r   r   Útest_write_listØ  s
    zTestSubarray.test_write_listc             C   s€   | j jdddd�}tjdddgƒ|d< tjj|d d … dddggƒ tjdd	d
ggƒ|d d …< tjj|d d … dd	d
ggƒ d S )Nrb   r   r„  )r2   r@   rL   r   r   r  r,   )r   )r   r   r3   rf   rb  rc  )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|ƒ}| j|| jƒ dS )z= Enum datasets can be created and type correctly round-trips r±   )Úbasetyper·   ru   )r2   N)ru   ru   )rH   Ú
enum_dtypeÚEDICTr   r   r2   Zcheck_enum_dtyper$   )r   r®   r    Zdt2Zdict2r   r   r   r…   ñ  s
    
zTestEnum.test_createc             C   st   t j| jdd�}| jjdd|d�}d|d< d	|d	d
d
…f< | j|d dƒ | j|d	d
d
…f tjdd dd�ƒ d
S )z/ Enum datasets can be read/written as integers r�   )r‹  r·   ru   )r2   r²   é#   é%   r   N)ru   ru   )rŽ  r�  )rŽ  r�  )r   )	rH   rŒ  r�  r   r   r$   rN   r3   rf   )r   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j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|j|ƒ tjd|d�}||d< | j|d |ƒ d S )Nr·   ru   )r2   .)ru   )ru   )r   r   r$   r2   r3   rG   rN   )r   r®   r&   rF   r   r   r   Ú	_exectest	  s
    zTestFloats._exectestÚfloat16zNumPy float16 support requiredc             C   s   | j tjdƒƒ dS )z Mini-floats round trip r“  N)r’  r3   r2   )r   r   r   r   Ú	test_mini  s    zTestFloats.test_minic             C   s<   t tdƒr"| jtjjtjdƒƒ n| jtjjtjdƒƒ dS )z Test mapping for float16 r“  z<f2z<f4N)rD   r3   r$   r   Z
IEEE_F16LEr2   )r   r   r   r   Útest_mini_mapping  s    
zTestFloats.test_mini_mappingN)r   r   r   r"   r’  r   Ú
skipUnlessrD   r3   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 )ÚTestTrackTimesz"
        Feature: track_times
    c             C   s2   | j jdddd�}tjj|jƒj}| jd|ƒ dS )zC check that when track_times=False, the time stamp=0 (Jan 1, 1970) r   r   F)r  r   N)r   )r   r   rH   r   r!  r"  r#  r$   )r   r    Zds_mtimer   r   r   Útest_disable_track_times$  s    z'TestTrackTimes.test_disable_track_timesc             C   s,   | j tƒ� | jjdddd� W dQ R X dS )z3 check that when give track_times an invalid value r   r   Únull)r  N)r   )r5   r6   r   r   )r   r   r   r   Útest_invalid_track_times*  s    z'TestTrackTimes.test_invalid_track_timesN)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 )ÚTestZeroShapez7
        Features of datasets with (0,)-shape axes
    c             C   s|   | j jdddd�}| j|jtj|ƒjƒ | j jdddd�}| j|jtj|ƒjƒ | j jdd	d
d�}| j|jtj|ƒjƒ dS )z1 Empty datasets can be converted to NumPy arrays r·   r   N)r•   r  r  )r   )N)r   r   )NN)r   r   r$   r%   r3   rf   )r   r    r   r   r   Útest_array_conversion6  s    z#TestZeroShape.test_array_conversionc             C   s~   ddg}| j jdd|dd�}tjd|d	�}| j|d
 j|jƒ | j|d
 j|jƒ | j|f  j|jƒ | j|f  j|jƒ dS )z- Slicing into empty datasets works correctly rb   r   rc   r±   r·   r   N)r2   r•   )r2   .)rb   r   )rc   r±   )r   )N)r   )r   r   r3   Úemptyr$   r%   r2   )r   r®   r    r|   r   r   r   Útest_readingA  s    zTestZeroShape.test_readingN)r   r   r   r"   rœ  rž  r   r   r   r   r›  0  s   r›  r-   r,   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 j| ƒ tjdƒjdƒ| _| jjd| jd�| _| j| jd< d S )Nru   r·   )rF   .i'  )ru   ru   )	r   r   r3   rM   rO   rF   r   r   r&   )r   r   r   r   r   X  s    
zTestRegionRefs.setUpc             C   s@   t jdd…ddd…f }| jj| }| j| j| | j| ƒ dS )z4 Region references can be used as slicing arguments r  rŽ  r-   ru   r  N)r3   rz   r&   Ú	regionrefrN   rF   )r   ÚslicÚrefr   r   r   Útest_create_ref^  s    zTestRegionRefs.test_create_refc             C   s,   | j jd d… }| j | }|jdks(t‚d S )Nr   )r&   r¡  r/   rX   )r   r£  rh  r   r   r   Útest_empty_regiond  s    
z TestRegionRefs.test_empty_regionc             C   s–   | j jdddd�}tjjtjjƒ}|jƒ  tjj|jdtjj	|ƒ}|| tj
tjdƒƒks^t‚|jƒ  tjj|jdtjj	|ƒ}|| |f  ks’t‚d S )NZscalarg      ð?r¬   )rF   r2   ó   .)r   r   rH   Zh5sÚcreateZSCALARZselect_noneZh5rrS   ZDATASET_REGIONrq   r3   r2   rX   Z
select_all)r   r    Zsidr£  r   r   r   Útest_scalar_datasetk  s    z"TestRegionRefs.test_scalar_datasetc             C   sX   t jdd…ddd…f }| jj| }| j| jjj|ƒ| jjƒ | j| jjj|ƒdƒ dS )	z, Region reference shape and selection shape r  rŽ  r-   ru   r  é   N)r-   r©  )r3   rz   r&   r¡  r$   r%   Z	selection)r   r¢  r£  r   r   r   Útest_ref_shapez  s    zTestRegionRefs.test_ref_shapeN)
r   r   r   r"   r   r¤  Úempty_regionref_xfailr¥  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 )Ú
TestAstypez(.astype() wrapper & context manager
    c             C   s„   | j jdddd�}tjdƒ|d< |jdƒ�  | j|d tjddd�ƒ W d Q R X |jdƒ� }| j|d tjddd�ƒ W d Q R X d S )	Nr·   ru   rŽ   )r2   .rµ   r¬   )ru   )r   r   r3   rM   ÚastyperN   )r   r&   Zf4dsr   r   r   Útest_astype_ctx…  s    $zTestAstype.test_astype_ctxc             C   sL   | j jdddd�}tjdƒ|d< |jdƒd d … }| j|tjddd�ƒ d S )Nr·   ru   rŽ   )r2   .r¬   )ru   )r   r   r3   rM   r­  rN   )r   r&   r|   r   r   r   Útest_astype_wrapperŽ  s    zTestAstype.test_astype_wrapperN)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 jdgƒ}| jjdf |d�}| j|d jt jdƒƒ d S )Nrb   r±   r·   )r2   )rb   r±   )r3   r2   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   sV  t jtƒ}| jjdd	|d�}tjdƒ|d< tjdƒ|d< dddg|d< tjdƒ|d< | j|d tjdƒƒ | j|d tjdƒƒ | j|d tjdddgƒƒ | j|d tjdƒƒ tjtjdƒtjdƒgt	d�|dd…< | j|d tjdƒƒ | j|d tjdƒƒ tjtjdƒtjdƒgƒ|dd…< | j|d tjdƒƒ | j|d tjdƒƒ d S )
NÚvlenr   )r2   rL   r   r   r@   r  )r   )
rH   Ú
vlen_dtyperñ   r   r   r3   rM   rN   rf   rg   )r   r®   r    r   r   r   ró   £  s     
&"zTestVlen.test_intc             C   s6   t jtƒ}| jjdd|d�}| jjdd|f  jƒ d S )Nr³  r   )r2   Úvlen2)r   )r   )rH   r´  rñ   r   r   r2   )r   r®   r    r   r   r   Útest_reuse_from_otherµ  s    
zTestVlen.test_reuse_from_otherc             C   sl   dt fdtjt ƒfg}| jjdd|d�}| jj}| jjƒ  tj|dƒ| _| jjdd| jd d f  jƒ d S )	Nrb   rc   r³  r   )r2   rµ  )r   )r   )	rñ   rH   r´  r   r   rì   r   r   r2   )r   r®   r    Úfnamer   r   r   Útest_reuse_struct_from_otherº  s    
z%TestVlen.test_reuse_struct_from_otherc             C   sN  t jtƒ}| jjdd|d�}tjddgƒ|d< tjdgƒ|d< dddg|d< | j|d tjddgƒƒ | j|d tjdgƒƒ | j|d tjdddgƒƒ tjd	d
dddgtjdƒgt	d�|dd…< | j|d tjdƒƒ | j|d tjdƒƒ tjtjd	ddgƒtjdddgƒgƒ|dd…< | j|d tjdƒƒ | j|d tjdƒƒ d S )Nr³  rL   )r2   gffffffö?g333333ó?r   r   r@   gš™™™™™¹?gš™™™™™ñ?gÍÌÌÌÌÌ @gÍÌÌÌÌÌ@r   r  gš™™™™™@gš™™™™™É?)rL   )
rH   r´  rñ   r   r   r3   rf   rN   rM   rg   )r   r®   r    r   r   r   Útest_convertÂ  s    
*zTestVlen.test_convertc             C   s®   t jtƒ}| jjdd|d�}tjdƒ|d< tjtjdƒtjdƒgtjdƒtjdƒggtd�|d d …d d …f< tjtjdƒtjdƒgtjdƒtjdƒggƒ|d d …d d …f< d S )	Nr³  r@   )r2   r   r   rL   )r@   r@   )r   r   )	rH   r´  rñ   r   r   r3   rM   rf   rg   )r   r®   r    r   r   r   Útest_multidimÓ  s    
,zTestVlen.test_multidimr³  c             C   sh  t j|ƒ}| jj|d|d�}tjdddg|d�}tjdddddg|d�}tjdddgtjdƒd�}|j|ƒ}dddddg}	tj|	|d�}
dd ddddg}tj||d�}||d< ||d< ||d< |	|d< ||d< | j||d ƒ | j||d ƒ | j||d ƒ | j|
|d ƒ | j||d ƒ tjddg|d�}
|
dd… |d< | j|
|d ƒ | jj	ƒ  | 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  )r2   g      ð?g       @g      >@g33333Y@gÍÌÌÌÌi@gfffff†X@g      %@g     Àr@r   r@   r^  r�   g      Œ@g        g      à?ru   r   i'  r<  rL   r   g333333Ó?gš™™™™™@N)r  g      %Àg     ÀrÀg      à¿éÿÿÿÿiœÿÿÿ)rH   r´  r   r   r3   rf   r2   r­  rN   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 jdƒ}| j|ƒ d S )Nr“  )r3   r2   r½  )r   r¼  r   r   r   Útest_numpy_float16  s    
zTestVlen.test_numpy_float16c             C   s   t jdƒ}| j|ƒ d S )NZfloat32)r3   r2   r½  )r   r¼  r   r   r   Útest_numpy_float32  s    
zTestVlen.test_numpy_float32c             C   s   t jdƒ}| j|ƒ d S )Nr{  )r3   r2   r½  )r   r¼  r   r   r   Útest_numpy_float64_from_dtype  s    
z&TestVlen.test_numpy_float64_from_dtypec             C   s   t j}| j|ƒ d S )N)r3   r{  r½  )r   r¼  r   r   r   Útest_numpy_float64_2  s    zTestVlen.test_numpy_float64_2c             C   s"  | j jddtjdƒd� tjdddddddgƒ}|ddd… | j d d	< t| j d d	 |ddd… kƒsŽt| j d d	 › d
|ddd… › �ƒ‚| j jddtjdƒd� tjdddddddgƒ}|ddd… | j d d	< t| j d d	 |ddd… kƒ�st| j d d	 › d
|ddd… › �ƒ‚dS )z4Test that non-contiguous arrays are stored correctlyZncr-   rç   )r2   TFNr@   r   z != Znc2Zint8r   r   r  rL   r§   )r-   )r-   r»  )r   r   rH   r´  r3   rf   r    rX   )r   r·   r  r   r   r   Útest_non_contiguous_arrays  s    Fz#TestVlen.test_non_contiguous_arraysN)r³  )r   r   r   ró   r¶  r¸  r¹  rº  r½  r¾  r¿  rÀ  rÁ  rÂ  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 jddƒ}|jjƒ }dS )z Test H5Dget_access_plist r   r   N)r   )r   r   rS   Zget_access_plist)r   r    Zp_listr   r   r   Útest_get_access_list-  s    z TestLowOpen.test_get_access_listc             C   sH   t jjt jjƒ}| jjddƒ}~t jj| jjd|ƒ}| j	|t jj
ƒ dS )z# Test the dapl keyword to h5d.open r·   ru   ó   xN)ru   )rH   Zh5pr§  ZDATASET_ACCESSr   r   Zh5drü   rS   r   Z	DatasetID)r   Zdaplr&   Zdsidr   r   r   Ú	test_dapl2  s
    zTestLowOpen.test_daplN)r   r   r   rÄ  rÆ  r   r   r   r   rÃ  +  s   rÃ  r  z#chunk info requires  HDF5 >= 1.10.5c              C   sD  ddl m}  | ƒ }tj|dƒ�(}|jddddd� d	|d d d …< W d Q R X |jdƒ tj|d
ƒ�Ø}|d j}|jƒ dks~t‚xlt	dƒD ]`}t
tjtj|dƒƒd ƒ}|j|ƒ}|j|ks¾t‚|jdksÌt‚|jd k	sÚt‚|jdksˆt‚qˆW |jdƒ}|jdk�st‚|jdk�st‚|jd k	�s&t‚|jdk�s6t‚W d Q R X d S )Nr   )ÚBytesIOr   rz  ru   r-   r�   )r%   r‘   r2   r   rê   )ru   ru   )r-   r-   )r-   r-   )r   r   )r   r   )ÚiorÇ  rH   r   r   ÚseekrS   Zget_num_chunksrX   rí   r™   r3   rf   Zunravel_indexZget_chunk_infoZchunk_offsetZfilter_maskZbyte_offsetr/   Zget_chunk_info_by_coord)rÇ  ÚbufÚfoutÚfinr    ÚjÚoffsetÚsir   r   r   Útest_get_chunk_details;  s*    



rÐ  c             C   s.   | j ddd�}|jd kst‚|jd ks*t‚d S )Nr�  r�   )r2   )r   r%   rX   r•   )Úwritable_filer    r   r   r   Útest_empty_shapeY  s    rÒ  c              C   sœ   ddl m}  | ƒ }tj|dƒ�}|jddd� W d Q R X |jdƒ tj|dƒ�D}|d jd ksbt‚|d jj	ƒ d ksxt‚|d jj
ƒ dksŽt‚W d Q R X d S )Nr   )rÇ  r   r�  r|  )r2   rê   )rÈ  rÇ  rH   r   r   rÉ  r‘   rX   rS   Z
get_offsetZget_storage_size)rÇ  rÊ  rË  rÌ  r   r   r   Útest_zero_storage_size_  s    
rÓ  c             C   sœ   t jt jƒjt jt jƒjd g}| jd|t jd�}|jt jt jƒksHt‚t jj	|d d … t j
|t jd�ƒ ||d d …< t jj	|d d … t j
|t jd�ƒ d S )Nr   r·   )rF   r2   )r2   )r3   Ziinforv   Úmaxr   Zuint64r2   rX   rb  rc  rf   )rÑ  rF   r    r   r   r   Útest_python_int_uint64m  s     "rÕ  c             C   s>   | j ddtjd�}tjjddd�}||d d …d	dd
gdf< d S )NrF   r  éè  r@   )r2   éÿ   rL   )r/   r   r   .)r  rÖ  r@   )r  rL   r@   )r   r3   r|  rë   rð   )rÑ  r|   Úblockr   r   r   Útest_setitem_fancy_indexing{  s    rÙ  c           	   C   s0   t tdƒƒ�} | d d dks"t‚W d Q R X d S )Nzvlen_string_dset.h5ZDS1r   s   Parting)r   r   rX   )r   r   r   r   Útest_vlen_spacepad‚  s    rÚ  c           	   C   s0   t tdƒƒ�} | d d dks"t‚W d Q R X d S )Nzvlen_string_dset_utc.h5Zds1r   s   2009-12-20T10:16:18.662409Z)r   r   rX   )r   r   r   r   Útest_vlen_nullterm‡  s    rÛ  rL   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ks,t‚d S )Né   rF   r-   T)r%   r2   r¼   Zallow_unknown_filter)r-   r-   )r   r3   r|  r   Ú_filtersrX   )rÑ  Zfake_filter_idr    r   r   r   Útest_allow_unknown_filterŒ  s
    
rÞ  )r   r-   r,   )r   r-   r  )r   r-   rL   )Or"   r  rN  Znumpyr3   r9   r;   Úcommonr   r   Ú
data_filesr   rH   r   r   r   Zh5py._hl.baser	   r
   r   Zh5py._hl.selectionsrÀ   Z
selectionsÚselr   r   r#   rE   rt   r€   rƒ   r�   r¥   r´   rC   Úfiltersra  rº   rÉ   rÑ   rØ   rÝ   rà   rã   rø   r  r  r*  r7  rE  rG  rR  rW  rv  rƒ  r‡  r‘  r—  r›  Úmarkr<   ÚversionZhdf5_version_tupler«  r   r¬  r°  r²  rÃ  r–  rÐ  rÒ  rÓ  rÕ  rÙ  rÚ  rÛ  ZskipifrÞ  r   r   r   r   Ú<module>   s�   	FYCC&,'q>,D )B
0 

