B
    d4                 @   s:   d dl Z ddlmZ dddZdd ZG d	d
 d
eZdS )    N   )TestCase   c             C   s   | j  | dkS )Nr   )idZ
get_offset)datasetoffset r   P/var/www/html/venv/lib/python3.7/site-packages/h5py/tests/test_file_alignment.py
is_aligned   s    r
   c             C   s   d| dS )NdataZ03r   )ir   r   r	   dataset_name
   s    r   c               @   s(   e Zd ZdZdd Zdd Zdd ZdS )	TestFileAlignmentzn
        Ensure that setting the file alignment has the desired effect
        in the internal structure.
    c          	   C   sh   |   }d}t|dF}x>tdD ]*}|jt||dd}||d< t|s$P q$W tdW d Q R X d S )N)iq  wi  uint8)dtype.z(Data was all found to be aligned to 4096)mktemph5pyFilerangecreate_datasetr   r
   RuntimeError)selffnameshapeh5filer   r   r   r   r	   test_no_alignment_set   s    z'TestFileAlignment.test_no_alignment_setc          
   C   s   d}d}xtdD ]l}|   }tj|d||dH}x@tdD ]4}|jt||dd}|d |d	< t||d
s8tq8W W d Q R X qW d S )Ni  i   ))i	  )i  )i  r   )alignment_thresholdalignment_intervalr   )r      .)r   )r   r   r   r   r   r   r
   AssertionError)r   r   r   r   r   r   r   r   r   r   r	   "test_alignment_set_above_threshold.   s    

z4TestFileAlignment.test_alignment_set_above_thresholdc          
   C   s   d}d}x~dD ]v}|   }tj|d||dR}xJtdD ].}|jt||dd}||d< t||d	s8P q8W td
| dW d Q R X qW d S )Ni  i   ))iq  )i  r   )r   r   r   )r   .)r   z$Data was all found to be aligned to z. This is highly unlikely.)r   r   r   r   r   r   r
   r   )r   r   r   r   r   r   r   r   r   r   r	   "test_alignment_set_below_thresholdG   s    

z4TestFileAlignment.test_alignment_set_below_thresholdN)__name__
__module____qualname____doc__r   r!   r"   r   r   r   r	   r      s   r   )r   )r   commonr   r
   r   r   r   r   r   r	   <module>   s   
