o
    2h                     @   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)logicalr   r   N)npdtypeh5py	ref_dtyper   	py_createget_member_typeassertEqualSTD_REF_OBJ
IEEE_F32LEget_member_offsetget_size)selfdttidt1t2 r   N/var/www/html/chatgem/venv/lib/python3.10/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	d
D ]\}}}|t|tr9|	dn||t
| q(| |j| | |jj| d S )N   )f1f2f3)r	   z<i4<f8)r         )namesformatsoffsetsr%   r'   r&   T)strictutf8)r   r   r   createCOMPOUNDzipinsert
isinstancestrencoder   r   itemsize)r   size	type_dict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   r7   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w || }| |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  >)r?   gϽ >g;c  =笃>g4-  >gt  =g4  =)r?   g]  >g;'>g  (>g% (=gi  h=g  ݽ)r?   gSdݽgjg@  H>g?>g6  0>g<  >)r   )r?   g[_>gؽg  8=gT p  =g =g4'ӽ)r?   g&1  =g3  
>g/=gI/>gX>g׽)r?   gb9  P>g43?	>g   >gcE/=g[>g(e   =)r?   g[~=r@   g(e   =g׺ 0=g   >g~,=   	      r      5         
   i  rNr	   z<f2r"   )mktempr0   r   arrayfloat32r   h5fr*   h5screate_simpler   
IEEE_F16LEcopy
set_fieldsset_size	set_ebiaslockh5dwriteALLNATIVE_LDOUBLEFiletestingassert_array_equalr   r   AttributeError
longdouble)r   test_filenamedatasetdataset2dataset3dataset4dataset5dimswdatawdata2fidspacemytypedsetmytype2mytype3mytype4fvaluesr   r   r   test_custom_float_promotion>   s   













z+TestTypeFloatID.test_custom_float_promotionN)r8   r9   r:   r;   rq   r   r   r   r   r<   ;   s    r<   )	numpyr   r   r   commonr   r   r   r<   r   r   r   r   <module>   s   	)