U
    md                     @   sR   d dl Zd dlZd dlmZ ddlmZmZ G dd dejZG dd deZdS )	    N)h5t   )TestCaseutc                   @   s    e Zd ZdZdd Zdd ZdS )TestCompoundzG
        Feature: Compound types can be created from Python dtypes
    c                 C   s   t dtjfdg}tj|dd}|d|d }}| |tj | |tj	 | |
dd | |
dtj  dS )zL Reference types are correctly stored in compound types (issue 144)
        a)b<f4T)Zlogicalr   r   N)npdtypeh5pyZ	ref_dtyper   	py_createZget_member_typeassertEqualZSTD_REF_OBJZ
IEEE_F32LEZget_member_offsetget_size)selfdttidt1t2 r   L/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/h5py/tests/test_h5t.pytest_ref   s    zTestCompound.test_refc                 C   s   d}dddgdddgdd	d
gd}t |}ttj|}t|d |d |d D ]2\}}}|t|trt|	dn||t
| qR| |j| | |jj| d S )N   f1f2Zf3r	   z<i4<f8r         )namesformatsoffsetsr   r    r   utf8)r
   r   r   createZCOMPOUNDzipinsert
isinstancestrencoder   r   itemsize)r   sizeZ	type_dictZexpected_dtyper   nameoffsetr   r   r   r   test_out_of_order_offsets#   s&    
  z&TestCompound.test_out_of_order_offsetsN)__name__
__module____qualname____doc__r   r,   r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdd ZdS )TestTypeFloatIDzTest TypeFloatID.c                 C   s  |    }d}d}d}d}d}d}tjddd	d
dddgdddddddgdddddddgdddddddggtjd }tjdd!d"d#d$d%d&gdd'd(d)d*d+d,gdd-d.d/d0d1d2gdd3dd4d5d6d7ggtjd }	tj|}
tj	|}t
j }|d8d9d:d;d9 |d< |d= |  tj|
|||}|tjjtjj| ~t
j }|d>d9d?d;d9 |d< |d= |  tj|
|||}|tjjtjj|	 ~t
j }|d>d@d:d;d@ |d< |d> |  tj|
|||}|tjjtjj|	 ~t
j }|d>d@d:d;d@ |d< |dA |  tj|
|||}|tjjtjj|	 ~tj|
|t
j|}|tjjtjj|	 ~~~
t|dB}|| dCdC }tj|| | |jtdD || dCdC }tj||	 | |jtdD || }z| |jtdE W n* tk
rN   | |jtdD Y nX || }| |jtdF || }| |jtj dCS )Gz@Custom floats are correctly promoted to standard floats on read.s   DS1s   DS2s   DS3s   DS4s   DS5)      ga  g>g];>=gq=gg=g  `ӽgZF  >gϽ >g;c  =g>g4-  >gt  =g4  =g]  >g;'>g  (>g% (=gi  h=g  ݽgSdݽgjg@  H>g?>g6  0>g<  >)r   g[_>gؽg  8=gT p  =g =g4'ӽg&1  =g3  
>g/=gI/>gX>g׽gb9  P>g43?	>g   >gcE/=g[>g(e   =g[~=g(e   =g׺ 0=g   >g~,=   	      r      5         
   i  rNr	   z<f2r   )mktempr'   r
   arrayZfloat32r   Zh5fr"   Zh5sZcreate_simpler   Z
IEEE_F16LEcopyZ
set_fieldsZset_sizeZ	set_ebiaslockZh5dwriteALLZNATIVE_LDOUBLEFiletestingZassert_array_equalr   r   AttributeErrorZ
longdouble)r   Ztest_filenameZdatasetZdataset2Zdataset3Zdataset4Zdataset5ZdimsZwdataZwdata2fidspaceZmytypeZdsetZmytype2Zmytype3Zmytype4fvaluesr   r   r   test_custom_float_promotion>   s    
        
        











z+TestTypeFloatID.test_custom_float_promotionN)r-   r.   r/   r0   rJ   r   r   r   r   r1   ;   s   r1   )	numpyr
   r   r   commonr   r   r   r1   r   r   r   r   <module>
   s
   )