U
    md4                     @   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   W/home/sam/Atlas/atlas_env/lib/python3.8/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   sf   |   }d}t|dD}tdD ],}|jt||dd}||d< t|s" qXq"tdW 5 Q R X d S )Niq  w  uint8Z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   sz   d}d}dD ]h}|   }tj|d||dD}tdD ]4}|jt||dd}|d |d	< t||d
s4tq4W 5 Q R X qd S )Nr   r   ))i	  )r   )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}dD ]t}|   }tj|d||dP}tdD ]0}|jt||dd}||d< t||d	s4 qvq4td
| dW 5 Q R X qd S )Nr   i   )r   )i  r   r    r   r   .r$   z$Data was all found to be aligned to z. This is highly unlikely.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   
