a
    v=ic                     @   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   d/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/h5py/tests/test_h5t.pytest_ref   s    zTestCompound.test_refc                 C   s   d}g dg dg dd}t |}ttj|}t|d |d |d D ]2\}}}|t|trn|	d	n||t
| qL| |j| | |jj| d S )
N   )f1f2Zf3)r	   z<i4<f8)r         )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   s6  |    }d}d}d}d}d}d}tjg dg dg d	g d
gtjd}tjg dg dg dg dgtjd}	tj|}
t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 |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 |d |  tj|
|||}|tjjtjj|	 ~tj|
|t
j|}|tjjtjj|	 ~~~
t|d}|| dd }tj|| | |jtd || dd }tj||	 | |jtd || }z| |jtd W n( ty   | |jtd Y n0 || }| |jtd || }| |jtj dS )z@Custom floats are correctly promoted to standard floats on read.s   DS1s   DS2s   DS3s   DS4s   DS5)      )a  g>g];>=gq=gg=g  `ӽgZF  >)r4   gϽ >g;c  =笃>g4-  >gt  =g4  =)r4   g]  >g;'>g  (>g% (=gi  h=g  ݽ)r4   gSdݽgjg@  H>g?>g6  0>g<  >)r   )r4   g[_>gؽg  8=gT p  =g =g4'ӽ)r4   g&1  =g3  
>g/=gI/>gX>g׽)r4   gb9  P>g43?	>g   >gcE/=g[>g(e   =)r4   g[~=r5   g(e   =g׺ 0=g   >g~,=   	      r      5         
   i  rNr	   z<f2r   )mktempr'   r
   array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dataset5dimsZwdataZwdata2Z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   rM   r   r   r   r   r1   ;   s   r1   )	numpyr
   r   r   commonr   r   r   r1   r   r   r   r   <module>
   s
   )