
    d                     t    d dl Zd dlZd dlmZ ddlmZmZ  G d dej                  Z G d de          ZdS )	    N)h5t   )TestCaseutc                       e Zd ZdZd Zd ZdS )TestCompoundzG
        Feature: Compound types can be created from Python dtypes
    c                 &   t          j        dt          j        fdg          }t	          j        |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t2s        3lib/python3.11/site-packages/h5py/tests/test_h5t.pytest_refzTestCompound.test_ref   s     XT^,l;<<mB---$$Q'')<)<Q)?)?BS_---S^,,,..q111555..q113?3K3K3M3MNNNNN    c                    d}g dg dg dd}t          j        |          }t          j        t          j        |          }t          |d         |d         |d                   D ]Y\  }}}|                    t          |t                    r|	                    d	          n||t          j
        |                     Z|                     |j        |           |                     |j        j        |           d S )
N   )f1f2f3)r   z<i4<f8)r         )namesformatsoffsetsr)   r+   r*   utf8)r   r   r   createCOMPOUNDzipinsert
isinstancestrencoder   r   itemsize)r   size	type_dictexpected_dtyper   nameoffsetr   s           r   test_out_of_order_offsetsz&TestCompound.test_out_of_order_offsets#   s   ''',,,!zz
 
	 ),,jt,, #'"Ii$8)I:N!
 !
 	 	D&" JJ'1$'<'<FF###$b!!    	N333+T22222r    N)__name__
__module____qualname____doc__r   r:    r    r   r   r      s?         	O 	O 	O3 3 3 3 3r    r   c                       e Zd ZdZd ZdS )TestTypeFloatIDzTest TypeFloatID.c                    |                                                                  }d}d}d}d}d}d}t          j        g dg dg d	g d
gt          j                  }t          j        g dg dg dg dgt          j                  }	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          j        |d          }||         dd         }t          j                            ||           |                     |j        t          j        d                     ||         dd         }t          j                            ||	           |                     |j        t          j        d                     ||         }	 |                     |j        t          j        d                     n=# t4          $ r0 |                     |j        t          j        d                     Y nw xY w||         }|                     |j        t          j        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  >)rE   gϽ >g;c  =笃>g4-  >gt  =g4  =)rE   g]  >g;'>g  (>g% (=gi  h=g  ݽ)rE   gSdݽgjg@  H>g?>g6  0>g<  >)r   )rE   g[_>gؽg  8=gT p  =g =g4'ӽ)rE   g&1  =g3  
>g/=gI/>gX>g׽)rE   gb9  P>g43?	>g   >gcE/=g[>g(e   =)rE   g[~=rF   g(e   =g׺ 0=g   >g~,=   	      r      5         
   i  rNr   z<f2r&   )mktempr3   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valuess                      r   test_custom_float_promotionz+TestTypeFloatID.test_custom_float_promotion>   s\    ,,.. + + ++ + +, , ,+ + +, 46:? ? ?  - - -- - -, , ,, , ,- 57J@ @ @ hoom,,&&t,, $$&&"aAq)))xsGVU;;

48<u555 .%%''2q!Q***"xsHgu==

48<v666 .%%''2r1a,,,"xsHgu==

48<v666 .%%''2r1a,,,#xsHgu==

48<v666 xsHc.@%HH

48<v666 ImS)) 7AAA

%%fe444rx777 8QQQ

%%ff555rx777 {	:TZ%9999 	: 	: 	:TZ%99999	: {RXe__555 {R]33333s   9-U' '7V! V!N)r;   r<   r=   r>   rw   r?   r    r   rA   rA   ;   s.        ~4 ~4 ~4 ~4 ~4r    rA   )	numpyr   r   r   commonr   r   r   rA   r?   r    r   <module>rz      s                              &3 &3 &3 &3 &32; &3 &3 &3RA4 A4 A4 A4 A4h A4 A4 A4 A4 A4r    