
    1Vh<                    
   d Z ddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZ ddlmZ ddlmZmZmZ ddlmZmZ ddlmZmZ dd	lmZ dd
lmZ ddlZddlmc mZ ddlmZ  G d de      Z  G d de       Z! G d de       Z" G d de       Z# G d d      Z$ G d d      Z% G d de       Z& G d de       Z' G d de       Z( G d de       Z)ejT                  jW                  d e,dfejZ                  dfej\                  dfe/d!fej`                  d!fejb                  d!f ejd                  d"d#$      d%f ejd                  d&d#$      d%f ejd                  d"'      d%f ejd                  d&'      d%f ejd                         d%fg      d(        Z3 G d) d*e       Z4 e
jj                  d+ejl                  jn                  vd,       G d- d.e              Z8 e
jj                  d+ejl                  jn                  vd,       G d/ d0e              Z9 e
jj                  d1ejl                  jn                  vd2       G d3 d4e              Z: e
jj                  d5ejl                  jn                  vd6       G d7 d8e              Z; e
jj                  d9ejl                  jn                  vd:       G d; d<e              Z< e
jj                  d=ejl                  jn                  vd>       G d? d@e              Z= e
jj                  dAejl                  jn                  vdB       G dC dDe              Z> G dE dFe       Z? G dG dHe       Z@ G dI dJe       ZA G dK dLe       ZB G dM dNe       ZC G dO dPe       ZD G dQ dRe       ZE G dS dTe       ZF G dU dVe       ZG G dW dXe       ZH G dY dZe       ZI G d[ d\e       ZJ G d] d^e       ZK G d_ d`e       ZL G da dbe       ZMejT                  j                  ej2                  j                  dck(  dde      ZP G df dge       ZQ G dh die       ZR G dj dke       ZS G dl dme       ZT G dn doe       ZUdp ZV e
j                  ej2                  j                  dqk\  xs4 ej2                  j                  drk\  xr ej2                  j                  dsk  dt      du        ZXdv ZYdw ZZdx Z[dy Z\dz Z]d{ Z^d| Z_d} Z` G d~ de       Za G d de       ZbddZcddZdejT                  jW                  dd ecfd ecfd ecfd edfgg d      Zeedk  rdndZfejT                  jW                  ddefg      eed               ZgejT                  j                  edk  de      eed               Zieed        Zjeed        Zkeed        Zleed        Zmy)z
    Dataset testing operations.

    Tests all dataset operations, including creation, with the exception of:

    1. Slicing operations for read and write, handled by module test_slicing
    2. Type conversion for read and write (currently untested)
    N   )utTestCase)get_data_file_path)FileGroupDataset)is_empty_dataspaceproduct)h5fh5t)H5pyDeprecationWarning)version)NUMPY_RELEASE_VERSIONc                       e Zd Zd Zd Zy)BaseDatasetc                 B    t        | j                         d      | _        y )Nw)r   mktempfselfs    G/home/dcms/DCMS/lib/python3.12/site-packages/h5py/tests/test_dataset.pysetUpzBaseDataset.setUp'   s    dkkmS)    c                 R    | j                   r| j                   j                          y y N)r   closer   s    r   tearDownzBaseDataset.tearDown*   s    66FFLLN r   N)__name__
__module____qualname__r   r    r   r   r   r   &   s    *r   r   c                   "    e Zd ZdZd Zd Zd Zy)TestReprz5
        Feature: repr(Dataset) behaves sensibly
    c                 `    | j                   j                  ddd      }t        |      dk(  sJ y )Nfoo   int32dtypez,<HDF5 dataset "foo": shape (4,), type "<i4">r   create_datasetreprr   dss     r   test_repr_basiczTestRepr.test_repr_basic4   s0    VV""5$g">BxIIIIr   c                     | j                   j                  dd      }| j                   j                          t        |      dk(  sJ y)z( repr() works on live and dead datasets r'   r(   z<Closed HDF5 dataset>N)r   r.   r   r/   r0   s     r   test_repr_closedzTestRepr.test_repr_closed8   s8    VV""5$/Bx2222r   c                 `    | j                   j                  d dd      }t        |      dk(  sJ y )Nr(   r*   r+   z2<HDF5 dataset (anonymous): shape (4,), type "<i4">r-   r0   s     r   test_repr_anonymouszTestRepr.test_repr_anonymous>   s0    VV""4W"=BxOOOOr   N)r    r!   r"   __doc__r2   r4   r6   r#   r   r   r%   r%   /   s    J3Pr   r%   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Z ej                   eed
       d      d        Zd Zy)TestCreateShapez@
        Feature: Datasets can be created from a shape only
    c                 t    | j                   j                  dd      }| j                  |j                  d       y)z Create a scalar dataset r'   r#   Nr   r.   assertEqualshaper   dsets     r   test_create_scalarz"TestCreateShape.test_create_scalarI   s,    vv$$UB/R(r   c                 t    | j                   j                  dd      }| j                  |j                  d       y)z Create a size-1 dataset r'   r   Nr;   r>   s     r   test_create_simplez"TestCreateShape.test_create_simpleN   s,    vv$$UD1T*r   c                 t    | j                   j                  dd      }| j                  |j                  d       y)z+ Create a size-1 dataset with integer shaper'   r   rB   Nr;   r>   s     r   test_create_integerz#TestCreateShape.test_create_integerS   s,    vv$$UA.T*r   c                 T   | j                   j                  dd      }| j                  |j                  d       | j                  |j                  d       | j                   j                  dd      }| j                  |j                  d       | j                  |j                  d       y) Create an extended dataset r'   ?   rI   bar   
   <   Nr   r.   r<   r=   sizer>   s     r   test_create_extendedz$TestCreateShape.test_create_extendedX   s~    vv$$UE2U+B'vv$$UG4W-R)r   c                 T   | j                   j                  dd      }| j                  |j                  d       | j                  |j                  d       | j                   j                  dd      }| j                  |j                  d       | j                  |j                  d       y)rG   r'   rI   rH   rJ   rK   rN   NrO   r>   s     r   test_create_integer_extendedz,TestCreateShape.test_create_integer_extendeda   s~    vv$$UB/U+B'vv$$UG4W-R)r   c                     | j                   j                  dd      }| j                  |j                  t	        j                  d             y)) Confirm that the default dtype is float r'   rH   z=f4Nr   r.   r<   r,   npr>   s     r   test_default_dtypez"TestCreateShape.test_default_dtypej   s4    vv$$UE2RXXe_5r   c                     | j                  t              5  | j                  j                  d       ddd       y# 1 sw Y   yxY w)z  Missing shape raises TypeError r'   NassertRaises	TypeErrorr   r.   r   s    r   test_missing_shapez"TestCreateShape.test_missing_shapeo   s7    y) 	)FF!!%(	) 	) 	)s	   ;Ac                 0   | j                   j                  ddt        j                        }t	        j
                         dv r*t        j                  dt	        j
                         z         | j                  |j                  t        j                         y)rU   r'   rH   r+   )ppc64lez(Storage of long double deactivated on %sN)
r   r.   rW   
longdoubleplatformmachinepytestxfailr<   r,   r>   s     r   test_long_doublez TestCreateShape.test_long_doublet   se    vv$$UE$G,LLChFVFVFXXYR]]3r   
complex256zNo support for complex256c                     | j                   j                  ddt        j                  d            }| j	                  |j                  t        j                  d             y)rU   r'   rH   rf   r+   N)r   r.   rW   r,   r<   r>   s     r   test_complex256zTestCreateShape.test_complex256{   sK     vv$$UE+-88L+A % CRXXl%;<r   c                     | j                   j                  dd      }| j                  |j                  d       | j                   j                  dd      }| j                  |j                  d       y )Ns   foorB   s   bar/baz   r;   r   r?   dset2s      r   test_name_byteszTestCreateShape.test_name_bytes   sV    vv$$VT2T*%%j$7d+r   N)r    r!   r"   r7   r@   rC   rE   rQ   rS   rX   r]   re   r   skipIfhasattrrW   rh   rn   r#   r   r   r9   r9   C   sa    )
+
+
**6
)
4 RYY72|,,.IJ= K=,r   r9   c                   ^    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zy)TestCreateDatazA
        Feature: Datasets can be created from existing data
    c                     t        j                  dd      }| j                  j                  d|      }| j	                  |j
                  |j
                         y)z- Create a scalar dataset from existing array r#   r   r'   dataNrW   onesr   r.   r<   r=   r   ru   r?   s      r   r@   z!TestCreateData.test_create_scalar   sC    wwr3vv$$U$6TZZ0r   c                     t        j                  dd      }| j                  j                  d|      }| j	                  |j
                  |j
                         y)z/ Create an extended dataset from existing data rH   r   r'   rt   Nrv   rx   s      r   rQ   z#TestCreateData.test_create_extended   sC    wwuc"vv$$U$6TZZ0r   c                     | j                   j                  ddd      }| j                  |t        j                         | j                  d| j                   v        y)z1 Create dataset with missing intermediate groups z/foo/bar/bazrM   rM   z<i4)r=   r,   N)r   r.   assertIsInstanceh5pyr	   
assertTruer0   s     r   test_dataset_intermediate_groupz.TestCreateData.test_dataset_intermediate_group   sF    VV"">"Ob$,,/$&&01r   c                     t        j                  dd      }| j                  j                  dd|      }| j	                  |j
                  d       | j                  |d   |j                  d             y)	z8 Create from existing data, and make it fit a new shape    r   r+   r'   rM      r=   ru   .N)rW   aranger   r.   r<   r=   assertArrayEqualreshaperx   s      r   test_reshapezTestCreateData.test_reshape   s^    yy3'vv$$U'$EW-d3ig)>?r   c                     | j                  t              5  t        | j                  d   j                         ddd       y# 1 sw Y   yxY w)zE Binding Dataset to a non-DatasetID identifier fails with ValueError /N)r[   
ValueErrorr	   r   idr   s    r   test_appropriate_low_level_idz,TestCreateData.test_appropriate_low_level_id   s9    z* 	$DFF3KNN#	$ 	$ 	$s   #AAc                    |j                   j                         }t        |t        j                        sJ |j                         |k(  sJ ||j                         sJ y |j                         rJ |j                         |k(  sJ y r   )r   get_type
isinstancer   TypeStringIDget_csetis_variable_strget_size)r   r?   csetlengthtids        r   check_h5_stringzTestCreateData.check_h5_string   s{    gg #s//000||~%%%>&&(((**,,,<<>V+++r   c           	      j     fd} | j                   j                  dd              | j                   j                  dddg              | j                   j                  ddgdgg              | j                   j                  dt        j                  ddgt        	                   y
)z= Creating dataset with byte string yields vlen ASCII dataset c                 J    j                  | t        j                  d        y Nr   )r   r   
CSET_ASCIIr?   r   s    r   check_vlen_asciiz?TestCreateData.test_create_bytestring.<locals>.check_vlen_ascii   s      s~~d Cr   a   abcrt   b   defcdr+   Nr   r.   rW   arrayobject)r   r   s   ` r   test_create_bytestringz%TestCreateData.test_create_bytestring   s    	D..s.@A..s&&9I.JK..s6(VH9M.NO..bhh/v> / 
 	r   c                     | j                   j                  dt        j                  ddgd            }| j	                  |t
        j                  d       y )	Nr   r   r   S3r+   rt   r   r   )r   r.   rW   r   r   r   r   r>   s     r   test_create_np_szTestCreateData.test_create_np_s   sE    vv$$Srxx8HPT/U$VT3>>!<r   c           	      j     fd} | j                   j                  dd              | j                   j                  dddg              | j                   j                  ddgdgg              | j                   j                  dt        j                  ddgt        	                   y )
Nc                 J    j                  | t        j                  d        y r   )r   r   	CSET_UTF8r   s    r   check_vlen_utf8z;TestCreateData.test_create_strings.<locals>.check_vlen_utf8   s      s}}T Br   r   abcrt   r   defr   r   r+   r   )r   r   s   ` r   test_create_stringsz"TestCreateData.test_create_strings   s    	C--c->?--c-GH--c%5'8J-KL--bhhu~V< . 
 	r   c                     | j                  t              5  | j                  j                  dt	        j
                  ddgd             d d d        y # 1 sw Y   y xY w)Nr   r   r   U3r+   rt   )r[   r\   r   r.   rW   r   r   s    r   test_create_np_uzTestCreateData.test_create_np_u   sP    y) 	TFF!!#BHHff5ET,R!S	T 	T 	Ts   5AAc                     | j                   j                  dd       | j                  t        | j                   d   j                               y )Nr'   r   r+   )r   r.   r~   r
   r   r   s    r    test_empty_create_via_None_shapez/TestCreateData.test_empty_create_via_None_shape   s9    e3/*466%=+;+;<=r   c                     | j                   j                  dt        j                  d             | j	                  t        | j                   d   j                               y )Nr'   r   r+   rt   )r   r.   r}   Emptyr~   r
   r   r   s    r   !test_empty_create_via_Empty_classz0TestCreateData.test_empty_create_via_Empty_class   sB    e$**3*?@*466%=+;+;<=r   c                     | j                  t              5  | j                  j                  ddt	        j
                  d             d d d        y # 1 sw Y   y xY w)NrJ   r)   r   r   )r[   r   r   r.   rW   r   r   s    r   test_create_incompatible_dataz,TestCreateData.test_create_incompatible_data   sJ    z* 	FFF!!%q		!!E	F 	F 	Fs   2AAN)r    r!   r"   r7   r@   rQ   r   r   r   r   r   r   r   r   r   r   r   r#   r   r   rr   rr      sK    112@$
,	=T>>Fr   rr   c                      e Zd ZdZej
                  j                  dddej                  dd ej                  dd fddej                  dd ej                  d	d
 fddej                  d
dd
d
f   ej                  d
d
d
df   fddej                  dd
ddf   ej                  d
d
 fg      d        Z	d Z
d Zd Zd Zd Zy
)TestReadDirectlyzI
        Feature: Read data directly from Dataset into a Numpy array
    +source_shape,dest_shape,source_sel,dest_seld   r   rM   2   rN   F   Z   Nr   rM      r   r         	   rL   rk   rL   r   c                 P   t        j                  t        |      d      j                  |      }|j	                  d||      }t        j
                  |dd      }|j                         }	||   |	|<   |j                  |||       t         j                  j                  ||	       y )Nint64r+   r?   rt   )
rW   r   r   r   r.   fullcopyread_directtestingassert_array_equal)
r   writable_filesource_shape
dest_shape
source_seldest_selsource_valuesr?   arrexpecteds
             r   test_read_directz!TestReadDirectly.test_read_direct   s     		',"7wGOOP\]++FL}+Uggj"G488:*:6j(3


%%c84r   c                    |j                  ddt        j                  dd            }t        j                  dd      }|j	                  |       t        j
                  j                  |t        j                  dd             y )Nr?   rM   rM   r   r+   rt   )r.   rW   r   rw   r   r   r   r   r   r?   r   s       r   test_no_selzTestReadDirectly.test_no_sel   sb    ++FE		"T[@\+]gge7+


%%c299Rw+GHr   c                    |j                  dd      }t        j                  dd      }t        j                  t
              5  |j                  |t        j                  dd t        j                  dd        d d d        y # 1 sw Y   y xY w	Nedsetr   r+   r   r   rM   r   rN   )r.   rW   rw   rc   raisesr\   r   s_)r   r   
empty_dsetr   s       r   
test_emptyzTestReadDirectly.test_empty   sr    "11'1I
ggfg&]]9% 	C""3aRUU2b\B	C 	C 	Cs   6BBc                     |j                  ddd      }t        j                  d      }t        j                  t
              5  |j                  |       d d d        y # 1 sw Y   y xY wNr?   r   r   r+      r.   rW   rw   rc   r   r\   r   r   s       r   test_wrong_shapez!TestReadDirectly.test_wrong_shape  sU    ++FF'+Jggfo]]9% 	"S!	" 	" 	"   AA'c                     |j                  ddd      }t        j                  dd      }t        j                  t
              5  |j                  |       d d d        y # 1 sw Y   y xY wNr?   r{   r   r+   F)orderr   r   s       r   test_not_c_contiguousz&TestReadDirectly.test_not_c_contiguous  sX    ++FHG+Lgghc*]]9% 	"S!	" 	" 	"   A  A)c                    d}|j                  d|t        j                        }t        j                  |t        j                        }|j	                  |       t        j                  dt        j                        }t        j                  t              5  |j	                  |       d d d        y # 1 sw Y   y xY w)N)r   r   r?   r+   )r      )r.   rW   r   zerosr   rc   r   r\   )r   r   r=   r?   r   arr2s         r   test_zero_lengthz!TestReadDirectly.test_zero_length  s    ++FE+JhhuBHH- xxrxx0]]9% 	#T"	# 	# 	#s   B44B=)r    r!   r"   r7   rc   markparametrizerW   r   r   r   r   r   r   r   r#   r   r   r   r      s     [[5VRUU1R["%%2,7FBEE"RL"%%*5xssAva"f>beeArr1HoruuQx8		
55IC""	#r   r   c                      e Zd ZdZej
                  j                  dddej                  dd ej                  dd fddej                  dd ej                  d	d
 fddej                  d
dd
d
f   ej                  d
d
d
df   fddej                  dd
ddf   ej                  d
d
 fg      d        Z	d Z
d Zd Zy
)TestWriteDirectlyz>
        Feature: Write Numpy array directly into Dataset
    r   r   r   rM   r   rN   r   r   Nr   r   r   r   r   rk   rL   r   c                 4   |j                  d|dd      }t        j                  t        |            j	                  |      }t        j
                  |dd      }||   ||<   |j                  |||       t        j                  j                  |d d  |       y )Nr?   r*   r   r,   	fillvaluer+   )	r.   rW   r   r   r   r   write_directr   r   )	r   r   r   r   r   r   r?   r   r   s	            r   test_write_directz#TestWriteDirectly.test_write_direct$  s     ++FJgY[+\ii-.66|D77:r9 _#z84


%%d1gx8r   c                    |j                  dd      }t        j                  t              5  |j	                  t        j                  d      t
        j                  dd t
        j                  dd        d d d        y # 1 sw Y   y xY wr   )r.   rc   r   r\   r  rW   rw   r   )r   r   r   s      r   r   zTestWriteDirectly.test_empty4  sj    "11'1I
]]9% 	P##BGGFORUU1R["%%2,O	P 	P 	Ps   A	A??Bc                     |j                  ddd      }t        j                  d      }t        j                  t
              5  |j                  |       d d d        y # 1 sw Y   y xY wr   r.   rW   rw   rc   r   r\   r  r   s       r   r   z"TestWriteDirectly.test_wrong_shape9  sU    ++FF'+Jggfo]]9% 	#c"	# 	# 	#r   c                     |j                  ddd      }t        j                  dd      }t        j                  t
              5  |j                  |       d d d        y # 1 sw Y   y xY wr   r  r   s       r   r   z'TestWriteDirectly.test_not_c_contiguous?  sX    ++FHG+Lgghc*]]9% 	#c"	# 	# 	#r   )r    r!   r"   r7   rc   r   r   rW   r   r  r   r   r   r#   r   r   r   r     s     [[5VRUU1R["%%2,7FBEE"RL"%%*5xssAva"f>beeArr1HoruuQx8		
99P
##r   r   c                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)TestCreateRequirezS
        Feature: Datasets can be created only if they don't exist in the file
    c                     | j                   j                  ddd      }| j                  |t               | j	                  |j
                  d       y)z& Create new dataset with no conflicts r'   r   r   N)r   require_datasetr|   r	   r<   r=   r>   s     r   test_createzTestCreateRequire.test_createL  s>    vv%%eWc:dG,W-r   c                     | j                   j                  ddd      }| j                   j                  ddd      }| j                  ||       y)z) require_dataset yields existing dataset r'   r   r   Nr   r  r<   rl   s      r   test_create_existingz&TestCreateRequire.test_create_existingR  sB    vv%%eWc:&&ugs;u%r   c                    | j                   j                  ddd      }| j                   j                  ddd      }| j                  ||       | j                   j                  ddd      }| j                   j                  ddd      }| j                  ||       | j                   j                  ddd      }| j                   j                  ddd      }| j                  ||       y)	z; require_dataset with integer shape yields existing datasetr'   rM   r   rJ   r   bazs   bazNr  rl   s      r   test_create_1Dz TestCreateRequire.test_create_1DX  s    vv%%eR5&&ub#6u%vv%%eUC8&&ub#6u%vv%%eR5&&vuc:u%r   c                     | j                   j                  ddd       | j                  t              5  | j                   j	                  ddd       ddd       y# 1 sw Y   yxY w)z6 require_dataset with shape conflict yields TypeError r'   r   r   )rM   r)   Nr   r.   r[   r\   r  r   s    r   test_shape_conflictz%TestCreateRequire.test_shape_conflictf  sQ    eWc2y) 	8FF""5'37	8 	8 	8   AA#c                     | j                   j                  d       | j                  t              5  | j                   j	                  ddd       ddd       y# 1 sw Y   yxY w)z< require_dataset with object type conflict yields TypeError r'   r   r   N)r   create_groupr[   r\   r  r   s    r   test_type_conflictz$TestCreateRequire.test_type_conflictl  sM    E"y) 	8FF""5'37	8 	8 	8s   AA!c                     | j                   j                  ddd      }| j                  t              5  | j                   j	                  ddd       ddd       y# 1 sw Y   yxY w)zL require_dataset with dtype conflict (strict mode) yields TypeError
        r'   r   r   S10Nr  r>   s     r   test_dtype_conflictz%TestCreateRequire.test_dtype_conflictr  sU     vv$$UGS9y) 	:FF""5'59	: 	: 	:r  c                     | j                   j                  ddd      }| j                   j                  dddd      }| j                  ||       y)z* require_dataset with exactly dtype match r'   r   r   TexactN)r   r.   r  r<   rl   s      r   test_dtype_exactz"TestCreateRequire.test_dtype_exacty  sI     vv$$UGS9&&ugs$&Gu%r   c                     | j                   j                  ddd      }| j                   j                  dddd      }| j                  ||       | j                  |j                  t        j                  d             y)zJ require_dataset with convertible type succeeds (non-strict mode)
        r'   r   i4i2Fr   N)r   r.   r  r<   r,   rW   rl   s      r   test_dtype_closez"TestCreateRequire.test_dtype_close  se     vv$$UGT:&&ugt5&Iu%bhhtn5r   N)r    r!   r"   r7   r  r  r  r  r  r  r"  r&  r#   r   r   r  r  F  s/    .&&88:&6r   r  c                   F    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)TestCreateChunkedzL
        Feature: Datasets can be created by manually specifying chunks
    c                 x    | j                   j                  ddd      }| j                  |j                  d       y)z Create via chunks tuple r'   r   r   r=   chunksNr   r.   r<   r+  r>   s     r   test_create_chunksz$TestCreateChunked.test_create_chunks  s1    vv$$U&$Ge,r   c                 x    | j                   j                  ddd      }| j                  |j                  d       y)z Create via chunks integer r'   r   rM   r*  r   Nr,  r>   s     r   test_create_chunks_integerz,TestCreateChunked.test_create_chunks_integer  s1    vv$$U&$De,r   c                     | j                  t              5  | j                  j                  ddd       ddd       y# 1 sw Y   yxY w)z& Illegal chunk size raises ValueError r'   r   r   r*  Nr[   r   r   r.   r   s    r   test_chunks_mismatchz&TestCreateChunked.test_chunks_mismatch  sB    z* 	FFF!!%vf!E	F 	F 	F	   >Ac                     | j                  t              5  | j                  j                  dddd       ddd       y# 1 sw Y   yxY w)z3 Chunked format required for given storage options r'   r   r   F)r=   maxshaper+  Nr1  r   s    r   test_chunks_falsez#TestCreateChunked.test_chunks_false  sD    z* 	RFF!!%us5!Q	R 	R 	R	    ?Ac                     | j                  t              5  | j                  j                  ddd       ddd       y# 1 sw Y   yxY w)z> Attempting to create chunked scalar dataset raises TypeError r'   r#   r   r*  NrZ   r   s    r   test_chunks_scalarz$TestCreateChunked.test_chunks_scalar  sB    y) 	AFF!!%r%!@	A 	A 	Ar3  c                     | j                   j                  ddd      }| j                  |j                  t               | j                  t        |j                        d       y)z Auto-chunking of datasets r'   )r   r   Tr*  rk   N)r   r.   r|   r+  tupler<   lenr>   s     r   test_auto_chunksz"TestCreateChunked.test_auto_chunks  sJ    vv$$U)D$Idkk51T[[)1-r   c                 z    | j                   j                  dddd      }| j                  |j                  d       y)z7 Auto-chunking with pathologically large element sizes r'   r   
S100000000Tr=   r,   r+  rB   Nr,  r>   s     r   test_auto_chunks_abusez(TestCreateChunked.test_auto_chunks_abuse  s4    vv$$U$lSW$Xd+r   c                    | j                   j                  ddt        j                  d      }d|ddddf<   | j	                  t        j
                  |ddddf   dk(               d	|d<   | j	                  t        j
                  |d   d	k(               d
|dd | j	                  t        j
                  |dd d
k(               y)z+ Test scalar assignment of chunked dataset r'   )r   r   r   )r   r   r   rB  rM   r   N(         r   rk   )r   r.   rW   r*   r~   allr>   s     r   test_scalar_assignmentz(TestCreateChunked.test_scalar_assignment  s    vv$$U++-88K % I Q2XtAq"H~345 QtAw"}-. Qq	tAayB/0r   c                 <   t        j                  t        d      5 }| j                  j	                  ddd       ddd       t        j                  t        d      5 }| j                  j	                  ddd	       ddd       y# 1 sw Y   LxY w# 1 sw Y   yxY w)
z, Auto-chunking of empty datasets not allowedr   matchr'   S100T)r,   r+  Nr   r,   r5  )rc   r   r\   r   r.   )r   errs     r   test_auto_chunks_no_shapez+TestCreateChunked.test_auto_chunks_no_shape  s    ]]9G4 	DFF!!%vd!C	D ]]9G4 	DFF!!%v!C	D 	D	D 	D	D 	Ds   BBBBN)r    r!   r"   r7   r-  r/  r2  r6  r:  r>  rC  rI  rP  r#   r   r   r(  r(    s8    -
-
F
R
A
.,
1 Dr   r(  c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)TestCreateFillvaluez>
        Feature: Datasets can be created with fill value
    c                     | j                   j                  ddd      }| j                  |d   d       | j                  |d   d       y)z- Fill value is reflected in dataset contents r'   r         @r  r   r   N)r   r.   r<   r>   s     r   test_create_fillvalz'TestCreateFillvalue.test_create_fillval  sE    vv$$UES$Aa#&a#&r   c                     | j                   j                  ddd      }| j                  |j                  d       | j	                  |j                  t
        j                         y)z( Fill value is recoverable via property r'   r   g      @rU  N)r   r.   r<   r  assertNotIsInstancerW   ndarrayr>   s     r   test_propertyz!TestCreateFillvalue.test_property  sI    vv$$UES$A-  <r   c                 t    | j                   j                  dd      }| j                  |j                  d       y)z0 .fillvalue property works correctly if not set r'   r   r   N)r   r.   r<   r  r>   s     r   test_property_nonez&TestCreateFillvalue.test_property_none  s,    vv$$UE2+r   c                    t        j                  ddg      }t        j                  d|      d   }| j                  j	                  dd||      }| j                  |j                  |       | j                  |d	   |       y
)z& Fill value works with compound types )r   f4)r   i8rB   r+   r   r'   r   r  r)   N)rW   r,   rw   r   r.   r<   r  assertAlmostEqual)r   dtvr?   s       r   test_compoundz!TestCreateFillvalue.test_compound  so    XX{K01GGD#A&vv$$UEq$I+tAw*r   c                     | j                  t              5  | j                  j                  ddddgd      }ddd       y# 1 sw Y   yxY w)z$ Bogus fill value raises ValueError r'   r   r   i)r   r   *   r  Nr1  r>   s     r   test_exczTestCreateFillvalue.test_exc  sQ    z* 	B66((%z2b ) BD	B 	B 	Bs   "AA
N)	r    r!   r"   r7   rV  rZ  r\  rc  rh  r#   r   r   rR  rR    s!    '=,
+Br   rR  c                       e Zd ZdZd Z ej                  dej                  j                  vd      d        Z
d Zd Zd Zd	 Zd
 Zd Zd Zy)TestFillTimezI
        Feature: Datasets created with specified fill time property
    c                 8   | j                   j                  ddd      }|j                  j                         }| j	                  |j                         t        j                  j                         | j	                  |d   d       | j	                  |d   d       y)z Fill time default to IFSET r'   r   rT  rU  r   r   N	r   r.   r   get_create_plistr<   get_fill_timer}   h5dFILL_TIME_IFSETr   r?   plists      r   test_fill_time_defaultz#TestFillTime.test_fill_time_default  sz    vv$$UES$A((*,,.0H0HIa#&a#&r   gzipDEFLATE is not installedc                 :   | j                   j                  dddd      }|j                  j                         }| j	                  |j                         t        j                  j                         | j	                  |d   d       | j	                  |d   d       y)	z5 Fill time is IFSET for compressed dataset (chunked) r'   r   rt  rT  )compressionr  r   r   Nrl  rq  s      r   test_compressed_defaultz$TestFillTime.test_compressed_default   s     vv$$UEv/2 % 4((*,,.0H0HIa#&a#&r   c                 :   | j                   j                  dddd      }|j                  j                         }| j	                  |j                         t        j                  j                         | j                  |d   d       | j                  |d   d       y)	z Fill time set to NEVER r'   r   rT  neverr  	fill_timer   r   N)
r   r.   r   rm  r<   rn  r}   ro  FILL_TIME_NEVERassertNotEqualrq  s      r   test_fill_time_neverz!TestFillTime.test_fill_time_never
  s    vv$$UES/6 % 8((*,,.0H0HIDGS)DGS)r   c                     | j                   j                  dddd      }|j                  j                         }| j	                  |j                         t        j                  j                         y)z# Fill time explicitly set to ALLOC r'   r   rT  allocr{  N)	r   r.   r   rm  r<   rn  r}   ro  FILL_TIME_ALLOCrq  s      r   test_fill_time_allocz!TestFillTime.test_fill_time_alloc  sY    vv$$UES/6 % 8((*,,.0H0HIr   c                     | j                   j                  ddddd      }|j                  j                         }| j	                  |j                         t        j                  j                         y)z# Fill time explicitly set to IFSET r'   r   rj   rT  ifset)r+  r  r|  Nrl  rq  s      r   test_fill_time_ifsetz!TestFillTime.test_fill_time_ifset  s[    vv$$UE$#/6 % 8((*,,.0H0HIr   c                     | j                  t              5  | j                  j                  ddd      }ddd       y# 1 sw Y   yxY w)z2 Choice of fill_time is 'alloc', 'never', 'ifset' r'   r   fill_badr|  Nr1  r>   s     r   test_invalid_fill_timez#TestFillTime.test_invalid_fill_time"  sD    z* 	M66(((LD	M 	M 	Mr3  c                     | j                  t              5  | j                  j                  ddd      }ddd       y# 1 sw Y   yxY w)z fill_time must be a string r'   r   rk   r  Nr1  r>   s     r   test_non_str_fill_timez#TestFillTime.test_non_str_fill_time'  sD    z* 	D66(((CD	D 	D 	Dr3  c                    | j                   j                  dddd      }|j                  j                         }| j	                  |j                         t        j                  j                         t        j                  |dd d      j                         sJ |j                  d       t        j                  |dd d      j                         sJ y)z= The resize dataset will be filled (by default fill value 0) r'   r9  r   r   )r5  r+  N        )r   r.   r   rm  r<   rn  r}   ro  rp  rW   iscloserH  resizerq  s      r   #test_resize_chunk_fill_time_defaultz0TestFillTime.test_resize_chunk_fill_time_default,  s    vv$$UFW,1 % 3((*,,.0H0HIzz$q'3'++---Gzz$q'3'++---r   c                    | j                   j                  dddddd      }|j                  j                         }| j	                  |j                         t        j                  j                         t        j                  |dd d      j                         rJ |j                  d       t        j                  |dd d      j                         rJ y)	z$ The resize dataset won't be filled r'   r9  r   rT  rz  r  )r5  r  r|  r+  N)r   r.   r   rm  r<   rn  r}   ro  r}  rW   r  anyr  rq  s      r   !test_resize_chunk_fill_time_neverz.TestFillTime.test_resize_chunk_fill_time_never8  s    vv$$UFW/2g,1 % 3 ((*,,.0H0HI::d1gs+//111G::d1gs+//1111r   N)r    r!   r"   r7   rs  r   ro   r}   filtersencoderx  r  r  r  r  r  r  r  r#   r   r   rj  rj    se    ' RYYvT\\0002LM' N'*JJM
D

.2r   rj  zdt,expectedr  utf-8r   encodingr   r   asciir  c                 N    |j                  dd|       }|j                  |k(  sJ y )Nr'   r   r+   )r.   r  )ra  r   r   r?   s       r   test_get_unset_fill_valuer  F  s-     ''uB'?D>>X%%%r   c                       e Zd ZdZd Zy)TestCreateNamedTypezC
        Feature: Datasets created from an existing named type
    c                    t        j                  d      | j                  d<   | j                  j                  dd| j                  d         }| j	                  |j                  t        j                  d             | j	                  |j
                  j                         | j                  d   j
                         | j                  |j
                  j                         j                                y)z7 Named type object works and links the dataset to type f8typexr   r+   N)	rW   r,   r   r.   r<   r   r   r~   	committedr>   s     r   
test_namedzTestCreateNamedType.test_named_  s    $vvv$$S&v$GRXXd^4))+TVVF^->->?((*4467r   N)r    r!   r"   r7   r  r#   r   r   r  r  Y  s    8r   r  rt  ru  c                   (    e Zd ZdZd Zd Zd Zd Zy)TestCreateGzipz=
        Feature: Datasets created with gzip compression
    c                     | j                   j                  dddd      }| j                  |j                  d       | j                  |j                  d       y)z# Create with explicit gzip options r'   r   r   rt  r   rw  compression_optsNr   r.   r<   rw  r  r>   s     r   	test_gzipzTestCreateGzip.test_gzipo  sP    vv$$UH&67 % 9))62..2r   c                     | j                   j                  ddd      }| j                  |j                  d       | j                  |j                  d       y)z+ Create with implicit gzip level (level 4) r'   r  rt  rw  r)   Nr  r>   s     r   test_gzip_implicitz!TestCreateGzip.test_gzip_implicitv  sI    vv$$UH&$I))62..2r   c                 ^   | j                   j                  ddd      }| j                  |j                  d       | j                  |j                  d       t
        j                  j                  j                  }	 t               t
        j                  j                  _        | j                  t              5  | j                   j                  ddd      }ddd       |t
        j                  j                  _        y# 1 sw Y   )xY w# |t
        j                  j                  _        w xY w)z. Create with gzip level by specifying integer r'   r  r   r  rt  N)r   r.   r<   rw  r  r}   _hldataset_LEGACY_GZIP_COMPRESSION_VALSr<  r[   r   )r   r?   original_compression_valss      r   test_gzip_numberzTestCreateGzip.test_gzip_number|  s    vv$$UH!$D))62..2$(HH$4$4$R$R!	W=BWDHH:"":. Mvv,,UH!,LM >WDHH:M M >WDHH:s$   <<D 8C?D ?DD !D,c                    | j                  t        t        f      5  | j                  j	                  ddd       ddd       | j                  t              5  | j                  j	                  ddd       ddd       | j                  t              5  | j                  j	                  dddd       ddd       y# 1 sw Y   xY w# 1 sw Y   SxY w# 1 sw Y   yxY w)	z= Illegal gzip level (explicit or implicit) raises ValueError r'   r     r  Nrt  r  )r[   r   RuntimeErrorr   r.   r   s    r   test_gzip_exczTestCreateGzip.test_gzip_exc  s    
L9: 	CFF!!%r!B	Cz* 	CFF!!%r!B	Cz* 	7FF!!%v35 " 7	7 	7		C 	C	C 	C	7 	7s#   B=C	 C=C	CCN)r    r!   r"   r7   r  r  r  r  r#   r   r   r  r  h  s    33W7r   r  c                       e Zd ZdZd Zd Zy)TestCreateCompressionNumberz?
        Feature: Datasets created with a compression code
    c                     t         j                  j                  j                  }	 t	               t         j                  j                  _        | j
                  j                  ddt         j                  j                  d      }|t         j                  j                  _        | j                  |j                  d       | j                  |j                  d       y# |t         j                  j                  _        w xY w)z^ Create with compression number of gzip (h5py.h5z.FILTER_DEFLATE) and a compression level of 7r'   r  )r   r  rt  r   N)r}   r  r  r  r<  r   r.   h5zFILTER_DEFLATEr<   rw  r  )r   r  r?   s      r   test_compression_numberz3TestCreateCompressionNumber.test_compression_number  s    $(HH$4$4$R$R!	W=BWDHH:66((dhhF]F]pt(uD=VDHH:))62..2 >WDHH:s   AC !C=c                    | j                  t              5 }| j                  j                  ddd       ddd       | j	                  dt        j                               | j                  t              5 }| j                  j                  ddd       ddd       | j	                  dt        |j                               t        j                  j                  j                  }	 t               t        j                  j                  _
        | j                  t              5  | j                  j                  ddt        j                  j                         ddd       |t        j                  j                  _
        y# 1 sw Y   PxY w# 1 sw Y   xY w# 1 sw Y   BxY w# |t        j                  j                  _
        w xY w)	z* Create with invalid compression numbers  r'   r  ir  NzInvalid filterr   zUnknown compression)r[   r   r   r.   assertInstr	exceptionr}   r  r  r  r<  
IndexErrorr  r  )r   er  s      r   test_compression_number_invalidz;TestCreateCompressionNumber.test_compression_number_invalid  s]   z* 	EaFF!!%t!D	E&AKK(89z* 	DaFF!!%s!C	D+S-=>$(HH$4$4$R$R!	W=BWDHH: "":. \%%eX488CZCZ%[\ >WDHH:!	E 	E	D 	D\ \ >WDHH:s;   F7F(<F( $7FF( FFF%!F( (!G	N)r    r!   r"   r7   r  r  r#   r   r   r  r    s    
3Wr   r  lzfzLZF is not installedc                       e Zd ZdZd Zd Zy)TestCreateLZF<
        Feature: Datasets created with LZF compression
    c                    | j                   j                  ddd      }| j                  |j                  d       | j                  |j                  d       t        j                  d      }| j                   j                  d|d      }| j                  |j                  d       | j                  |j                  d       | j                   j                          | j                   d   d	   }| j                  ||       y)
z Create with explicit lzf r'   r  r  r  Nr   rJ   )ru   rw  r#   )	r   r.   r<   rw  r  rW   r   flushr   )r   r?   testdatareaddatas       r   test_lzfzTestCreateLZF.test_lzf  s    vv$$UH%$H))51..599S>vv$$Uu$M))51..566%=$h1r   c                     | j                  t              5  | j                  j                  dddd       ddd       y# 1 sw Y   yxY w)z& Giving lzf options raises ValueError r'   r  r  r)   r  Nr1  r   s    r   test_lzf_exczTestCreateLZF.test_lzf_exc  sE    z* 	6FF!!%u34 " 6	6 	6 	6r7  N)r    r!   r"   r7   r  r  r#   r   r   r  r    s    2 6r   r  szipzSZIP is not installedc                       e Zd ZdZd Zy)TestCreateSZIPr  c                 B    | j                   j                  dddd      }y)z Create with explicit szip r'   r  r  )ec   r  N)r   r.   r>   s     r   	test_szipzTestCreateSZIP.test_szip  s%    vv$$UH&6@ % Br   N)r    r!   r"   r7   r  r#   r   r   r  r    s    Br   r  shufflezSHUFFLE is not installedc                       e Zd ZdZd Zy)TestCreateShufflez8
        Feature: Datasets can use shuffling filter
    c                 v    | j                   j                  ddd      }| j                  |j                         y)z Enable shuffle filter r'   r  T)r  N)r   r.   r~   r  r>   s     r   test_shufflezTestCreateShuffle.test_shuffle  s-    vv$$UHd$C%r   N)r    r!   r"   r7   r  r#   r   r   r  r    s    &r   r  
fletcher32zFLETCHER32 is not installedc                       e Zd ZdZd Zy)TestCreateFletcher32z=
        Feature: Datasets can use the fletcher32 filter
    c                 v    | j                   j                  ddd      }| j                  |j                         y)z Enable fletcher32 filter r'   r  T)r  N)r   r.   r~   r  r>   s     r   test_fletcher32z$TestCreateFletcher32.test_fletcher32  s-    vv$$UH$F(r   N)r    r!   r"   r7   r  r#   r   r   r  r    s    )r   r  scaleoffsetzSCALEOFFSET is not installedc                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
TestCreateScaleOffsetz?
        Feature: Datasets can use the scale/offset filter
    c                     | j                  t              5  | j                  j                  ddt        d      }ddd       y# 1 sw Y   yxY w)z[ Ensure that a scale factor is required for scaleoffset compression of floating point data r'   r  Tr,   r  Nr[   r   r   r.   floatr>   s     r    test_float_fails_without_optionsz6TestCreateScaleOffset.test_float_fails_without_options  I     z* 	Y66((SW(XD	Y 	Y 	Y   $AAc                     | j                  t              5  | j                  j                  ddt        d      }ddd       y# 1 sw Y   yxY w)z# Check when scaleoffset is negetiver'   r  gr  Nr  r>   s     r   test_non_integerz&TestCreateScaleOffset.test_non_integer  r  r  c                     | j                  t              5  | j                  j                  ddt        d      }ddd       y# 1 sw Y   yxY w)z% Check when dtype is unsupported typer'   r  Tr  N)r[   r\   r   r.   boolr>   s     r   test_unsupport_dtypez*TestCreateScaleOffset.test_unsupport_dtype  sI     y) 	X66((RV(WD	X 	X 	Xr  c                    d}d}dd|z  z  }t        j                  j                  | dz
  |z  }| j                  j	                  d|t         j
                  |      }|j                  J ||d	<   | j                  j                  }| j                  j                          t        j                  |d
      | _        | j                  d   d	   }| j                  ||d| z         ||k(  j                         rJ y)z2 Scaleoffset filter works for floating point data r)   r   i,  r   rM   g      ?r'   r  N.r)	precision)rW   randomrandr   r.   float64r  filenamer   r}   r   r   rH  )r   scalefacr=   ranger  r?   r  r  s           r   
test_floatz TestCreateScaleOffset.test_float  s     R8^#IINNE*S0E9vv$$UEQY$Z +++ S	66??8S)66%=% 	hBH9<MN (--////r   c                    d}d}t         j                  j                  dd|z  dz
  |t         j                        }| j                  j                  d|t         j                  d	      }|j                  J ||d<   | j                  j                  }| j                  j                          t        j                  |d      | _        | j                  d   d   }| j                  ||       y
)zB Scaleoffset filter works for integer data with default precision rG  r  r   rk   r   rP   r,   r'   Tr  N.r  )rW   r  randintr   r   r.   r  r  r   r}   r   r   r   nbitsr=   r  r?   r  r  s          r   test_intzTestCreateScaleOffset.test_int3  s     99$$QU
QU"(($S vv$$UEt$T +++ S	66??8S)66%=%h1r   c                    d}d}t         j                  j                  dd|z  |t         j                        }| j                  j                  d|t         j                  |      }| j                  |j                  dk(         ||d<   | j                  j                  }| j                  j                          t        j                  |d	      | _        | j                  d   d   }| j                  ||       y
)D Scaleoffset filter works for integer data with specified precision rG  r  r   rk   r  r'   r  .r  N)rW   r  r  r   r   r.   r~   r  r  r   r}   r   r   r  s          r   test_int_with_minbitsz+TestCreateScaleOffset.test_int_with_minbitsH  s     99$$QU
bhh$Ovv$$UEu$U 	((B./ S	66??8S)66%=%h1r   c                    d}d}t         j                  j                  dd|dz   z  dz
  |t         j                        }| j                  j                  d|t         j                  |      }| j                  |j                  dk(         ||d	<   | j                  j                  }| j                  j                          t        j                  |d
      | _        | j                  d   d	   }||k(  j                         rJ y)r  rG  r  r   rk   r   r  r'   r  .r  N)rW   r  r  r   r   r.   r~   r  r  r   r}   r   rH  r  s          r   test_int_with_minbits_lossyz1TestCreateScaleOffset.test_int_with_minbits_lossy\  s     99$$Qeai(81(<5PRPXPX$Yvv$$UEu$U 	((B./ S	66??8S)66%=% (--////r   N)r    r!   r"   r7   r  r  r  r  r  r  r
  r#   r   r   r  r    s-    YYX042*2(0r   r  c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
TestExternalzB
        Feature: Datasets with the external storage property
    c                    d}t         j                  j                  |      }| j                         }|dt        j                  fg}| j
                  j                  d||j                  |d      }||d<   |j                  J t        |d      5 }|j                         }ddd       |j                         k(  sJ t        j                  |j                  j                         j!                         j#                               j%                         }t        j                  | j
                  j&                        j(                  j%                         }	||	k(  sJ y# 1 sw Y   xY w)	z' Create and access an external dataset rL   r   r   r'   z	${ORIGIN}r,   externalefile_prefix.Nrb)rW   r  r   r   	UNLIMITEDr   r.   r,   r  openreadtobytespathlibPathr   get_access_plistget_efile_prefixdecodeas_posixr  parent)
r   r=   r  ext_filer  r?   fidcontentsr  r  s
             r   test_contentszTestExternal.test_contentsw  s)    99##E* ;;=q#--01vv$$UERZit$uS	}}((( (D! 	"SxxzH	"8++----||DGG$<$<$>$O$O$Q$X$X$Z[ddfdffoo.55>>@v%%%	" 	"s   EE&c           	         d}t         j                  j                  |      }| j                         }t        j                  j                  |      dt        j                  fg}| j                  j                  d||j                  |t        j                  j                  |            }||d<   |j                  J t        |d      5 }|j                         }ddd       |j                         k(  sJ t!        j"                  |j$                  j'                         j)                         j+                               j-                         }t!        j"                  |      j.                  j-                         }	||	k(  sJ | j                  j1                  d||j                  t        j                  j                  |            }
|
j                  J |
d	   |k(   y# 1 sw Y   xY w)
z< Create and access an external dataset using an efile_prefixr  r   r'   r  .Nr  )r  r#   )rW   r  r   ospathbasenamer   r  r   r.   r,   dirnamer  r  r  r  r  r  r   r  r  r  r  r  r  )r   r=   r  r  r  r?   r  r   r  r  rm   s              r   test_contents_efile_prefixz'TestExternal.test_contents_efile_prefix  s    99##E* ;;=WW%%h/CMMBCvv$$UERZikipipixix  zB  jC$  DS	}}((( (D! 	"SxxzH	"8++---- ||DGG$<$<$>$O$O$Q$X$X$Z[ddfh'..779v%%%&&ueX^^RTRYRYRaRabjRk&l~~)))b	X	" 	"s   	GG)c                 \    | j                   j                  dd| j                                y)z/ External argument may be a file name str only r'   r  r  N)r   r.   r   r   s    r   test_name_strzTestExternal.test_name_str  s#     	eXFr   c                     | j                   j                  ddt        j                  | j	                                      y)z0 External argument may be a file name path only r'   r  r)  N)r   r.   r  r  r   r   s    r   test_name_pathzTestExternal.test_name_path  s2     	eX'.||DKKM'B 	 	Dr   c                     | j                         d}t        fdt        |      D              }| j                  j	                  dd|      }t        |j                        |k(  sJ y)z9 External argument may be an iterable of multiple tuples r   c              3   .   K   | ]  }|d z  d f  yw)  Nr#   ).0r  r  s     r   	<genexpr>z/TestExternal.test_iter_multi.<locals>.<genexpr>  s     Eq1t8T2Es   poor  r)  N)r   iterr  r   r.   r=  r  )r   Nr  r?   r  s       @r   test_iter_multizTestExternal.test_iter_multi  s[     ;;=EE!HEEvv$$UHx$H4==!Q&&&r   c           
         d}| j                         }t        |gft        |dgft        |dt        j                  gft        |fgft        |dfgft        |dt        j                  dfgft        |ddfgffD ]=  \  }}| j                  |      5  | j                  j                  d||       ddd       ? y# 1 sw Y   JxY w)z" Test with invalid external lists r  r   zh5f.UNLIMITEDr'   r)  N)r   r\   r   r  r   r[   r   r.   )r   r=   r  exc_typer  s        r   test_invalidzTestExternal.test_invalid  s     ;;= 
#1&1cmm458+'8Q-)8Qq9:;(A789#
 
	GHh ""8, G%%eUX%FG G
	GG Gs   B77C 	c                     | j                         }d}d}| j                  j                  d|||      }|j                  J |j                  |k(  sJ |j
                  |k(  sJ y)z$ Create expandable external dataset )   @   )Nr;  r'   )r=   r5  r  N)r   r   r.   r+  r=   r5  )r   r  r=   r5  exp_dsets        r   test_create_expandablez#TestExternal.test_create_expandable  sq     ;;=66((eh2: ) <&&&~~&&&  H,,,r   N)r    r!   r"   r7   r!  r'  r*  r,  r5  r8  r=  r#   r   r   r  r  s  s-    &0:G
D'G$
-r   r  c                   *    e Zd ZdZddZd Zd Zd Zy)TestAutoCreatezP
        Feature: Datasets auto-created from data produce the correct types
    c                    |j                   j                         }| j                  t        |      t        j
                  j                         | j                  |j                         |       |r|j                         sJ y y r   )	r   r   r<   r  r}   r   r   r   r   )r   r1   r   variabler   s        r   assert_string_typez!TestAutoCreate.assert_string_type  s`    eenncDHH$9$9:.&&((( r   c                    d| j                   d<   | j                  | j                   d   t        j                  j                         ddg| j                   d<   | j                  | j                   d   t        j                  j                         t        j                  ddgt
        j                        | j                   d<   | j                  | j                   d   t        j                  j                         y)	z<Assigning byte strings produces a vlen string ASCII dataset s   Hello therer     as   bcyr+   zN)r   rB  r}   r   r   rW   r   object_r   s    r   test_vlen_byteszTestAutoCreate.test_vlen_bytes  s    $ssTXX-@-@AUmssTXX-@-@Ahhe}BJJ?ssTXX-@-@Ar   c                    dt        d      z   | j                  d<   | j                  | j                  d   t        j                  j
                         ddg| j                  d<   | j                  | j                  d   t        j                  j
                         t        j                  ddggt        j                        | j                  d<   | j                  | j                  d   t        j                  j
                         y	)
z?Assigning unicode strings produces a vlen string UTF-8 dataset Hello there4   r  r   bcrE  r+   rF  N)	chrr   rB  r}   r   r   rW   r   rG  r   s    r   test_vlen_unicodez TestAutoCreate.test_vlen_unicode  s    #c&k1ssTXX-?-?@DkssTXX-?-?@ hhd}BJJ?ssTXX-?-?@r   c                 .   t        j                  d      | j                  d<   | j                  d   }| j                  |t        j
                  j                  d       | j                  |j                  j                         j                         d       y)zV Assignment of fixed-length byte string produces a fixed-length
        ascii dataset rJ  r  F)rA  rF  N)rW   bytes_r   rB  r}   r   r   r<   r   r   r   r0   s     r   test_string_fixedz TestAutoCreate.test_string_fixed  sj     ii.sVVC[DHH$7$7%H)224b9r   N)T)r    r!   r"   r7   rB  rH  rN  rQ  r#   r   r   r?  r?    s    )	B
A:r   r?  c                       e Zd Zd Zd Zd Zy)TestCreateLikec                 H   t        j                  d      j                  dd      | j                  d<   | j                  j	                  d| j                  d          | j                  d   }| j                  |j                  d       | j                  |j                  d        y )Nr   r   lollike_lolr   r   )	rW   r   r   r   create_dataset_liker<   r=   assertIsr+  )r   dslikes     r   test_no_chunkszTestCreateLike.test_no_chunks  st    		"--a3u"":tvve}=
#v.fmmT*r   c                 P   | j                   j                  dt        j                  d      d      }| j	                  dt
        j                  j                  |j                        j                         | j                   j                  d|      }| j	                  dt
        j                  j                  |j                        j                         | j                   j                  dt        j                  d      d      }| j                  dt
        j                  j                  |j                        j                         | j                   j                  d	|      }| j                  dt
        j                  j                  |j                        j                         y )
NhondarG  T)ru   track_timesr   hyundaiibmFlenovo)r   r.   rW   r   r~  r}   h5gget_objinfo_idmtimerX  r<   )r   origsimilars      r   test_track_timeszTestCreateLike.test_track_times  s"   vv$$W299R=15 % 7Atxx33DHH=CCD&&,,Y=Atxx33GKK@FFGvv$$U216 % 8DHH00:@@A&&,,Xt<DHH00=CCDr   c                     | j                   j                  ddd      }| j                   j                  d|      }| j                  |j                  d       | j                  |j
                  d       y)z) Test when other.maxshape != other.shape otherr   r   r5  simr   N)r   r.   rX  r<   r=   r5  )r   rj  rg  s      r   test_maxshapezTestCreateLike.test_maxshape   s_     %%gur%B&&,,UE:.))51r   N)r    r!   r"   r[  rh  rn  r#   r   r   rS  rS    s    +E2r   rS  c                   $    e Zd Zd Zd Zd Zd Zy)TestChunkIteratorc                     | j                   j                  dd      }| j                  t              5  |j	                          d d d        y # 1 sw Y   y xY w)Nr'   r#   )r   r.   r[   r\   iter_chunksr>   s     r   r[  z TestChunkIterator.test_no_chunks)  sG    vv$$UB/y) 		 	 	s   AAc           	         | j                   j                  ddd      }t        ddd      ft        ddd      ft        dd	d      ft        d	d
d      ff}| j                  t	        |j                               t	        |             t        ddd      ft        dd	d      ft        d	dd      ff}| j                  t	        |j                  t        j                  dd             t	        |             y )Nr'   r   )    r+  r   rt  r   r;  `   r   r   a   r   r.   slicer<   listrr  rW   r   r   r?   r   s      r   test_1dzTestChunkIterator.test_1d.  s    vv$$UF5$A1R]$uR1~&7%2a.9J2c!_ d..014>B2b^%bA'85Bq>:KLd..ruuR|<=tH~Nr   c                    | j                   j                  ddd      }t        ddd      t        ddd      ft        ddd      t        dd	d      ft        ddd      t        ddd      ft        ddd      t        dd	d      ft        dd
d      t        ddd      ft        dd
d      t        dd	d      ft        d
d	d      t        ddd      ft        d
d	d      t        dd	d      ff}| j                  t	        |j                               t	        |             t        ddd      t        ddd      ff}| j                  t	        |j                  t        j                  ddddf               t	        |             y )Nr'   r   r   )rt  r;  ru  r   rt  r   r;  r   rv  0   4   rE  r   rx  r{  s      r   test_2dzTestChunkIterator.test_2d6  sp   vv$$UIg$F1b!_eAr1o6q"ab#q9"2r1-uQA?	r2q	5S!,-b"a0@aQ0 R+U2sA->?	r3	E!RO,uRa/@b#q/	 	d..014>B2r1%uRQ'78:d..ruuRU2b5[/ABCT(^Tr   c           	         | j                   j                  ddd      }t        ddd      t        ddd      ft        ddd      t        ddd      ft        ddd      t        ddd      ft        ddd      t        ddd      ff}t        dd      }| j                  t	        |j                  ||f            t	        |             y )	Nr'   rW  rk   rk   ru  r   r)   r   r   )r   r.   ry  r<   rz  rr  )r   r?   r   sels       r   test_2d_partial_slicez'TestChunkIterator.test_2d_partial_sliceC  s    vv$$UE%$@1a^U1a^4!QNE!QN3!QNE!QN3!QNE!QN35 Aajd..Sz:;T(^Lr   N)r    r!   r"   r[  r|  r  r  r#   r   r   rp  rp  (  s    
OUMr   rp  c                   F    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)
TestResizezF
        Feature: Datasets created with "maxshape" may be resized
    c                     | j                   j                  ddd      }| j                  |j                  d       | j	                  |j
                  d       y)z  Create dataset with "maxshape" r'   r  r   rN   rk  Nr   r.   assertIsNotr+  r<   r5  r>   s     r   r  zTestResize.test_createT  sE    vv$$UHx$Hd+1r   c                 $   | j                   j                  ddd      }| j                  |j                  d       | j	                  |j
                  d       | j                   j                  ddd      }| j	                  |j
                  d       y)z6 Create dataset with "maxshape" using integer maxshaper'   rm  r   rk  NrJ   r  r>   s     r   r  zTestResize.test_create_1DZ  st    vv$$UEB$?d+.vv$$UB$<.r   c                 ,   | j                   j                  ddd      }| j                  |j                  d       |j	                  d       | j                  |j                  d       |j	                  d       | j                  |j                  d       y)z( Datasets may be resized up to maxshape r'   r  r  rk  r   r   Nr   r.   r<   r=   r  r>   s     r   test_resizezTestResize.test_resizec  sq    vv$$UHx$HX.HX.HX.r   c                     | j                   j                  ddd      }| j                  |j                  d       |j	                  d       | j                  |j                  d       y)z> Datasets may be resized up to maxshape using integer maxshaper'   r   rE  rk  rm  )r   Nr  r>   s     r   test_resize_1DzTestResize.test_resize_1Dl  sQ    vv$$UB$<U+EU+r   c                     | j                   j                  ddd      }| j                  t              5  |j	                  d       ddd       y# 1 sw Y   yxY w)z. Resizing past maxshape triggers an exception r'   r  r  rk  )r   r   N)r   r.   r[   	Exceptionr  r>   s     r   test_resize_overzTestResize.test_resize_overs  sL    vv$$UHx$Hy) 	"KK!	" 	" 	"s   AAc                     | j                   j                  dd      }| j                  t              5  |j	                  d       ddd       y# 1 sw Y   yxY w)z/ Resizing non-chunked dataset raises TypeError r'   r  r  N)r   r.   r[   r\   r  r>   s     r   test_resize_nonchunkedz!TestResize.test_resize_nonchunkedy  sG    vv$$UH5y) 	"KK!	" 	" 	"s   AAc                     | j                   j                  ddd      }|j                  dd       | j                  |j                  d       y	)
z Resize specified axis r'   r  r  rk  r   r   axisr  N)r   r.   r  r<   r=   r>   s     r   test_resize_axiszTestResize.test_resize_axis  sA    vv$$UHx$HBQX.r   c                     | j                   j                  ddd      }| j                  t              5  |j	                  dd       ddd       y# 1 sw Y   yxY w)	z  Illegal axis raises ValueError r'   r  r  rk  r   rk   r  N)r   r.   r[   r   r  r>   s     r   test_axis_exczTestResize.test_axis_exc  sP    vv$$UHx$Hz* 	$KKK#	$ 	$ 	$s   AAc                     | j                   j                  ddd      }| j                  |j                  d       | j                  |j                  d       y)z? Allow zero-length initial dims for unlimited axes (issue 111) r'   )   r   )r  Nrk  N)r   r.   r<   r=   r5  r>   s     r   test_zero_dimzTestResize.test_zero_dim  sE    vv$$UGj$IW-
3r   N)r    r!   r"   r7   r  r  r  r  r  r  r  r  r  r#   r   r   r  r  N  s4    2//,""/$4r   r  c                       e Zd ZdZd Zd Zy)	TestDtypezD
        Feature: Dataset dtype is available as .dtype property
    c                     | j                   j                  ddd      }| j                  |j                  t	        j                  d             y)z Retrieve dtype from dataset r'   r  |S10NrV   r>   s     r   
test_dtypezTestDtype.test_dtype  s7    vv$$UD&9RXXf%56r   c                     t        j                  dt         j                  fdt         j                  fg      }| j                  j	                  dd|      }| j                  |j                  |       y)z7 Retrieve dtype from complex float16 dataset (gh-2156) r  rf  r'   r  N)rW   r,   float16r   r.   r<   )r   	complex32r?   s      r   test_dtype_complex32zTestDtype.test_dtype_complex32  sU     HHsBJJ/#rzz1BCD	vv$$UD)<Y/r   N)r    r!   r"   r7   r  r  r#   r   r   r  r    s    7
0r   r  c                       e Zd ZdZd Zd Zy)TestLenzG
        Feature: Size of first axis is available via Python's len
    c                 r    | j                   j                  dd      }| j                  t        |      d       y)z Python len() (under 32 bits) r'   )8  r  r  N)r   r.   r<   r=  r>   s     r   test_lenzTestLen.test_len  s,    vv$$UI6TC(r   c                 |   | j                   j                  dd      }| j                  |j                  d       t        j
                  dk(  r*| j                  t              5  t        |       ddd       n| j                  t        |      d       | j                  |j                         d       y# 1 sw Y   *xY w)z Python len() vs Dataset.len() r'   )        r  iNr  )	r   r.   r<   r=   sysmaxsizer[   OverflowErrorr=  r>   s     r   test_len_bigzTestLen.test_len_big  s    vv$$UM:]3;;+%""=1 D	  SY0W-	 s   !B22B;N)r    r!   r"   r7   r  r  r#   r   r   r  r    s    )
	.r   r  c                       e Zd ZdZd Zd Zy)TestIterz;
        Feature: Iterating over a dataset yields rows
    c                    t        j                  dd      j                  d      }| j                  j	                  d|      }t        ||      D ]2  \  }}| j                  t        |      d       | j                  ||       4 y)	z& Iterating over a dataset yields rows r   r   r+   r   r'   rt   r   N)	rW   r   r   r   r.   zipr<   r=  r   )r   ru   r?   r  rE  s        r   	test_iterzTestIter.test_iter  ss    yy3'//8vv$$U$6dO 	(DAqSVQ'!!!Q'	(r   c                     | j                   j                  dd      }| j                  t              5  |D cg c]  }| c} ddd       yc c}w # 1 sw Y   yxY w)z0 Iterating over scalar dataset raises TypeError r'   r#   r=   N)r   r.   r[   r\   )r   r?   r  s      r   test_iter_scalarzTestIter.test_iter_scalar  sT    vv$$U"$5y) 	1Q	 		 	s   A	AAAAN)r    r!   r"   r7   r  r  r#   r   r   r  r    s    (r   r  c                   v    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestStringszr
        Feature: Datasets created with vlen and fixed datatypes correctly
        translate to and from HDF5
    c                    t        j                  d      }| j                  j                  dd|      }|j                  j                         }| j                  t        |      t         j                  j                         | j                  |j                         t         j                  j                         t        j                  |j                        }| j                  |j                  d       y)z3 Vlen bytes dataset maps to vlen ascii in the file r  r  r  r   r+   N)r}   string_dtyper   r.   r   r   r<   r  r   r   r   r   check_string_dtyper,   r  r   ra  r1   r   string_infos        r   rH  zTestStrings.test_vlen_bytes  s    0VV""3b"9eenncDHH$9$9:)<)<=--bhh7--w7r   c                    t        j                  d      }d}| j                  j                  dd||      }| j	                  | j                  d   d   |       | j	                  | j                  d   j                         d   |j                                | j	                  | j                  d   j                  |       y)	& Vlen bytes dataset handles fillvalue r  r     barr  r   r  r   Nr}   r  r   r.   r<   asstrr  r  r   ra  
fill_valuer1   s       r   test_vlen_bytes_fillvaluez%TestStrings.test_vlen_bytes_fillvalue  s    0
VV""3bJ"OQ4**,Q/1B1B1DE..
;r   c                    t        j                         }| j                  j                  dd|      }|j                  j                         }| j                  t        |      t         j                  j                         | j                  |j                         t         j                  j                         t        j                  |j                        }| j                  |j                  d       y)z5 Vlen unicode dataset maps to vlen utf-8 in the file r  r   r+   r  N)r}   r  r   r.   r   r   r<   r  r   r   r   r   r  r,   r  r  s        r   rN  zTestStrings.test_vlen_unicode  s     VV""3b"9eenncDHH$9$9:););<--bhh7--w7r   c                    t        j                         }d}| j                  j                  dd||      }| j	                  | j                  d   d   |j                  d             | j	                  | j                  d   j                         d   |       | j	                  | j                  d   j                  |j                  d             y)( Vlen unicode dataset handles fillvalue    bárr  r   r  r   r  N)r}   r  r   r.   r<   r  r  r  r  s       r   test_vlen_unicode_fillvaluez'TestStrings.test_vlen_unicode_fillvalue  s     
VV""3bJ"OQ):):7)CD**,Q/<..
0A0A'0JKr   c                    t        j                  d      }| j                  j                  dd|      }|j                  j                         }| j                  t        |      t        j                  j                         | j                  |j                                | j                  |j                         d       | j                  |j                         t        j                  j                         t        j                   |j                        }| j                  |j"                  d       | j                  |j$                  d       y)zK Fixed-length bytes dataset maps to fixed-length ascii in the file
        r  r  r   r+   rM   r  N)rW   r,   r   r.   r   r   r<   r  r}   r   r   assertFalser   r   r   r   r  r  r   r  s        r   test_fixed_asciizTestStrings.test_fixed_ascii  s     XXfVV""3b"9eenncDHH$9$9:,,./,)<)<=--bhh7--w7++R0r   c                    t        j                  dd      }d}| j                  j                  dd||      }| j	                  | j                  d   d   |       | j	                  | j                  d   j                         d   |j                                | j	                  | j                  d   j                  |       y	)
r  r  rM   r  r  r  r   r  r   Nr  r  s       r   test_fixed_bytes_fillvaluez&TestStrings.test_fixed_bytes_fillvalue  s    ;
VV""3bJ"OQ4**,Q/1B1B1DE..
;r   c                    t        j                  dd      }| j                  j                  dd|      }|j                  j                         }| j                  |j                         t         j                  j                         d}|j                  d      |d<   ||d	<   ||g|d
d t        j                  ||gt              |dd t        j                  |j                  d      gd
z  |      |dd | j                  t              5  t        j                  ||gd      |dd d d d        t        j                   j#                  |d d t        j                  |j                  d      gdz  d             y # 1 sw Y   UxY w)Nr  r   r  r  r   r+      cùr   r   rk   r)   rL      UrM   S)r}   r  r   r.   r   r   r<   r   r   r   r  rW   r   r   r[   r\   r   r   )r   ra  r1   r   ss        r   test_fixed_utf8zTestStrings.test_fixed_utf8  sE   :VV""3b"9eenn););<!11a&1Q((Aq601Q((AHHW-.2"=1Qy) 	3xxAc2BqH	3 	

%%b!fbhh8I7JQ7NVY.Z[	3 	3s   E==Fc                    t        j                  dd      }dj                  d      }| j                  j	                  dd||      }| j                  | j                  d   d   |       | j                  | j                  d   j                         d   |j                  d             | j                  | j                  d   j                  |       y	)
r  r  rM   r  r  r  r   r  r   N)	r}   r  r  r   r.   r<   r  r  r  r  s       r   test_fixed_utf_8_fillvaluez&TestStrings.test_fixed_utf_8_fillvalue%  s    ;]]7+
VV""3bJ"OQ4**,Q/1B1B71KL..
;r   c                     t        j                  d      }| j                  t              5  | j                  j                  dd|      }ddd       y# 1 sw Y   yxY w)zA Fixed-length unicode datasets are unsupported (raise TypeError) z|U10r  r   r+   N)rW   r,   r[   r\   r   r.   r   ra  r1   s      r   test_fixed_unicodezTestStrings.test_fixed_unicode.  sN    XXfy) 	>&&sF"&=B	> 	> 	>s   AAc                     t        j                  d      }| j                  j                  dd|      }d}||d<   |d   }| j	                  t        |      t               | j	                  ||       y)	zN writing and reading to vlen bytes dataset preserves type and content
        r  r  r  r   r+      Hellor   N)r}   r  r   r.   r<   r  bytesr   ra  r1   ru   outs        r   test_roundtrip_vlen_bytesz%TestStrings.test_roundtrip_vlen_bytes4  sj     0VV""3b"91ecE*d#r   c                     t        j                  d      }| j                  j                  dd|      }d}||d<   |d   }| j	                  t        |      t         j                         | j	                  ||       y)z[ Writing to and reading from fixed-length bytes dataset preserves
        type and content r  r  r   r+   r  r   N)rW   r,   r   r.   r<   r  rP  r  s        r   test_roundtrip_fixed_bytesz&TestStrings.test_roundtrip_fixed_bytes?  sl     XXfVV""3b"91ecBII.d#r   c                    t        j                         }| j                  j                  dd|      }d}||d<   | j	                  |d   t
               |j                         d   }| j	                  |t               | j                  ||       y )Nr  r   r+      fàilter   )	r}   r  r   r.   r|   r  r  r  r<   r  s        r   test_retrieve_vlen_unicodez&TestStrings.test_retrieve_vlen_unicodeJ  s|     VV""3R"81beU+hhjmc3'd#r   c                 *   | j                   j                  ddt        j                               }d}||d<   |j	                  d      }| j                  t              5  |d    d d d        | j                  |j	                  dd      d   d       | j                  |j	                  d	      d   |       | j                  d
t        |j	                                      t        j                  j                  |j	                         d d t        j                  |gt                     t        j                  j                  t        j                  |j	                               d d t        j                  |gt                     y # 1 sw Y   &xY w)Nr  r   r+   r  r   r  ignorefiltelatin-1rM   r   )r   r.   r}   r  r  r[   UnicodeDecodeErrorr<   r~  r=  rW   r   r   r   r   asarray)r   r1   ru   strwrap1s       r   
test_asstrzTestStrings.test_asstrT  s9   VV""3T5F5F5H"I188G$12 	QK	 	'84Q7A 	BHHY/2D9 	S_- 	

%%HHJrNBHHdV6:	
 	

%%JJrxxz"2A&$v(F	
#	 	s   FFc                    t        j                  d      }| j                  j                  dd|      }d}t	        j
                  |j                  d      |      |d<   | j                  |d   t        j                         |j                         d   }| j                  |t               | j                  ||       | j                  |j                  d	d
      d   d       | j                  |j                  d      d   |       t        j                  j                  |j                         d d t	        j
                  |gt                     y )Nr   r   r  r   r+   r  r  r   r  r  r   r  r   )r}   r  r   r.   rW   r   r  r|   rP  r  r  r<   r~  r   r   r   r  s        r   test_asstr_fixedzTestStrings.test_asstr_fixedo  s
   a(VV""3R"8W-R81beRYY/hhjmc3'd# 	'84Q7= 	BHHY/2D9 	

%%HHJrNBHHdV6:	
r   c                     t        j                  d      }| j                  j                  dd|      }d}| j	                  t
              5  ||d<   ddd       y# 1 sw Y   yxY w)zGEncoding error when writing a non-ASCII string to an ASCII vlen datasetr  r  r   r+   r  r   N)r}   r  r   r.   r[   UnicodeEncodeError)r   ra  r1   ru   s       r   test_unicode_write_errorz$TestStrings.test_unicode_write_error  s_    w'VV""3b"912 	BqE	 	 	s   AA#c                    t        j                         }| j                  j                  dd|      }dt	        d      z   j                  d      }||d<   |d   }| j                  t        |      t               | j                  ||       y)	zJ Writing valid utf-8 byte strings to a unicode vlen dataset is OK
        r  r   r+   rJ  rK  utf8r   N)	r}   r  r   r.   rM  r  r<   r  r  r  s        r   test_unicode_write_bytesz$TestStrings.test_unicode_write_bytes  s|      VV""3b"9V,44V<1ecE*d#r   c                    t        j                  d      }| j                  j                  dd|      }d}||d<   |d   }| j	                  t        |      t               | j	                  ||j                  d             y)z: Writing an ascii str to ascii vlen dataset is OK
        r  r  r   r+   zASCII stringr   N)r}   r  r   r.   r<   r  r  r  r  s        r   test_vlen_bytes_write_ascii_strz+TestStrings.test_vlen_bytes_write_ascii_str  ss     w'VV""3b"91ecE*dkk'23r   N)r    r!   r"   r7   rH  r  rN  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#   r   r   r  r    s^    
8<8L1<\ <>	$	$$
6
,	$	4r   r  c                   (    e Zd ZdZd Zd Zd Zd Zy)TestCompoundz:
        Feature: Compound types correctly round-trip
    c           
         t        j                  dt         j                  fdt         j                  fdt         j                  fdt         j                  fdt         j                  fdt         j                  fdt         j                  fg      }t        j
                  d|	      }|j                  D ]'  }t         j                  j                  d      d
z  ||<   ) || j                  d<   | j                  d   d   }| j                  t        j                  ||k(               | j                  |j                  |j                         y)z: Compound types are read back in correct order (issue 236)weightcputimewalltimeparents_offset	n_parentsstatusendpoint_typer  r+   r   test.N)rW   r,   r  uint32uint8rY  fieldsr  r   r~   rH  r<   )r   ra  r  keyoutdatas        r   test_rtzTestCompound.test_rt  s     XX2::.'4("**5.		:)2995&1-rxx8< = ::e2.99 	:CII,,U3c9HSM	: "v&&.%w(2347r   c                 X   t        j                  dt         j                  dffdt         j                  fg      }t        j                  d|      }|j
                  D ]5  }t         j                  j                  ||   j                        dz  ||<   7 | j                  j                  dd|      }|j
                  D ]
  }||   ||<    | j                  d   d	   }| j                  t        j                  ||k(               | j                  |j                  |j                         y )
Nr  r   r  r	  r+   rP   r   r
  .)rW   r,   r  r  rY  r  r  r=   r   r.   r~   rH  r<   )r   ra  r  r  r1   r  s         r   test_assignzTestCompound.test_assign  s   XXBJJ?3)28848 9 ::e2.99 	MCII,,(3-2E2E,FLHSM	M VV""65";99 	$CsmBsG	$ &&.%w(2347r   c                 v   t        j                  dt         j                  fdt         j                  fdt         j                  fg      }t        j                  d|      }|j                  D ]'  }t         j
                  j                  d      dz  ||<   ) || j                  d<   t         j                  j                  | j                  d   j	                  ddg      d d  |ddg          t         j                  j                  | j                  d   j	                  d      d d  |d          t         j                  j                  t        j                  | j                  d   j	                  ddg            |ddg          t        j                  dt         j                  fg      }t         j                  j                  t        j                  | j                  d   j	                  dg      |      |dg   j                  |             t        | j                  d   j	                  d            dk(  sJ y )	Nr  rE  rF  r	  r+   r   r
  r  )rW   r,   r  rY  r  r  r   r   r   r  r*   astyper=  )r   ra  r  r  dt_ints        r   test_fieldszTestCompound.test_fields  s   XX"**"**"**
  ::e2.99 	:CII,,U3c9HSM	: "v 	

%%FF6N!!3*-a0(C:2F	
 	

%%FF6N!!#&q)8C=	
 	

%%JJtvvf~,,c3Z898S#J;O	
 C?+,


%%JJtvvf~,,cU36BcUO""6*	
 466&>((-."444r   c                    t        j                  dt        j                  t         j                        fdt        j                  t         j                        fg      }t        j                  dt        j                  |      fdt         j
                  fg      }t        j                  t        dd      t         j                        t        j                  t        dd	      t         j                        f}t        j                  t        d
d      t         j                        t        j                  t        dd      t         j                        f}t        j                  t        j                  ||g|      dft        j                  |g|      dfg|      }|| j                  d<   | j                  d   }| j                  ||d       y )Nr   r   f1f2r   r   r+   rL   r   rM   r  r     rk   r1   F)check_alignment)
rW   r,   r}   
vlen_dtyper*   r   r   r  r   r   )r   dt_innerra  inner1inner2ru   r  s          r   test_nested_compound_vlenz&TestCompound.test_nested_compound_vlen  sY   88c4??288#<= $//"((";<> ? XXdooh78bhh') * ((5A;bhh7((5A;bhh79 ((5R=9((5R=9; xx"((FF#38DaH6((;Q?A " tffTl 	c4?r   N)r    r!   r"   r7   r  r  r  r!  r#   r   r   r   r     s    8(8"!5F@r   r   c                       e Zd Zd Zd Zy)TestSubarrayc                     | j                   j                  ddd      }g d|d<   t        j                  j	                  |d d  g dg       g dg|d d  t        j                  j	                  |d d  g dg       y Nr   rB   3int8r+   r   rk   r   r   )r)   r   rL   )r   r.   rW   r   r   r0   s     r   test_write_listzTestSubarray.test_write_list  se    VV""3G"<1


%%bei[91


%%bei[9r   c                 B   | j                   j                  ddd      }t        j                  g d      |d<   t        j                  j                  |d d  g dg       t        j                  g dg      |d d  t        j                  j                  |d d  g dg       y r%  )r   r.   rW   r   r   r   r0   s     r   test_write_arrayzTestSubarray.test_write_array  sw    VV""3G"<#1


%%bei[9)%1


%%bei[9r   N)r    r!   r"   r(  r*  r#   r   r   r#  r#    s    ::r   r#  c                   (    e Zd ZdZddddZd Zd Zy)	TestEnumzM
        Feature: Enum datatype info is preserved, read/write as integer
    r   r   rg  )REDGREENBLUEc                     t        j                  | j                  d      }| j                  j	                  dd|      }|j
                  }t        j                  |      }| j                  || j                         y)z= Enum datasets can be created and type correctly round-trips rf  basetyper  r~  r+   N)r}   
enum_dtypeEDICTr   r.   r,   check_enum_dtyper<   )r   ra  r1   dt2dict2s        r   r  zTestEnum.test_create%  s^    __TZZ#6VV""3
""=hh%%c*

+r   c                 $   t        j                  | j                  d      }| j                  j	                  dd|      }d|d<   d|dd	d	f<   | j                  |d   d       | j                  |dd	d	f   t        j                  d
d             y	)z/ Enum datasets can be read/written as integers r$  r1  r  r~  r+   rg  )#   %   r   N)dr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )	r}   r3  r4  r   r.   r<   r   rW   r   r  s      r   test_readwritezTestEnum.test_readwrite-  s~    __TZZ$7VV""3
""=6
1a4FR(bAh4(HIr   N)r    r!   r"   r7   r4  r  r;  r#   r   r   r,  r,    s      2.E,Jr   r,  c                   \    e Zd ZdZd Z ej                   eed      d      d        Z	d Z
y)
TestFloatszA
        Test support for mini and extended-precision floats
    c                     | j                   j                  dd|      }| j                  |j                  |       t	        j
                  d|      }||d<   | j                  |d   |       y )Nr  r   r+   .)r   r.   r<   r,   rW   rw   r   )r   ra  r?   ru   s       r   	_exectestzTestFloats._exectest=  s^    vv$$S&$;R(wwvR(S	d3i.r   r  zNumPy float16 support requiredc                 L    | j                  t        j                  d             y)z Mini-floats round trip r  N)r?  rW   r,   r   s    r   	test_minizTestFloats.test_miniD  s     	rxx	*+r   c                    t        t        d      r>| j                  t        j                  j
                  t        j
                  d             y| j                  t        j                  j
                  t        j
                  d             y)z Test mapping for float16 r  z<f2z<f4N)rp   rW   r<   r   
IEEE_F16LEr,   r   s    r   test_mini_mappingzTestFloats.test_mini_mappingJ  sP    2y!S^^11288E?CS^^11288E?Cr   N)r    r!   r"   r7   r?  r   
skipUnlessrp   rW   rA  rD  r#   r   r   r=  r=  7  s<    / R]]72y)+KL, M,
Dr   r=  c                       e Zd ZdZd Zd Zy)TestTrackTimesz"
        Feature: track_times
    c                     | j                   j                  ddd      }t        j                  j	                  |j
                        j                  }| j                  d|       y)zC check that when track_times=False, the time stamp=0 (Jan 1, 1970) r'   r(   Fr^  r   N)r   r.   r}   rb  rc  rd  re  r<   )r   r1   ds_mtimes      r   test_disable_track_timesz'TestTrackTimes.test_disable_track_timesX  sK    VV""5$E"B88''/55H%r   c                     | j                  t              5  | j                  j                  ddd       ddd       y# 1 sw Y   yxY w)z3 check that when give track_times an invalid value r'   r(   nullrI  NrZ   r   s    r   test_invalid_track_timesz'TestTrackTimes.test_invalid_track_times^  sB    y) 	CFF!!%6!B	C 	C 	Cr3  N)r    r!   r"   r7   rK  rN  r#   r   r   rG  rG  R  s    &Cr   rG  c                       e Zd ZdZd Zd Zy)TestZeroShapez7
        Features of datasets with (0,)-shape axes
    c                    | j                   j                  ddd      }| j                  |j                  t	        j
                  |      j                         | j                   j                  ddd      }| j                  |j                  t	        j
                  |      j                         | j                   j                  dd	d
      }| j                  |j                  t	        j
                  |      j                         y)z1 Empty datasets can be converted to NumPy arrays r  r   Nrk  rE  r   r   rF  r   r   )NN)r   r.   r<   r=   rW   r   r0   s     r   test_array_conversionz#TestZeroShape.test_array_conversionj  s    VV""3D"9288B<#5#56VV""3w"?288B<#5#56VV""3"F288B<#5#56r   c                    ddg}| j                   j                  dd|d      }t        j                  d|      }| j	                  |d   j
                  |j
                         | j	                  |d   j                  |j                         | j	                  |d	   j
                  |j
                         | j	                  |d	   j                  |j                         y
)z- Slicing into empty datasets works correctly )r   r   )r   rf  r  rR  r   rN  r+   .r#   N)r   r.   rW   emptyr<   r=   r,   )r   ra  r1   r   s       r   test_readingzTestZeroShape.test_readingu  s    *%VV""3B"Ihht2&C		2C		2Bsyy1Bsyy1r   N)r    r!   r"   r7   rT  rW  r#   r   r   rP  rP  d  s    	7	2r   rP  )r   rM   rL   z+Issue with empty region refs in HDF5 1.10.6)reasonc                   B    e Zd ZdZd Zd Zed        Zed        Zd Z	y)TestRegionRefsz3
        Various features of region references
    c                 
   t         j                  |        t        j                  d      j	                  d      | _        | j                  j                  d| j
                        | _        | j
                  | j                  d<   y )Ni'  r~  r  rt   .)	r   r   rW   r   r   ru   r   r.   r?   r   s    r   r   zTestRegionRefs.setUp  s[    $IIi(00<	FF))#DII)>			#r   c                     t         j                  dddddf   }| j                  j                  |   }| j	                  | j                  |   | j
                  |          y)z4 Region references can be used as slicing arguments r   r9  rM   r   r   N)rW   r   r?   	regionrefr   ru   r   slicrefs      r   test_create_refzTestRegionRefs.test_create_ref  sR    uuRUBs1H_%ii!!$'diindiio>r   c                 v    | j                   j                  d d }| j                   |   }|j                  dk(  sJ y )Nr   )r?   r]  rP   )r   r`  r  s      r   test_empty_regionz TestRegionRefs.test_empty_region  s5    ii!!"1%iinxx1}}r   c                 x   | j                   j                  ddd      }t        j                  j	                  t        j                  j
                        }|j                          t        j                  j	                  |j                  dt        j                  j                  |      }||   t        j                  t        j                  d            k(  sJ |j                          t        j                  j	                  |j                  dt        j                  j                  |      }||   |d   k(  sJ y )Nscalar      ?r^  ru   r,      .r#   )r   r.   r}   h5screateSCALARselect_noneh5rr   DATASET_REGIONr   rW   r,   
select_all)r   r1   sidr`  s       r   test_scalar_datasetz"TestRegionRefs.test_scalar_dataset  s    VV""8#T"Bhhoodhhoo. 	hhoobeeT488+B+BCH#w$**RXXd^4444 	hhoobeeT488+B+BCH#w"R&   r   c                 f   t         j                  dddddf   }| j                  j                  |   }| j	                  | j                  j                  j                  |      | j                  j
                         | j	                  | j                  j                  j                  |      d       y)z, Region reference shape and selection shape r   r9  rM   r   r   )rM      N)rW   r   r?   r]  r<   r=   	selectionr^  s      r   test_ref_shapezTestRegionRefs.test_ref_shape  s    uuRUBs1H_%ii!!$',,2237I,,66s;XFr   N)
r    r!   r"   r7   r   ra  empty_regionref_xfailrc  rq  ru  r#   r   r   rZ  rZ    s?    #?   ! !Gr   rZ  c                   "    e Zd ZdZd Zd Zd Zy)
TestAstypez(.astype() wrapper & context manager
    c                     | j                   j                  ddd      }t        j                  d      |d<   |j	                  d      d d  }| j                  |t        j                  dd             y Nr  r   r%  r+   r   .r^  )r   r.   rW   r   r  r   r   r?   r   s      r   test_astype_wrapperzTestAstype.test_astype_wrapper  s\    vv$$S&$=IIcNS	kk$"c299S#=>r   c                     | j                   j                  ddd      }t        j                  d      |d<   | j	                  dt        |j                  d                   y rz  )r   r.   rW   r   r<   r=  r  r>   s     r   test_astype_wrapper_lenz"TestAstype.test_astype_wrapper_len  sL    vv$$S&$=IIcNS	c$++d"345r   c                 
   | j                   j                  ddd      }t        j                  d      |d<   t        j                  |j                  d      d      }| j                  |t        j                  dd             y rz  )r   r.   rW   r   r  r  r   r{  s      r   test_astype_wrapper_asarrayz&TestAstype.test_astype_wrapper_asarray  sb    vv$$S&$=IIcNS	jjT*$7c299S#=>r   N)r    r!   r"   r7   r|  r~  r  r#   r   r   rx  rx    s    ?6
?r   rx  c                       e Zd ZdZd Zy)TestScalarCompoundzl
        Retrieval of a single field from a scalar compound dataset should
        strip the field info
    c                     t        j                  dg      }| j                  j                  dd|      }| j	                  |d   j                  t        j                  d             y )Nre  r  r#   r+   r   rf  )rW   r,   r   r.   r<   )r   ra  r?   s      r   test_scalar_compoundz'TestScalarCompound.test_scalar_compound  sM    XXzl#vv$$S"B$7c"((3-8r   N)r    r!   r"   r7   r  r#   r   r   r  r    s    
9r   r  c                   V    e Zd Zd Zd Zd Zd Zd ZddZd Z	d Z
d	 Zd
 Zd Zd Zy)TestVlenc                    t        j                  t              }| j                  j	                  dd|      }t        j                  d      |d<   t        j                  d      |d<   g d|d<   t        j                  d      |d<   | j                  |d   t        j                  d             | j                  |d   t        j                  d             | j                  |d   t        j                  g d             | j                  |d   t        j                  d             t        j                  t        j                  d	      t        j                  d
      gt              |dd | j                  |d   t        j                  d	             | j                  |d   t        j                  d
             t        j                  t        j                  d      t        j                  d      g      |dd | j                  |d   t        j                  d             | j                  |d   t        j                  d             y )Nvlenr(   r+   r   r   r   r'  rk   r   r)   )
r}   r  intr   r.   rW   r   r   r   r   r  s      r   r  zTestVlen.test_int  s   __S!VV""64r":		!1		!11		!1beRYYq\2beRYYq\2beRXXi%89beRYYq\2((BIIaL"))A,7vF1QbeRYYq\2beRYYq\2((BIIaL"))A,781QbeRYYq\2beRYYq\2r   c                     t        j                  t              }| j                  j	                  dd|      }| j                  j	                  dd|d   j
                         y )Nr  rB   r+   vlen2r#   )r}   r  r  r   r.   r,   r  s      r   test_reuse_from_otherzTestVlen.test_reuse_from_other  sI    __S!VV""64r":gtRV\\:r   c                    dt         fdt        j                  t               fg}| j                  j	                  dd|      }| j                  j
                  }| j                  j                          t        j                  |d      | _        | j                  j	                  dd| j                  d   d   d   j                         y )Nr   r   r  rB   r+   r  r#   )	r  r}   r  r   r.   r  r   r   r,   )r   ra  r1   fnames       r   test_reuse_struct_from_otherz%TestVlen.test_reuse_struct_from_other  s    Cj3 456VV""64r":5#&gtTVVF^C-@-D-J-JKr   c                    t        j                  t              }| j                  j	                  dd|      }t        j                  ddg      |d<   t        j                  dg      |d<   g d|d	<   | j                  |d   t        j                  ddg             | j                  |d   t        j                  dg             | j                  |d	   t        j                  g d
             t        j                  g dt        j                  d      gt              |dd	 | j                  |d   t        j                  d             | j                  |d   t        j                  d             t        j                  t        j                  g d      t        j                  g d      g      |dd	 | j                  |d   t        j                  d             | j                  |d   t        j                  d             y )Nr  r@  r+   gffffff?333333?r   r   )r  rk   r   rk   r'  )皙?g?g @g@r)   r)   r   )r  r  皙@)皙?r  r  r   )
r}   r  r  r   r.   rW   r   r   r   r   r  s      r   test_convertzTestVlen.test_convert  s}   __S!VV""64r":#s$1#11beRXXq!f%56beRXXqc]3beRXXi%89((3RYYq\B&Q1QbeRYYq\2beRYYq\2((BHH_5HH_57 81QbeRYYq\2beRYYq\2r   c                 n   t        j                  t              }| j                  j	                  dd|      }t        j                  d      |d<   t        j                  t        j                  d      t        j                  d      gt        j                  d      t        j                  d      ggt              |d d d d f<   t        j                  t        j                  d      t        j                  d      gt        j                  d      t        j                  d      gg      |d d d d f<   y )Nr  r  r+   r   rS  r   rk   )	r}   r  r  r   r.   rW   r   r   r   r  s      r   test_multidimzTestVlen.test_multidim  s    __S!VV""66"<99Q<488biilBIIaL9YYq\299Q<8:AGI1a488biilBIIaL9 iilBIIaL9; <1a4r   c                    t        j                  |      }| j                  j                  |d|      }t	        j
                  g d|      }t	        j
                  g d|      }t	        j
                  g dt	        j                  d            }|j                  |      }g d}	t	        j
                  |	|      }
g d}t	        j
                  ||      }||d	<   ||d
<   ||d<   |	|d<   ||d<   | j                  ||d	          | j                  ||d
          | j                  ||d          | j                  |
|d          | j                  ||d          t	        j
                  ddg|      }
|
dd |d	<   | j                  |
|d	          | j                  j                          | j                  j                          y)z
        Helper for testing various vlen numpy data types.
        :param np_dt: Numpy datatype to test
        :param dataset_name: String name of the dataset to create for testing.
        r  r+   )rf         @g      >@)g33333Y@gi@gfffffX@g      %g     r)r   rk   r  r*   )rf  r  g      @r  g      )r   ir   r   i'  r   r   r   rk   r   r)   g333333?r  N)r}   r  r   r.   rW   r   r,   r  r   r  r   )r   np_dtdataset_namera  r1   array_0array_1array_2casted_array_2list_3list_array_3list_4list_array_4s                r   _help_float_testingzTestVlen._help_float_testing  s    __U#VV""<R"@ ((=6((>eL ((9BHHW,=> . *xxe4 ,xxe411111gr!u-gr!u-nbe4lBqE2lBqE2 xxc
%8Q1lBqE2 	r   c                 P    t        j                  d      }| j                  |       y )Nr  rW   r,   r  r   r  s     r   test_numpy_float16zTestVlen.test_numpy_float16D      #  'r   c                 P    t        j                  d      }| j                  |       y )Nfloat32r  r  s     r   test_numpy_float32zTestVlen.test_numpy_float32H  r  r   c                 P    t        j                  d      }| j                  |       y )Nr  r  r  s     r   test_numpy_float64_from_dtypez&TestVlen.test_numpy_float64_from_dtypeL  r  r   c                 F    t         j                  }| j                  |       y r   )rW   r  r  r  s     r   test_numpy_float64_2zTestVlen.test_numpy_float64_2P  s    

  'r   c                    | j                   j                  ddt        j                  d             t	        j
                  g d      }|ddd   | j                   d   d<   t        | j                   d   d   |ddd   k(        s"J | j                   d   d    d	|ddd           | j                   j                  d
dt        j                  d             t	        j
                  g d      }|ddd   | j                   d
   d<   t        | j                   d
   d   |ddd   k(        s"J | j                   d
   d    d	|ddd           y)z4Test that non-contiguous arrays are stored correctlyncr   r  r+   )TFTTFFFNrk   r   z != nc2int8)rk   r)   r   r   r   r   r   )r   r.   r}   r  rW   r   rH  )r   r  rE  s      r   test_non_contiguous_arraysz#TestVlen.test_non_contiguous_arraysT  s1   dE1HIHHCDCaC&tQ466$<?a!f,-O$&&,q/1B$q1vh/OO-eU$//&2IJHH+,SqS6ua466%=#q1v-.Q466%=3C2DD3Q30QQ.r   c                     t        j                  d      }d}| j                  j                  dd||      }t	        j
                  t              5  t        j                  |j                         t               d d d        y # 1 sw Y   y xY w)Nr  r  r  r  r   r  r+   )r}   r  r   r.   rc   r   r   rW   r   r  r  r  s       r   test_asstr_array_dtypezTestVlen.test_asstr_array_dtypeb  si    0
VV""3bJ"O]]:& 	,HHRXXZs+	, 	, 	,s   *BBN)r  )r    r!   r"   r  r  r  r  r  r  r  r  r  r  r  r  r#   r   r   r  r    sA    3$;
L3"<.`((((R,r   r  c                       e Zd Zd Zd Zy)TestLowOpenc                 p    | j                   j                  dd      }|j                  j                         }y)z Test H5Dget_access_plist r'   r(   N)r   r.   r   r  )r   r1   p_lists      r   test_get_access_listz TestLowOpen.test_get_access_listl  s*    VV""5$/'')r   c                 j   t         j                  j                  t         j                  j                        }| j                  j                  dd      }~t         j                  j                  | j                  j                  d|      }| j                  |t         j                  j                         y)z# Test the dapl keyword to h5d.open r  r      xN)r}   h5prj  DATASET_ACCESSr   r.   ro  r  r   r|   	DatasetID)r   daplr?   dsids       r   	test_daplzTestLowOpen.test_daplq  so    xxtxx667vv$$S&1xx}}TVVYYd3dDHH$6$67r   N)r    r!   r"   r  r  r#   r   r   r  r  j  s    *
8r   r  c            
      D   ddl m}   |        }t        j                  |d      5 }|j	                  dddd       d	|d   d d  d d d        |j                  d       t        j                  |d
      5 }|d   j                  }|j                         dk(  sJ t        d      D ]  }t        t        j                  t        j                  |d            dz        }|j                  |      }|j                  |k(  sJ |j                  dk(  sJ |j                   J |j"                  dkD  rJ  |j%                  d      }|j                  dk(  sJ |j                  dk(  sJ |j                   J |j"                  dkD  sJ 	 d d d        y # 1 sw Y   IxY w# 1 sw Y   y xY w)Nr   BytesIOr   r
  r~  r{   r$  r=   r+  r,   r   r  r   rM   rS  )ior  r}   r   r.   seekr   get_num_chunksr  r<  rW   r   unravel_indexget_chunk_infochunk_offsetfilter_maskbyte_offsetrP   get_chunk_info_by_coord)r  buffoutfinr1   joffsetsis           r   test_get_chunk_detailsr  z  s   
)C	3	 F*XTRVQ HHQK	3	 [^^  "c)))s 	A288B$4$4Q$ABRGHF""1%B??f,,,>>Q&&&>>---77Q;;	 ''/&(((~~"""~~)))ww{{#  
 s   F	1B8F*AF	FF)r   rG  r   )r   rM   rM   )r   rM   c   zJchunk iteration requires  HDF5 1.10.10 and later 1.10, or 1.12.3 and laterc                     ddl m}   |        }t        j                  |d      5 }|j	                  dddd       d	|d   d
d
 d
d
d
       |j                  d       t        j                  |d      5 }|d   j                  }|j                         }|dk(  sJ i t        |      D ]"  }|j                  |      }||j                  <   $ fd}|j                  |       d
d
d
       y
# 1 sw Y   xY w# 1 sw Y   y
xY w)z%H5Dchunk_iter() for chunk informationr   r  r   r
  r~  r{   r$  r  r   Nr  r   c                     | j                      }| j                   |j                   k(  sJ | j                  |j                  k(  sJ | j                  |j                  k(  sJ | j                  |j                  k(  sJ y r   )r  r  r  rP   )
chunk_infoknowncis     r   callbackz!test_chunk_iter.<locals>.callback  sw    z../E**e.@.@@@@))U->->>>>))U->->>>>??ejj000r   )r  r  r}   r   r.   r  r   r  r  r  r  
chunk_iter)	r  r  r   r  
num_chunksr  r  r  r  s	           @r   test_chunk_iterr    s   
 
)C	3	 	z($O&	! HHQK	3	 "y||((*
S   z" 	%A$$Q'B"$Br	%	1 	!#" " 
" "s   C*2A/C6*C36C?c                 b    | j                  dd      }|j                  J |j                  J y )NrV  r*   r+   )r.   r=   r5  )r   r1   s     r   test_empty_shaper    s7    		%	%gW	%	=B88;;r   c                     ddl m}   |        }t        j                  |d      5 }|j	                  dd       d d d        |j                  d       t        j                  |d      5 }|d   j                  J |d   j                  j                         J |d   j                  j                         dk(  sJ 	 d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r  r   rV  r  r+   r  )
r  r  r}   r   r.   r  r+  r   
get_offsetget_storage_size)r  r  r  r  s       r   test_zero_storage_sizer    s    
)C	3	 4G734 HHQK	3	 77|""***7|))+3337|//1Q6667 7	4 47 7s   C'ACCCc                    t        j                  t         j                        j                  t        j                  t         j                        j                  dz   g}| j	                  d|t         j
                        }|j                  t        j                  t         j
                        k(  sJ t         j                  j                  |d d  t        j                  |t         j
                               ||d d  t         j                  j                  |d d  t        j                  |t         j
                               y )Nr   r  rg  r+   )
rW   iinfor   maxr.   uint64r,   r   r   r   )r   ru   r1   s      r   test_python_int_uint64r    s    HHRXX""BHHRXX$6$:$:Q$>?D 
	%	%cBII	%	FB88rxx		****JJ!!"Q%$bii)HI BqEJJ!!"Q%$bii)HIr   c                     | j                  ddt        j                        }t        j                  j	                  dd      }||d d g ddf<   y )	Nru   )r   r/  rk   r+      )r   r   rk   r  )r   rk   r)   .)r.   rW   r  r  r  )r   r   blocks      r   test_setitem_fancy_indexingr    sG    

&
&v|288
&
LCIIc	2E"C9cr   c                  r    t        t        d            5 } | d   d   dk(  sJ 	 d d d        y # 1 sw Y   y xY w)Nzvlen_string_dset.h5DS1r   s   Partingr   r   r   s    r   test_vlen_spacepadr    s>    	 !67	8 )Ax{j((() ) )   -6c                  r    t        t        d            5 } | d   d   dk(  sJ 	 d d d        y # 1 sw Y   y xY w)Nzvlen_string_dset_utc.h5ds1r   s   2009-12-20T10:16:18.662409Zr  r  s    r   test_vlen_nulltermr    s?    	 !:;	< =x{<<<<= = =r  c                     d}| j                  ddt        j                  |d      }t        |      |j                  v sJ y )N   ru   r{   T)r=   r,   rw  allow_unknown_filter)r.   rW   r  r  _filters)r   fake_filter_idr1   s      r   test_allow_unknown_filterr     sE    N		%	%hbhhN! 
& 
B ~"++---r   c            
         ddl m}   |        }t        j                  |d      5 }|j	                  dddddd	d
      }|j
                  j                         j                         }|j
                  j                         j                         dd |k7  sJ |dk(  sJ 	 ddd       |j                  d       t        j                  |d      5 }|j                  dddddd      }|j
                  j                         j                         }|j
                  j                         j                         dd |k7  sJ |dk(  sJ 	 ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)z2Chunk cache configuration for individual datasets.r   r  r   r  )rM   r   )r   r)   r$      r    )r=   r+  r,   rdcc_nbytesrdcc_w0rdcc_nslotsr   N)r  r  r  r    0 q=
ףp?  )r=   r,   r  r  r  )r	  r  r  )r  r  r}   r   r.   r   r  get_chunk_cache	get_cacher  r  )r  r  r  r1   ds_chunk_cacher  s         r   test_dset_chunk_cacher    s`   
)C	3	 =  xd'# ! G //1AACww'')335ab9^KKK!<<<<= HHQK	3	 >  xt'3 ! H //1AACvv&&(224QR8NJJJ!====> >= => >s   A8EA7EEE"c                       e Zd ZdZd Zd Zy)TestCommutativez|
    Test the symmetry of operators, at least with the numpy types.
    Issue: https://github.com/h5py/h5py/issues/1947
    c                    d}| j                   j                  d|t        t        j                  j
                  |       }t        j                  |d         }t        j                  ||k(  ||k(  k(        sJ t        j                  ||k7  ||k7  k(        sJ d}t        j                  |      |z   }t        j                  ||k(  ||k(  k(        sJ t        j                  ||k7  ||k7  k(        sJ y)z
        Create a h5py dataset, extract one element convert to numpy
        Check that it returns symmetric response to == and !=
        r   r   r
  r,   ru   rS  gMbP?N)	r   r.   r  rW   r  r  r  rH  nanmax)r   r=   r?   valdeltanvals         r   test_numpy_commutativez&TestCommutative.test_numpy_commutative  s    
 vv$$VU%*,))..%*@ % B
 jjd$vvsd{4555vvsd{4555 yyu$vvtt|6777vvtt|6777r   c                     d}| j                   j                  d|t        t        j                  j
                  |       }t        d      }||k(  ||k(  k(  sJ ||k7  ||k7  k(  sJ y)z
        Create a h5py dataset and check basetype compatibility.
        Check that operation is symmetric, even if it is potentially
        not meaningful.
        r  r
  r  r  N)r   r.   r  rW   r  r  )r   r=   r?   r  s       r   test_basetype_commutativez)TestCommutative.test_basetype_commutative&  sp     vv$$VU%*,))..%*@ % B
 Bit---t---r   N)r    r!   r"   r7   r  r  r#   r   r   r  r  	  s    80.r   r  c                       e Zd ZdZd Zd Zy)TestVirtualPrefixz%
    Test setting virtual prefix
    c                 D   d}d}| j                   j                  d|t        t        j                  j
                  | |      }t        j                  |j                  j                         j                         j                               j                         }||k(  sJ y )Nr  /path/to/virtualr
  )r,   ru   virtual_prefix)r   r.   r  rW   r  r  r  r  r   r  get_virtual_prefixr  r  )r   r=   r  r?   virtual_prefix_readbacks        r   test_virtual_prefix_createz,TestVirtualPrefix.test_virtual_prefix_create:  s    +vv$$VU%*,))..%*@6D % F #*,,tww/G/G/I/\/\/^/e/e/g"h"q"q"s&.888r   c                 |   d}| j                   j                  ddd|      }t        j                  |j                  j                         j                         j                               j                         }| j                  ||       | j                  |t               | j                  |j                  d       y )Nr  r'   r   r   )r  )r   r  r  r  r   r  r  r  r  r<   r|   r	   r=   )r   r  r?   r   s       r   test_virtual_prefix_requirez-TestVirtualPrefix.test_virtual_prefix_requireD  s    +vv%%eWcN%["),,tww/G/G/I/\/\/^/e/e/g"h"q"q"s)@AdG,W-r   N)r    r!   r"   r7   r!  r#  r#   r   r   r  r  6  s    9.r   r  c                 \    t        j                  d      }d}| j                  d|||      S )Nr  r  s   fillr  r  )r}   r  r.   filer=   ra  r  s       r   ds_strr'  M  s1    			G	,BJsEzJJr   c                     t        j                  dt        j                  d      fdt         j                  fg      }t        j
                  d|      }t        j                  ||      | d<   | d   S )Nr'   r  r  rJ   )fillr  r+   r  )rW   r,   r}   r  r  r  broadcast_tor%  s       r   	ds_fieldsr+  S  sd    		!!734	

 
B M4J
E2DI9r   zview_getter,make_dsc                     | S r   r#   r1   s    r   <lambda>r.  `  s    B r   c                 .    | j                  t              S )Nr+   )r  r   r-  s    r   r.  r.  a  s    BIIFI+ r   c                 "    | j                         S r   )r  r-  s    r   r.  r.  b  s    BHHJ r   c                 $    | j                  d      S )Nr'   )r  r-  s    r   r.  r.  c  s    BIIe$ r   )r1   r  r  r  )ids)rk   r   Fr   Tc                 R     ||      } | |      }t        j                  ||       y )Nr   )rW   r   )view_gettermake_dsr   r   r1   views         r   test_array_copyr8  k  s%     
	Br?DHHTr   z"forbidding copies requires numpy 2c                      ||      } | |      }t        j                  t        d      5  t        j                  |d       d d d        y # 1 sw Y   y xY w)Nz#memory allocation cannot be avoidedrK  Fr4  )rc   r   r   rW   r   r5  r6  r   r1   r7  s        r   test_array_copy_falser;  s  sI     
	Br?D	z)N	O #
E"# # #s   AAc                      ||      } | |      }t        j                  |d      j                  t        j                  d      k(  sJ y )Nr  r+   )rW   r   r,   r:  s        r   test_array_dtyper=    s=    		Br?D88D'--&1AAAAr   c                      ||d      } | |      }t        |d   t        t        f      sJ t        j                  |      j
                  dk(  sJ y )Nr#   r  )r   r  r  rW   r   r=   r:  s        r   test_array_scalarr?    sK    	b	)Br?Dd2h---88D>2%%%r   c                 p     ||d      } | |      }t        j                  |      j                  dk(  sJ y )Nr   rL   r  )rW   r   r=   r:  s        r   test_array_ndrB    s3    	f	-Br?D88D>6)))r   c                      ||d      } | |      }|j                   t        j                   t              k(  sJ |j                  dk(  sJ |j                  dk(  sJ |j
                  dk(  sJ t        |      dk(  sJ y )NrA  r  rk   r   r   )r,   rW   r   ndimr=   rP   r=  r:  s        r   test_view_propertiesrE    st    	f	-Br?D::&))))99>>::99??t9>>r   )r   )nr7   r  r#  r  numpyrW   ra   rc   warningscommonr   r   
data_filesr   r}   r   r   r	   h5py._hl.baser
   r   r   r   h5py.h5py_warningsr   r   h5py._hl.selectionsr  
selectionsr  h5py.tests.commonr   r   r%   r9   rr   r   r   r  r(  rR  rj  r   r   r  r*   r   r  r  r  r  r  r  ro   r  r  r  r  r  r  r  r  r  r  r?  rS  rp  r  r  r  r  r  r   r#  r,  r=  rG  rP  rd   hdf5_version_tuplerv  rZ  rx  r  r  r  r  rE  r  r  r  r  r  r  r  r   r  r  r  r'  r+  view_gettersCOPY_IF_NEEDEDr8  skipifr;  r=  r?  rB  rE  r#   r   r   <module>rS     sU    	 
       * % % 5  5   ! ! 3( P{ P(D,k D,LVF[ VFr9# 9#x%# %#P@6 @6F@D @DF#B+ #BLQ2; Q2h !HXXqMXXqM
CLZZZZT2C8T2C8T(#.T(#.T#) &&
8+ 8 6,,,.HI)7[ )7 J)7X 6,,,.HI$W+ $W J$WN 5+++-CD6K 6 E6: 6,,,.EF	B[ 	B G	B 9DLL///1KL	& 	& M	& <t||2224QR); ) S) = 3 335STn0K n0 Un0bi-; i-X):[ ):X2[ 2:"M "MLA4 A4H0 0&.k ..{ *P4+ P4fd@; d@N:; :$J{ J4D D6C[ C$2K 2: ))LL##z18 *  
-G[ -G`? ?,9 9M,{ M,`8+ 8 8 t||..*< r//;>p4<<CbCbepCp[]"]":7J#)
=
.>,+.k +.Z. ..K {{&&		+V4	'	$i0	 	, ' 	 0&8d$!78  9 F"/   # 	
# B B & & * *  r   