B
    dL                @   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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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%ej&'de(dfej)dfej*dfe+dfej,dfej-dfej.dd d!d"fej.d#d d!d"fej.dd$d"fej.d#d$d"fe. d"fgd%d& Z/G d'd( d(eZ0e
1d)ej2j3kd*G d+d, d,eZ4e
1d)ej2j3kd*G d-d. d.eZ5e
1d/ej2j3kd0G d1d2 d2eZ6e
1d3ej2j3kd4G d5d6 d6eZ7e
1d7ej2j3kd8G d9d: d:eZ8e
1d;ej2j3kd<G d=d> d>eZ9e
1d?ej2j3kd@G dAdB dBeZ:G dCdD dDeZ;G dEdF dFeZ<G dGdH dHeZ=G dIdJ dJeZ>G dKdL dLeZ?G dMdN dNeZ@G dOdP dPeZAG dQdR dReZBG dSdT dTeZCG dUdV dVeZDG dWdX dXeZEG dYdZ dZeZFG d[d\ d\eZGG d]d^ d^eZHG d_d` d`eZIej&jJejjKdakdbdcZLG ddde deeZMG dfdg dgeZNG dhdi dieZOG djdk dkeZPG dldm dmeZQe
RejjKdnkdodpdq ZSe
RejjKdrkpxejjKdskoxejjKdtk dudvdw ZTdxdy ZUdzd{ ZVd|d} ZWd~d ZXdd ZYdd ZZej&j[ejjKdk ddcdd Z\dd Z]G dd deZ^G dd deZ_dS )z
    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)H5pyDeprecationWarning)versionc               @   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   I/var/www/html/venv/lib/python3.7/site-packages/h5py/tests/test_dataset.pysetUp'   s    zBaseDataset.setUpc             C   s   | j r| 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 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_open4   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_scalarB   s    z"TestCreateShape.test_create_scalarc             C   s    | j dd}| |jd dS )z Create a size-1 dataset r   )r   N)r   r   r&   r'   )r   r(   r   r   r   test_create_simpleG   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   N)r   r   r&   r'   )r   r(   r   r   r   test_create_integerL   s    z#TestCreateShape.test_create_integerc             C   sX   | j dd}| |jd | |jd | j dd}| |jd | |jd dS )z Create an extended dataset r   )?   r,   bar)   
   <   N)r   r   r&   r'   size)r   r(   r   r   r   test_create_extendedQ   s    z$TestCreateShape.test_create_extendedc             C   sX   | j dd}| |jd | |jd | j dd}| |jd | |jd dS )z Create an extended dataset r   r,   )r,   r-   )r.   r/   r0   N)r   r   r&   r'   r1   )r   r(   r   r   r   test_create_integer_extendedZ   s    z,TestCreateShape.test_create_integer_extendedc             C   s&   | j dd}| |jtd dS )z) Confirm that the default dtype is float r   )r,   z=f4N)r   r   r&   dtypenp)r   r(   r   r   r   test_default_dtypec   s    z"TestCreateShape.test_default_dtypec          	   C   s&   |  t | 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_shapeh   s    z"TestCreateShape.test_missing_shapec             C   sF   | j jddtjd}t dkr2tdt   | |j	tj dS )z) Confirm that the default dtype is float r   )r,   )r4   )ppc64lez(Storage of long double deactivated on %sN)
r   r   r5   Z
longdoubleplatformmachinepytestxfailr&   r4   )r   r(   r   r   r   test_long_doublem   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 )z) Confirm that the default dtype is float r   )r,   r@   )r4   N)r   r   r5   r4   r&   )r   r(   r   r   r   test_complex256t   s    
zTestCreateShape.test_complex256c             C   s<   | j dd}| |jd | j dd}| |jd d S )Ns   foo)r   s   bar/baz)   )r   r   r&   r'   )r   r(   dset2r   r   r   test_name_bytes{   s    zTestCreateShape.test_name_bytesN)r   r   r   r$   r)   r*   r+   r2   r3   r6   r9   r?   r   skipIfhasattrr5   rA   rD   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)r5   onesr   r   r&   r'   )r   rH   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 )r,   r   r   )rH   N)r5   rI   r   r   r&   r'   )r   rH   r(   r   r   r   r2      s    z#TestCreateData.test_create_extendedc             C   s4   | j jdddd}| |tj | d| j k dS )z1 Create dataset with missing intermediate groups z/foo/bar/baz)r/   r/   z<i4)r'   r4   N)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d | |d |d dS )	z8 Create from existing data, and make it fit a new shape    r   )r4   r   )r/      )r'   rH   .N)r5   aranger   r   r&   r'   assertArrayEqualreshape)r   rH   r(   r   r   r   test_reshape   s    zTestCreateData.test_reshapec          	   C   s*   |  t t| jd j W dQ R X dS )zE Binding Dataset to a non-DatasetID identifier fails with ValueError /N)r7   
ValueErrorr   r   id)r   r   r   r   test_appropriate_low_level_id   s    z,TestCreateData.test_appropriate_low_level_idc             C   s`   |j  }t|tjst| |ks*t|d kr@| s\tn| rLt| |ks\td S )N)	rU   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_   )ra   r   
CSET_ASCII)r(   )r   r   r   check_vlen_ascii   s    z?TestCreateData.test_create_bytestring.<locals>.check_vlen_asciias   abc)rH   bs   defcd)r4   N)r   r   r5   arrayobject)r   rc   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 )	Nrd   s   abcs   defZS3)r4   )rH   rN   )r_   )r   r   r5   rh   ra   r   rb   )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_   )ra   r   	CSET_UTF8)r(   )r   r   r   check_vlen_utf8   s    z;TestCreateData.test_create_strings.<locals>.check_vlen_utf8rd   abc)rH   re   defrf   rg   )r4   )r   r   r5   rh   ri   )r   rm   r   )r   r   test_create_strings   s    z"TestCreateData.test_create_stringsc          	   C   s8   |  t$ | jjdtjddgddd W d Q R X d S )Nrd   s   abcs   defZU3)r4   )rH   )r7   r8   r   r   r5   rh   )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   )r4   )r   r   rK   r	   rU   )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   )r4   )rH   )r   r   rJ   EmptyrK   r	   rU   )r   r   r   r   !test_empty_create_via_Empty_class   s    z0TestCreateData.test_empty_create_via_Empty_classc          	   C   s2   |  t | jjddtdd W d Q R X d S )Nr-   r   rN   )r'   rH   )r7   rT   r   r   r5   rO   )r   r   r   r   test_create_incompatible_data   s    z,TestCreateData.test_create_incompatible_dataN)r   r   r   r$   r)   r2   rL   rR   rV   ra   rj   rk   rp   rq   rr   rt   ru   r   r   r   r   rG      s   

rG   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
    z+source_shape,dest_shape,source_sel,dest_sel)d   r   r/   2   r0   )F   Z   N)rM   r/   )   r{   r{   )      	   )r.   rB   r.   rN   c       
      C   sn   t jt |dd|}|jd||d}t j|ddd}| }	|| |	|< |||| t j	||	 d S )Nint64)r4   r(   )rH   )
r5   rO   productrQ   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(   )r/   r/   r   )r4   )rH   )r   r5   rO   rI   r   r   r   )r   r   r(   r   r   r   r   test_no_sel   s    
zTestReadDirectly.test_no_selc          	   C   sV   |j ddd}tdd}tt( ||tjdd tjdd  W d Q R X d S )	Nedsetr   )r4   )rw   r   r/   rx   r0   )r   r5   rI   r=   raisesr8   r   s_)r   r   
empty_dsetr   r   r   r   
test_empty   s    zTestReadDirectly.test_emptyc          	   C   s>   |j dddd}td}tt || W d Q R X d S )Nr(   )rw   r   )r4   )   )r   r5   rI   r=   r   r8   r   )r   r   r(   r   r   r   r   test_wrong_shape   s    
z!TestReadDirectly.test_wrong_shapec          	   C   sB   |j dddd}tjddd}tt || W d Q R X d S )Nr(   )r/   r/   r   )r4   F)order)r   r5   rI   r=   r   r8   r   )r   r   r(   r   r   r   r   test_not_c_contiguous  s    z&TestReadDirectly.test_not_c_contiguous)r   r   r   r$   r=   markparametrizer5   r   r   r   r   r   r   r   r   r   r   rv      s   .2rv   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
    z+source_shape,dest_shape,source_sel,dest_sel)rw   r   r/   rx   r0   )ry   rz   N)rM   r/   )r{   r{   r{   )r|   r}   r~   )r.   rB   r.   rN   c       	      C   sl   |j d|ddd}tt||}tj|ddd}|| ||< |||| tj|d d  | d S )Nr(   int32r   )r4   	fillvalue)r4   )	r   r5   rO   r   rQ   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   sP   |j ddd}tt. |tdtjdd tjdd  W d Q R X d S )	Nr   r   )r4   )rw   r   r/   rx   r0   )r   r=   r   r8   r   r5   rI   r   )r   r   r   r   r   r   r   !  s    zTestWriteDirectly.test_emptyc          	   C   s>   |j dddd}td}tt || W d Q R X d S )Nr(   )rw   r   )r4   )r   )r   r5   rI   r=   r   r8   r   )r   r   r(   r   r   r   r   r   &  s    
z"TestWriteDirectly.test_wrong_shapec          	   C   sB   |j dddd}tjddd}tt || W d Q R X d S )Nr(   )r/   r/   r   )r4   r   )r   )r   r5   rI   r=   r   r8   r   )r   r   r(   r   r   r   r   r   ,  s    z'TestWriteDirectly.test_not_c_contiguous)r   r   r   r$   r=   r   r   r5   r   r   r   r   r   r   r   r   r   r     s   .2
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/   rN   r   N)r   require_datasetr   r   r&   r'   )r   r(   r   r   r   test_create9  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/   rN   r   N)r   r   r&   )r   r(   rC   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   r/   r   r-   )r/   Zbazs   bazN)r   r   r&   )r   r(   rC   r   r   r   test_create_1DE  s    z TestCreateRequire.test_create_1Dc          	   C   s:   | j ddd | t | j ddd W dQ R X dS )z6 require_dataset with shape conflict yields TypeError r   )r/   rN   r   )r/   r   N)r   r   r7   r8   r   )r   r   r   r   test_shape_conflictS  s    z%TestCreateRequire.test_shape_conflictc          	   C   s6   | j d | t | j ddd W dQ R X dS )z< require_dataset with object type conflict yields TypeError r   )r/   rN   r   N)r   Zcreate_groupr7   r8   r   )r   r   r   r   test_type_conflictY  s    z$TestCreateRequire.test_type_conflictc          	   C   s:   | j ddd}| t | j ddd W dQ R X dS )zL require_dataset with dtype conflict (strict mode) yields TypeError
        r   )r/   rN   r   ZS10N)r   r   r7   r8   r   )r   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/   rN   r   T)exactN)r   r   r   r&   )r   r(   rC   r   r   r   test_dtype_exactf  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/   rN   i4i2F)r   N)r   r   r   r&   r4   r5   )r   r(   rC   r   r   r   test_dtype_closem  s    z"TestCreateRequire.test_dtype_closeN)r   r   r   r$   r   r   r   r   r   r   r   r   r   r   r   r   r   3  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   )rw   )r/   )r'   chunksN)r   r   r&   r   )r   r(   r   r   r   test_create_chunks|  s    z$TestCreateChunked.test_create_chunksc             C   s$   | j jdddd}| |jd dS )z Create via chunks integer r   )rw   r/   )r'   r   )r/   N)r   r   r&   r   )r   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Q R X dS )z& Illegal chunk size raises ValueError r   )rw   )r   )r'   r   N)r7   rT   r   r   )r   r   r   r   test_chunks_mismatch  s    z&TestCreateChunked.test_chunks_mismatchc          	   C   s.   |  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/   rw   F)r'   maxshaper   N)r7   rT   r   r   )r   r   r   r   test_chunks_false  s    z#TestCreateChunked.test_chunks_falsec          	   C   s,   |  t | jjdddd W dQ R X dS )z> Attempting to create chunked scalar dataset raises TypeError r   r   )rx   )r'   r   N)r7   r8   r   r   )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{   rw   T)r'   r   rB   N)r   r   r   r   tupler&   len)r   r(   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   )rN   Z
S100000000T)r'   r4   r   )r   N)r   r   r&   r   )r   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   )rN   rx   rx   )r   rx   rx   )r'   r4   r   r/   r   N(         r   rB   )r   r   r5   r   rK   all)r   r(   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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 allowedrs   )matchr   ZS100T)r4   r   Nr{   )r4   r   )r=   r   r8   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   v  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   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assertNotIsInstancer5   ndarray)r   r(   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   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 )rd   f4)re   i8)r   )r4   r   r   )r/   )r4   r   r   N)r5   r4   rI   r   r   r&   r   ZassertAlmostEqual)r   dtvr(   r   r   r   test_compound  s
    z!TestCreateFillvalue.test_compoundc          	   C   s2   |  t | jjddddgdd}W dQ R X dS )z$ Bogus fill value raises ValueError r   )r/   )rd   i)re   r   *   )r4   r   N)r7   rT   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   zdt,expectedg        zutf-8r|   )encodingr_       ascii)r   c             C   s"   |j dd| d}|j|kstd S )Nr   )r/   )r4   )r   r   rZ   )r   r   r   r(   r   r   r   test_get_unset_fill_value  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x)rw   )r4   N)	r5   r4   r   r   r&   rU   rW   rK   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d | |jd dS )z# Create with explicit gzip options r   )r{   rM   r   r~   )compressioncompression_optsN)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d | |jd dS )z+ Create with implicit gzip level (level 4) r   )r{   rM   r   )r   r   N)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d | |jd tjjj}z8t	 t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{   rM   r}   )r   r   N)r   r   r&   r   r   rJ   _hldataset_LEGACY_GZIP_COMPRESSION_VALSr   r7   rT   )r   r(   original_compression_valsr   r   r   test_gzip_number  s    
 zTestCreateGzip.test_gzip_numberc          	   C   s   |  ttf | jjdddd W dQ R X |  t | jjdddd W dQ R X |  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{   rM      )r   Nr   )r   r   )r7   rT   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
d | 	|jd dS )z^ Create with compression number of gzip (h5py.h5z.FILTER_DEFLATE) and a compression level of 7r   )r{   rM   )r}   )r   r   Nr   r}   )rJ   r   r   r   r   r   r   h5zFILTER_DEFLATEr&   r   r   )r   r   r(   r   r   r   test_compression_number5  s    
z3TestCreateCompressionNumber.test_compression_numberc          	   C   s   |  t}| jjdddd W dQ R X | dt|j |  t}| jjdddd W dQ R X | dt|j tjj	j
}z<t t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{   rM   i)r   NzInvalid filterrw   zUnknown compression)r7   rT   r   r   ZassertInr!   	exceptionrJ   r   r   r   r   
IndexErrorr   r   )r   er   r   r   r   test_compression_number_invalidA  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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{   rM   r   )r   Nrw   r-   )rH   r   r   )	r   r   r&   r   r   r5   rO   flushrP   )r   r(   testdatareaddatar   r   r   test_lzf]  s    

zTestCreateLZF.test_lzfc          	   C   s.   |  t | jjddddd W dQ R X dS )z& Giving lzf options raises ValueError r   )r{   rM   r   r   )r   r   N)r7   rT   r   r   )r   r   r   r   test_lzf_excm  s    zTestCreateLZF.test_lzf_excN)r   r   r   r$   r   r   r   r   r   r   r   V  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{   rM   r   )ec   )r   r   N)r   r   )r   r(   r   r   r   	test_szip{  s    zTestCreateSZIP.test_szipN)r   r   r   r$   r   r   r   r   r   r   t  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{   rM   T)r   N)r   r   rK   r   )r   r(   r   r   r   test_shuffle  s    zTestCreateShuffle.test_shuffleN)r   r   r   r$   r   r   r   r   r   r     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{   rM   T)r   N)r   r   rK   r   )r   r(   r   r   r   test_fletcher32  s    z$TestCreateFletcher32.test_fletcher32N)r   r   r   r$   r   r   r   r   r   r     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.   |  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{   rM   T)r4   r  N)r7   rT   r   r   float)r   r(   r   r   r    test_float_fails_without_options  s    z6TestCreateScaleOffset.test_float_fails_without_optionsc          	   C   s.   |  t | jjddtdd}W dQ R X dS )z# Check when scaleoffset is negetiver   )r{   rM   g)r4   r  N)r7   rT   r   r   r  )r   r(   r   r   r   test_non_integer  s    z&TestCreateScaleOffset.test_non_integerc          	   C   s.   |  t | jjddtdd}W dQ R X dS )z% Check when dtype is unsupported typer   )r{   rM   T)r4   r  N)r7   r8   r   r   bool)r   r(   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k	sJt||d	< | jj}| j	  t
|d
| _| jd d	 }| j||d|  d ||k rtdS )z2 Scaleoffset filter works for floating point data r   )rw   i,  r{   r/   g      ?r   )r4   r  N.r)	precision)r5   randomrandr   r   r  r  rZ   filenamer   rJ   r   rP   r   )r   Zscalefacr'   ranger   r(   r  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
k	sDt||d< | jj}| j	  t
|d| _| jd d }| || d
S )zB Scaleoffset filter works for integer data with default precision r   )rw   i,  r   rB   r   )r1   r   T)r4   r  N.r  )r5   r
  randintr   r   intr  rZ   r  r   rJ   r   rP   )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dk ||d< | jj}| j	  t
|d	| _| jd d }| || d
S )zD Scaleoffset filter works for integer data with specified precision r   )rw   i,  r   rB   )r1   r   )r4   r  .r  N)r5   r
  r  r   r   r  rK   r  r  r   rJ   r   rP   )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dk ||d	< | jj}| j	  t
|d
| _| jd d	 }||k rtdS )zD Scaleoffset filter works for integer data with specified precision r   )rw   i,  r   rB   r   )r1   r   )r4   r  .r  N)r5   r
  r  r   r   r  rK   r  r  r   rJ   r   r   rZ   )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               @   s@   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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}||d< |jdk	sTt	t
|d}| }W dQ R X || kst	tjjd	krt|j    }t| jjj }	||	kst	dS )
z' Create and access an external dataset )r.   rw   r   r   z	${ORIGIN})r4   externalefile_prefix.Nrb)r   r/   r   )r5   r
  r   r
   	UNLIMITEDr   r   r4   r  rZ   openreadtobytesrJ   r   hdf5_version_tuplepathlibPathrU   get_access_plistget_efile_prefixdecodeas_posixr  parent)
r   r'   r   ext_filer  r(   fidcontentsr  r$  r   r   r   test_contents  s    zTestExternal.test_contentsc          	   C   s  d}t j|}|  }tj|dtjfg}| jj	d||j
|tj|d}||d< |jdk	sdtt|d}| }W dQ R X || ksttjjdkrt|j    }t|j }	||	kst| jjd||j
tj|d	}
|
jdk	st|
d
 |k dS )z< Create and access an external dataset using an efile_prefix)r.   rw   r   r   )r4   r  r  .Nr  )r   r/   r   )r  r   )r5   r
  r   ospathbasenamer
   r  r   r   r4   dirnamer  rZ   r  r  r  rJ   r   r  r  r  rU   r   r!  r"  r#  r$  r   )r   r'   r   r%  r  r(   r&  r'  r  r$  rC   r   r   r   test_contents_efile_prefix*  s"     z'TestExternal.test_contents_efile_prefixc             C   s   | j jdd|  d dS )z/ External argument may be a file name str only r   )r.   rw   )r  N)r   r   r   )r   r   r   r   test_name_strH  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   )r.   rw   )r  N)r   r   r  r  r   )r   r   r   r   test_name_pathM  s    
zTestExternal.test_name_pathc                sN   |    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 rw   c             3   s   | ]} |d  d fV  qdS )i  Nr   ).0r   )r%  r   r   	<genexpr>X  s    z/TestExternal.test_iter_multi.<locals>.<genexpr>Zpoo)r.   rw   )r  N)r   iterr  r   r   r   r  rZ   )r   Nr  r(   r   )r%  r   test_iter_multiS  s
    zTestExternal.test_iter_multic          
   C   s   d}|   }xt|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d||d W dQ R X qhW dS )z" Test with invalid external lists )r.   rw   r   zh5f.UNLIMITEDr   )r  N)r   r8   r
   r  rT   r7   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/  r4  r6  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  }| t|tjj | | | |r>| s>t	d S )N)
rU   rW   r&   r   rJ   r   rY   r[   r\   rZ   )r   r"   r^   variabler`   r   r   r   assert_string_typet  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y)r4   zN)r   r9  rJ   r   rb   r5   rh   object_)r   r   r   r   test_vlen_bytes{  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 zHello therei4   r   rd   bcr;  )r4   r<  N)	chrr   r9  rJ   r   rl   r5   rh   r=  )r   r   r   r   test_vlen_unicode  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 zHello therer   F)r8  r   N)r5   string_r   r9  rJ   r   rb   r&   rU   rW   r]   )r   r"   r   r   r   test_string_fixed  s    
z TestAutoCreate.test_string_fixedN)T)r   r   r   r$   r9  r>  rA  rC  r   r   r   r   r7  o  s
   
r7  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|   )	r5   rO   rQ   r   create_dataset_liker&   r'   ZassertIsr   )r   Zdsliker   r   r   test_no_chunks  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)rH   track_timesr   ZhyundaiZibmFZlenovo)r   r   r5   rO   assertNotEqualrJ   h5gget_objinfo_idmtimerF  r&   )r   origsimilarr   r   r   test_track_times  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 other)r/   r{   )r   sim)r{   N)r   r   rF  r&   r'   r   )r   rQ  rO  r   r   r   test_maxshape  s    zTestCreateLike.test_maxshapeN)r   r   r   rG  rP  rS  r   r   r   r   rD    s   rD  c               @   s$   e Zd Zdd Zdd Zdd ZdS )TestChunkIteratorc          	   C   s0   | j dd}| t |  W d Q R X d S )Nr   r   )r   r   r7   r8   iter_chunks)r   r(   r   r   r   rG    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   )rw   )    )r   r   rV  r   @   `   rw   rx   a   )r   r   slicer&   listrU  r5   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   )rw   rw   )rV  rW  )r   r   rV  r   rW  rw   rX  0   4   r   rx   )r   r   rZ  r&   r[  rU  r5   r   )r   r(   r   r   r   r   test_2d  s     " " zTestChunkIterator.test_2dN)r   r   r   rG  r\  r_  r   r   r   r   rT    s   rT  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{   rM   )r{   r0   )r   N)r   r   assertIsNotr   r&   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   Nr-   )r   r   ra  r   r&   r   )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{   rM   )r{   r0   )r   )r{   rx   N)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d |d | |jd dS )z> Datasets may be resized up to maxshape using integer maxshaper   r{   r   )r   )r{   )rM   N)r   r   r&   r'   rb  )r   r(   r   r   r   test_resize_1D  s    
zTestResize.test_resize_1Dc          	   C   s6   | j jdddd}| t |d W dQ R X dS )z. Resizing past maxshape triggers an exception r   )r{   rM   )r{   r0   )r   )r{   ry   N)r   r   r7   	Exceptionrb  )r   r(   r   r   r   test_resize_over  s    zTestResize.test_resize_overc          	   C   s2   | j dd}| t |d W dQ R X dS )z/ Resizing non-chunked dataset raises TypeError r   )r{   rM   )r{   r0   N)r   r   r7   r8   rb  )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{   rM   )r{   r0   )r   rx   r   )axis)r{   rx   N)r   r   rb  r&   r'   )r   r(   r   r   r   test_resize_axis  s    zTestResize.test_resize_axisc          	   C   s:   | j jdddd}| t |jddd W dQ R X dS )	z  Illegal axis raises ValueError r   )r{   rM   )r{   r0   )r   rx   rB   )rh  N)r   r   r7   rT   rb  )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   )rk  N)r   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   rc  rd  rf  rg  ri  rj  rl  r   r   r   r   r`    s   		r`  c               @   s    e Zd ZdZd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|   z|S10N)r   r   r&   r4   r5   )r   r(   r   r   r   
test_dtype  s    zTestDtype.test_dtypec             C   s<   t dt jfdt jfg}| jdd|}| |j| dS )z7 Retrieve dtype from complex float16 dataset (gh-2156) r  r   r   )r|   N)r5   r4   float16r   r   r&   )r   Z	complex32r(   r   r   r   test_dtype_complex32#  s    zTestDtype.test_dtype_complex32N)r   r   r   r$   rn  rp  r   r   r   r   rm    s   rm  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   )i8  rk  i8  N)r   r   r&   r   )r   r(   r   r   r   test_len1  s    zTestLen.test_lenc          	   C   sj   | j dd}| |jd tjdkrF| t t| W dQ R X n| t|d | | d dS )z Python len() vs Dataset.len() r   )l        rk  iNl        )	r   r   r&   r'   sysmaxsizer7   OverflowErrorr   )r   r(   r   r   r   test_len_big6  s    
zTestLen.test_len_bigN)r   r   r   r$   rr  rv  r   r   r   r   rq  +  s   rq  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d}| jjd|d}x2t||D ]$\}}| t|d | || q0W dS )	z& Iterating over a dataset yields rows rM   r   )r4   )r/   rN   r   )rH   rN   N)	r5   rO   rQ   r   r   zipr&   r   rP   )r   rH   r(   r   r;  r   r   r   	test_iterH  s
    zTestIter.test_iterc          	   C   s8   | j jddd}| t dd |D  W dQ R X dS )z0 Iterating over scalar dataset raises TypeError r   r   )r'   c             S   s   g | ]}|qS r   r   )r0  r   r   r   r   
<listcomp>T  s    z-TestIter.test_iter_scalar.<locals>.<listcomp>N)r   r   r7   r8   )r   r(   r   r   r   test_iter_scalarP  s    zTestIter.test_iter_scalarN)r   r   r   r$   ry  r{  r   r   r   r   rw  B  s   rw  c               @   s   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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 r   )r   r   )rw   )r4   N)rJ   string_dtyper   r   rU   rW   r&   r   r   rY   r[   rb   check_string_dtyper4   r   )r   r   r"   r`   string_infor   r   r   r>  ^  s    
zTestStrings.test_vlen_bytesc             C   sp   t jdd}d}| jjdd||d}| | jd d | | | jd  d |  | | jd j| dS )	z& Vlen bytes dataset handles fillvalue r   )r   s   barr   )rw   )r4   r   r   N)rJ   r}  r   r   r&   asstrr"  r   )r   r   
fill_valuer"   r   r   r   test_vlen_bytes_fillvalueh  s    z%TestStrings.test_vlen_bytes_fillvaluec             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   )rw   )r4   zutf-8N)rJ   r}  r   r   rU   rW   r&   r   r   rY   r[   rl   r~  r4   r   )r   r   r"   r`   r  r   r   r   rA  q  s    
zTestStrings.test_vlen_unicodec             C   st   t  }d}| jjdd||d}| | jd d |d | | jd  d | | | jd j|d dS )z( Vlen unicode dataset handles fillvalue u   bárr   )rw   )r4   r   r   zutf-8N)rJ   r}  r   r   r&   encoder  r   )r   r   r  r"   r   r   r   test_vlen_unicode_fillvalue{  s    z'TestStrings.test_vlen_unicode_fillvaluec             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
        z|S10r   )rw   )r4   r/   r   N)r5   r4   r   r   rU   rW   r&   r   rJ   r   rY   ZassertFalser\   r]   r[   rb   r~  r   r_   )r   r   r"   r`   r  r   r   r   test_fixed_ascii  s    

zTestStrings.test_fixed_asciic             C   sr   t jddd}d}| jjdd||d}| | jd d | | | jd  d |  | | jd j| d	S )
z& Vlen bytes dataset handles fillvalue r   r/   )r   r_   s   barr   )rw   )r4   r   r   N)rJ   r}  r   r   r&   r  r"  r   )r   r   r  r"   r   r   r   test_fixed_bytes_fillvalue  s    z&TestStrings.test_fixed_bytes_fillvaluec          	   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 Q R X tj|d d tj|
dgd dd d S )Nzutf-8r|   )r   r_   r   )rw   )r4   u   cùr   r   rB   r   r.      Ur/   S)rJ   r}  r   r   rU   rW   r&   r[   r   rl   r  r5   rh   ri   r7   r8   r   r   )r   r   r"   r`   sr   r   r   test_fixed_utf8  s    
"$zTestStrings.test_fixed_utf8c             C   sz   t jddd}dd}| jjdd||d}| | jd d | | | jd  d |d | | jd j| d	S )
z( Vlen unicode dataset handles fillvalue zutf-8r/   )r   r_   u   bárr   )rw   )r4   r   r   N)	rJ   r}  r  r   r   r&   r  r"  r   )r   r   r  r"   r   r   r   test_fixed_utf_8_fillvalue  s    
 z&TestStrings.test_fixed_utf_8_fillvaluec          	   C   s6   t d}| t | jjdd|d}W dQ R X dS )zA Fixed-length unicode datasets are unsupported (raise TypeError) z|U10r   )rw   )r4   N)r5   r4   r7   r8   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 }| t|t | || dS )	zN writing and reading to vlen bytes dataset preserves type and content
        r   )r   r   )rw   )r4   s   Hellor   N)rJ   r}  r   r   r&   r   bytes)r   r   r"   rH   outr   r   r   test_roundtrip_vlen_bytes  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 z|S10r   )rw   )r4   s   Hellor   N)r5   r4   r   r   r&   r   rB  )r   r   r"   rH   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/   )r4   u   fàilter   )	rJ   r}  r   r   r   r  r  r!   r&   )r   r   r"   rH   r  r   r   r   test_retrieve_vlen_unicode  s    z&TestStrings.test_retrieve_vlen_unicodec          	   C   s   | j jddt d}d}||d< |d}| t |d }W d Q R X | |ddd d | |d	d | | d
t	|  t
j| d d t
j|gtd d S )Nr   )r/   )r4   u   fàilter   r   ignoreZfiltezlatin-1r/   r   )r   r   rJ   r}  r  r7   UnicodeDecodeErrorr&   rI  r   r5   r   r   rh   ri   )r   r"   rH   Zstrwrap1r  r   r   r   
test_asstr  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|   )r_   r   )r/   )r4   u   cùzutf-8r   r   r  rf   zlatin-1r   )rJ   r}  r   r   r5   rh   r  r   bytes_r  r!   r&   rI  r   r   ri   )r   r   r"   rH   r  r   r   r   test_asstr_fixed  s    zTestStrings.test_asstr_fixedc          	   C   sB   t d}| jjdd|d}d}| t ||d< W dQ R X dS )zGEncoding error when writing a non-ASCII string to an ASCII vlen datasetr   r   )rw   )r4   u   fàilter   N)rJ   r}  r   r   r7   UnicodeEncodeError)r   r   r"   rH   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   )rw   )r4   zHello therei4   utf8r   N)	rJ   r}  r   r   r@  r  r&   r   r  )r   r   r"   rH   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   )rw   )r4   zASCII stringr   N)rJ   r}  r   r   r&   r   r  r  )r   r   r"   rH   r  r   r   r   test_vlen_bytes_write_ascii_str  s    
z+TestStrings.test_vlen_bytes_write_ascii_strN)r   r   r   r$   r>  r  rA  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r|  W  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	}x"|jD ]}t jdd
 ||< qXW || 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   )r4   rw   test.N)r5   r4   float64Zuint32uint8r   fieldsr
  r   rK   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}x*|jD ] }t jj|| jdd ||< q4W | jj	dd|d}x|jD ]}|| ||< qrW | jd d	 }| 
t ||k | |j|j d S )
Nr  rN   r  )r   )r4   )r1   rw   r  .)r5   r4   r  r  r   r  r
  r'   r   r   rK   r   r&   )r   r   r   r  r"   r  r   r   r   test_assignA  s     zTestCompound.test_assignc             C   sD  t dt jfdt jfdt jfg}t jd|d}x"|jD ]}t jdd ||< q8W || jd< t j| jd ddgd d  |ddg  t j| jd dd d  |d  t jt 	| jd ddg|ddg  t dt j
fg}t jt j	| jd dg|d|dg | t| jd ddks@td S )	Nr   r;  r<  )r   )r4   rw   r  r   )r5   r4   r  r   r  r
  r   r   r   Zasarrayr   astyper   rZ   )r   r   r   r  Zdt_intr   r   r   test_fieldsR  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   st   | j jdddd}dddg|d< tj|d d  dddgg d	d
dgg|d d < tj|d d  d	d
dgg d S )Nrd   )r   3int8)r4   r   rB   rN   r   r   r|   r.   )r   r   r5   r   r   )r   r"   r   r   r   test_write_listw  s
    zTestSubarray.test_write_listc             C   s   | j jdddd}tdddg|d< tj|d d  dddgg td	d
dgg|d d < tj|d d  d	d
dgg d S )Nrd   )r   r  )r4   r   rB   rN   r   r   r|   r.   )r   r   r5   rh   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  v  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   )ZREDZGREENZ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   )basetyper   )rw   rw   )r4   N)rJ   
enum_dtypeEDICTr   r   r4   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   )rw   rw   )r4   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   )	rJ   r  r  r   r   r&   rP   r5   rh   )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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   )rw   )r4   .)r   r   r&   r4   r5   rI   rP   )r   r   r(   rH   r   r   r   	_exectest  s
    zTestFloats._exectestro  zNumPy float16 support requiredc             C   s   |  td dS )z Mini-floats round trip ro  N)r  r5   r4   )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 ro  z<f2z<f4N)rF   r5   r&   r   Z
IEEE_F16LEr4   )r   r   r   r   test_mini_mapping  s    
zTestFloats.test_mini_mappingN)r   r   r   r$   r  r   
skipUnlessrF   r5   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}| d| dS )zC check that when track_times=False, the time stamp=0 (Jan 1, 1970) r   )r   F)rH  r   N)r   r   rJ   rJ  rK  rL  rM  r&   )r   r"   Zds_mtimer   r   r   test_disable_track_times  s    z'TestTrackTimes.test_disable_track_timesc          	   C   s,   |  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)rH  N)r7   r8   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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   N)r   r;  )r   )Nr<  )r   r   )NN)r   r   r&   r'   r5   rh   )r   r"   r   r   r   test_array_conversion  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 )rd   r   )re   r   r   )r   )N)r4   r   )r4   .r   N)r   r   r5   emptyr&   r'   r4   )r   r   r"   r   r   r   r   test_reading  s    zTestZeroShape.test_readingN)r   r   r   r$   r  r  r   r   r   r   r    s   r  )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 |  tdd| _| jjd| jd| _| j| jd< d S )Ni'  )rw   rw   r   )rH   .)	r   r   r5   rO   rQ   rH   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 rE  r  r/   rw   r|   N)r5   r   r(   	regionrefrP   rH   )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  r1   rZ   )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^t|  tj|jdtjj	|}|| |d kstd S )NZscalarg      ?r   )rH   r4      .r   )r   r   rJ   Zh5screateZSCALARZselect_noneZh5rrU   ZDATASET_REGIONrs   r5   r4   rZ   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 rE  r  r/   rw   r|   )r/      N)r5   r   r(   r  r&   r'   Z	selection)r   r  r  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p}td	 |d
  | |d tjdd
d W d Q R X |d }| |d tjddd W d Q R X W d Q R X dd |D t	gd kst
d S )Nr   )rw   r   )r4   rw   .T)recordalwaysr   r   c             S   s   g | ]
}|j qS r   )category)r0  r   r   r   r   rz  1  s    z.TestAstype.test_astype_ctx.<locals>.<listcomp>rB   )r   r   r5   rO   warningscatch_warningssimplefilterr  rP   r   rZ   )r   r(   Zwarn_recZf4dsr   r   r   test_astype_ctx$  s    
$.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   )rw   r   )r4   rw   .r   )r   r   r5   rO   r  rP   )r   r(   r   r   r   r   test_astype_wrapper3  s    zTestAstype.test_astype_wrapperc             C   s:   | j jdddd}td|d< | dt|d d S )Nr   )rw   r   )r4   rw   .r   )r   r   r5   rO   r&   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 )N)rd   r   r   r   )r4   rd   r   )r5   r4   r   r   r&   )r   r   r(   r   r   r   test_scalar_compoundG  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 t}| jjdd|d}td|d< td|d< dddg|d< td|d< | |d td | |d td | |d tdddg | |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vlen)r   )r4   rN   r   r   rB   r|   r   )
rJ   
vlen_dtyper  r   r   r5   rO   rP   rh   ri   )r   r   r"   r   r   r   r  O  s     
&"zTestVlen.test_intc             C   s6   t t}| jjdd|d}| jdd|d j d S )Nr  )r   )r4   vlen2r   )rJ   r  r  r   r   r4   )r   r   r"   r   r   r   test_reuse_from_othera  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 )Nrd   re   r  )r   )r4   r  r   )	r  rJ   r  r   r   r  r   r   r4   )r   r   r"   fnamer   r   r   test_reuse_struct_from_otherf  s    
z%TestVlen.test_reuse_struct_from_otherc             C   sN  t t}| jjdd|d}tddg|d< tdg|d< ddd	g|d< | |d tddg | |d tdg | |d tddd	g tjd
ddddgtdgt	d|dd< | |d td | |d td ttd
ddgtdddgg|dd< | |d td	 | |d td	 d S )Nr  )rN   )r4   gffffff?g333333?r   r   rB   rN   g?g?g @g@r   r|   g@g?)
rJ   r  r  r   r   r5   rh   rP   rO   ri   )r   r   r"   r   r   r   test_convertn  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  )rB   rB   )r4   r   )r   r   rN   rB   )	rJ   r  r  r   r   r5   rO   rh   ri   )r   r   r"   r   r   r   test_multidim  s    
,zTestVlen.test_multidimr  c             C   sh  t |}| 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dd}||}dddddg}	tj|	|d}
ddddddg}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|   )r4   g      ?g       @g      >@g33333Y@gi@gfffffX@g      %g     rr   rB   r  r   g      @g        g      r   ir   i'  ry   rN   r   g333333?g@N)rJ   r  r   r   r5   rh   r4   r  rP   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 )Nro  )r5   r4   r  )r   r  r   r   r   test_numpy_float16  s    
zTestVlen.test_numpy_float16c             C   s   t d}| | d S )Nfloat32)r5   r4   r  )r   r  r   r   r   test_numpy_float32  s    
zTestVlen.test_numpy_float32c             C   s   t d}| | d S )Nr  )r5   r4   r  )r   r  r   r   r   test_numpy_float64_from_dtype  s    
z&TestVlen.test_numpy_float64_from_dtypec             C   s   t j}| | d S )N)r5   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dd tdddddddg}|ddd | j d d	< t| j d d	 |ddd kst| j d d	  d
|ddd  | j jddtdd t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 correctlync)r/   r  )r4   TFNrB   r   z != Znc2Zint8r   r   r|   r   rN   r}   )r   r   rJ   r  r5   rh   r   rZ   )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  N  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   rU   r   )r   r"   Zp_listr   r   r   test_get_access_list  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   )rw      xN)rJ   Zh5pr  ZDATASET_ACCESSr   r   Zh5dr  rU   r   Z	DatasetID)r   Zdaplr(   dsidr   r   r   	test_dapl  s
    zTestLowOpen.test_daplN)r   r   r   r  r  r   r   r   r   r    s   r  )r   r/   r|   z#chunk info requires  HDF5 >= 1.10.5c           	   C   sD  ddl m}  |  }t|d(}|jddddd d	|d d d < W d Q R X |d t|d
}|d j}| dks~txlt	dD ]`}t
tt|dd }||}|j|kst|jdkst|jd k	st|jdkstqW |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   r  )rw   rw   )r/   r/   r   )r'   r   r4   r   r  rw   r/   )r   r   )ior  rJ   r   r   seekrU   get_num_chunksrZ   r  r   r5   rh   Zunravel_indexget_chunk_infochunk_offsetfilter_maskbyte_offsetr1   Zget_chunk_info_by_coord)r  buffoutfinr"   joffsetsir   r   r   test_get_chunk_details  s*    



r  )r   r   rN   )r   r/   r/   )r   r/   c   zJchunk iteration requires  HDF5 1.10.10 and later 1.10, or 1.12.3 and laterc           	      s   ddl m}  |  }t|d(}|jddddd d	|d d
d
< W d
Q R X |d t|dd}|d j}| }|dksti  x$t	|D ]}|
|}| |j< qW  fdd}|| W d
Q R X d
S )z%H5Dchunk_iter() for chunk informationr   )r  r   r  )rw   rw   )r/   r/   r   )r'   r   r4   r   Nr  rw   c                sN    | j  }| j |j kst| j|jks*t| j|jks:t| j|jksJtd S )N)r  rZ   r  r  r1   )Z
chunk_infoZknown)cir   r   callback  s
    
z!test_chunk_iter.<locals>.callback)r  r  rJ   r   r   r  rU   r  rZ   r  r  r  Z
chunk_iter)r  r  r   r  Z
num_chunksr  r   r  r   )r  r   test_chunk_iter  s     


r  c             C   s.   | j ddd}|jd kst|jd ks*td S )Nr  r   )r4   )r   r'   rZ   r   )r   r"   r   r   r   test_empty_shape%  s    r  c           	   C   s   ddl m}  |  }t|d}|jddd W d Q R X |d t|dD}|d jd ksbt|d j	 d ksxt|d j
 dkstW d Q R X d S )Nr   )r  r   r  r  )r4   r  )r  r  rJ   r   r   r  r   rZ   rU   Z
get_offsetZget_storage_size)r  r  r  r  r   r   r   test_zero_storage_size+  s    
r  c             C   s   t t jjt t jjd g}| jd|t jd}|jt t jksHtt j	|d d  t j
|t jd ||d d < t j	|d d  t j
|t jd d S )Nr   r   )rH   r4   )r4   )r5   Ziinfor   maxr   Zuint64r4   rZ   r   r   rh   )r   rH   r"   r   r   r   test_python_int_uint649  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 )NrH   )r|   i  rB   )r4      )r|   rN   rB   )r1   r   rB   r   .)r   r5   r  r
  r  )r   r   blockr   r   r   test_setitem_fancy_indexingG  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   rZ   )r   r   r   r   test_vlen_spacepadN  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   rZ   )r   r   r   r   test_vlen_nulltermS  s    r  )r   r/   rN   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   rH   )r/   r/   T)r'   r4   r   Zallow_unknown_filter)r   r5   r  r!   _filtersrZ   )r   Zfake_filter_idr"   r   r   r   test_allow_unknown_filterX  s
    
r  c           
   C   s   ddl m}  |  }t|dV}|jdddddd	d
d}|j  }|j  dd |ksdt	|dkspt	W dQ R X |
d t|dT}|jddddddd}|j  }|j  dd |kst	|dkst	W dQ R X dS )z2Chunk cache configuration for individual datasets.r   )r  r   r   )r/   r{   )r|   r   r   i    g?i  )r'   r   r4   rdcc_nbytesrdcc_w0rdcc_nslotsr   N)i  i    g?r  i  0 gq=
ףp?i  )r'   r4   r  r  r  )i  i  0 gq=
ףp?)r  r  rJ   r   r   rU   r   Zget_chunk_cacheZ	get_cacherZ   r  r   )r  r  r  r"   Zds_chunk_cacher  r   r   r   test_dset_chunk_cachef  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sHtt||k||kksbtd}t	|| }t||k||kkstt||k||kkstdS )z
        Create a h5py dataset, extract one element convert to numpy
        Check that it returns symmetric response to == and !=
        )rw   r   r  )r4   rH   r   gMbP?N)
r   r   r  r5   r
  r  r  r   rZ   Znanmax)r   r'   r(   valdeltaZ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<t||k||kksPtdS )z
        Create a h5py dataset and check basetype compatibility.
        Check that operation is symmetric, even if it is potentially
        not meaningful.
        )rw   r   r  )r4   rH   g        N)r   r   r  r5   r
  r  rZ   )r   r'   r(   r  r   r   r   test_basetype_commutative  s    z)TestCommutative.test_basetype_commutativeN)r   r   r   r$   r  r  r   r   r   r   r  |  s   r  c               @   sH   e Zd ZdZejejdk dddd Zejejdk dddd Z	d	S )
TestVirtualPrefixz%
    Test setting virtual prefix
    )r   r/   rB   z8Virtual prefix does not exist before HDF5 version 1.10.2)r  c             C   sR   d}d}| j jd|ttjj| |d}t|j	 
   }||ksNtd S )N)rw   r   z/path/to/virtualr  )r4   rH   virtual_prefix)r   r   r  r5   r
  r  r  r  rU   r   get_virtual_prefixr"  r#  rZ   )r   r'   r  r(   virtual_prefix_readbackr   r   r   test_virtual_prefix_create  s    
z,TestVirtualPrefix.test_virtual_prefix_createc             C   s^   d}| j jddd|d}t|j    }| 	|| | 
|t | 	|jd d S )Nz/path/to/virtualr   )r/   rN   r   )r  )r   r   r  r  rU   r   r  r"  r#  r&   r   r   r'   )r   r  r(   r  r   r   r   test_virtual_prefix_require  s    z-TestVirtualPrefix.test_virtual_prefix_requireN)
r   r   r   r$   r   rE   r   r  r  r   r   r   r   r   r    s
   r  )`r$   r  r)  rs  numpyr5   r;   r=   r  commonr   r   
data_filesr   rJ   r   r   r   Zh5py._hl.baser	   r
   r   Zh5py.h5py_warningsr   r   Zh5py._hl.selectionsr   Z
selectionsselr   r   r%   rG   rv   r   r   r   r   r   r   r  r   r   r  r  r  r}  r   r   rE   filtersr  r   r   r   r   r   r   r  r  r7  rD  rT  r`  rm  rq  rw  r|  r  r  r  r  r  r  r>   r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  Zskipifr  r  r  r  r   r   r   r   <module>   s   	FY0(CC&,'qc,D QO
0 

-