
    1Vh                         d Z ddlZddlZddlmc mZ ddlmc m	Z
 ddlmZmZ  G d de      Z G d de      Z G d	 d
e      Z G d de      Zy)z0
    Tests for the (internal) selections module
    N   )TestCaseutc                       e Zd Zd Zd Zy)BaseSelectionc                     t        j                  | j                         d      | _        | j                  j	                  dd      j
                  | _        y )Nwx )h5pyFilemktempfcreate_datasetiddsidselfs    J/home/dcms/DCMS/lib/python3.12/site-packages/h5py/tests/test_selections.pysetUpzBaseSelection.setUp   s8    4;;=#.FF))#r255	    c                 R    | j                   r| j                   j                          y y )N)r   closer   s    r   tearDownzBaseSelection.tearDown   s    66FFLLN r   N)__name__
__module____qualname__r   r   r   r   r   r   r      s    6r   r   c                   "    e Zd ZdZd Zd Zd Zy)TestTypeGenerationzU
        Internal feature: Determine output types from dataset dtype and fields.
    c                     t        j                  d      }t        j                  |d      \  }}| j	                  ||       | j	                  |t        j                  d             y)z. Non-compound types are handled appropriately ir   N)npdtypesel2read_dtypesassertEqualr   dtoutformats       r   test_simplezTestTypeGeneration.test_simple$   sM    XXc]&&r2.Vf%bhhsm,r   c                     t        j                  d      }| j                  t              5  t	        j
                  |d      \  }}ddd       y# 1 sw Y   yxY w)z3 Field names for non-field types raises ValueError r!   aN)r"   r#   assertRaises
ValueErrorr$   r%   r'   s       r   test_simple_fieldexcz'TestTypeGeneration.test_simple_fieldexc+   sH    XXc]z* 	7**2v6KC	7 	7 	7s   AAc                    t        j                  g d      }t        j                  |d      \  }}| j	                  ||       | j	                  ||       t        j                  |d      \  }}| j	                  ||       | j	                  |t        j                  ddg             t        j                  |d      \  }}| j	                  |t        j                  d             | j	                  |t        j                  dg             | j                  t              5  t        j                  |d      \  }}d	d	d	       y	# 1 sw Y   y	xY w)
z( Compound types with elemental subtypes )r.   r!   br   )cz|S10r   )r.   r5   r3   r4   r-   r!   )jkN)r"   r#   r$   r%   r&   r/   r0   r'   s       r   test_compound_simplez'TestTypeGeneration.test_compound_simple1   s   XX;= &&r2.Vf%b! &&r95Vf%bhhI(>@A &&r62Vbhhsm,I;!89 z* 	;**2z:KC	; 	; 	;s    EEN)r   r   r   __doc__r+   r1   r9   r   r   r   r   r      s    -7;r   r   c                       e Zd ZdZd Zy)TestScalarSliceRuleszD
        Internal feature: selections rules for scalar datasets
    c                    t        j                  | j                  d      \  }}| j                  |d       | j                  |j	                         d       t        j                  | j                  t
        f      \  }}| j                  |d       | j                  |j	                         d       | j                  t              5  t        j                  | j                  d      \  }}ddd       | j                  j                  dd      j                  }| j                  t              5  t        j                  |d      \  }}ddd       y# 1 sw Y   gxY w# 1 sw Y   yxY w)z* Permissible arguments for scalar slicing r   Nr   )r   y)r$   read_selections_scalarr   r&   get_select_npointsEllipsisr/   r0   r   r   r   RuntimeError)r   shape	selectionr   s       r   	test_argszTestScalarSliceRules.test_argsN   s0   66tyy"Ey%557;66tyy8+Ny#557;z* 	L#::499dKE9	L vv$$S$/22|, 	G#::4FE9	G 	G		L 	L	G 	Gs   $E,EEE$N)r   r   r   r:   rE   r   r   r   r<   r<   H   s    Gr   r<   c                       e Zd ZdZd Zy)TestSelectionz/ High-level routes to generate a selection
    c                 (   | j                   j                  dd      }|j                  ddddf   }t        j                  dt        g d      |      }| j                  |t        j                         t        j                  dd|      }| j                  |t        j                         t        j                  dt        j                  g d	      |      }| j                  |t        j                         t        j                  dd
|      }| j                  |t        j                         | j                  t              5  t        j                  dd|       d d d        t        j                  d||      }| j                  |t        j                         | j                  t              5  t        j                  d|d        d d d        | j                  t              5  t        j                  d||       d d d        t        j                  d||      }| j                  ||       | j                  t              5  t        j                  d||       d d d        y # 1 sw Y   
xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Ndset)d   rJ   r   rJ   )
   r         )rL   )   )TFFFTr   )rJ   foo)r   r   	regionrefselselectlistassertIsInstanceFancySelectionr"   arrayPointSelectionSimpleSelectionr/   	TypeError	Selectionr&   )r   rI   regrefstst1st2st3st4s           r   test_selectionzTestSelection.test_selectiond   s   vv$$VY7#qu- ZZtG}d3b#"4"45 ZZ|T2b#"4"45 jjrxx(EFMc3#5#56 jj4(c3#6#67 y) 	,JJvud+	, jjFD1c3==1 y) 	-JJvvt,	- y) 	-JJvvt,	- jjC.S! y) 	*JJvsD)	* 	*)	, 	,	- 	-	- 	-	* 	*s0   I#/I0$I<J#I-0I9<JJN)r   r   r   r:   rb   r   r   r   rG   rG   _   s    **r   rG   )r:   numpyr"   r   h5py._hl.selections_hl
selectionsrR   h5py._hl.selections2selections2r$   commonr   r   r   r   r<   rG   r   r   r   <module>rj      sT      ! ! # #  H (; (;TG= G./*M /*r   