
    d                         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dS )z0
    Tests for the (internal) selections module
    N   )TestCaseutc                       e Zd Zd Zd ZdS )BaseSelectionc                     t          j        |                                 d          | _        | j                            dd          j        | _        d S )Nwx )h5pyFilemktempfcreate_datasetiddsidselfs    :lib/python3.11/site-packages/h5py/tests/test_selections.pysetUpzBaseSelection.setUp   s=    4;;==#..F))#r225			    c                 J    | j         r| j                                          d S d S )N)r   closer   s    r   tearDownzBaseSelection.tearDown   s)    6 	FLLNNNNN	 	r   N)__name__
__module____qualname__r   r   r   r   r   r   r      s2        6 6 6    r   r   c                   $    e Zd ZdZd Zd Zd ZdS )TestTypeGenerationzU
        Internal feature: Determine output types from dataset dtype and fields.
    c                     t          j        d          }t          j        |d          \  }}|                     ||           |                     |t          j        d                     dS )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$   s_    Xc]]&r2..Vf%%%bhsmm,,,,,r   c                     t          j        d          }|                     t                    5  t	          j        |d          \  }}ddd           dS # 1 swxY w Y   dS )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+   s    Xc]]z** 	7 	7*2v66KC	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   AAAc                    t          j        g d          }t          j        |d          \  }}|                     ||           |                     ||           t          j        |d          \  }}|                     ||           |                     |t          j        ddg                     t          j        |d          \  }}|                     |t          j        d                     |                     |t          j        dg                     |                     t                    5  t          j        |d          \  }}d	d	d	           d	S # 1 swxY w Y   d	S )
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   X;;;== &r2..Vf%%%b!!! &r955Vf%%%bhI(>@@AAA &r622Vbhsmm,,,I;!8!8999 z** 	; 	;*2z::KC	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   6EE #E N)r   r   r   __doc__r+   r1   r9   r   r   r   r   r      sK         - - -7 7 7; ; ; ; ;r   r   c                       e Zd ZdZd ZdS )TestScalarSliceRuleszD
        Internal feature: selections rules for scalar datasets
    c                    t          j        | j        d          \  }}|                     |d           |                     |                                d           t          j        | j        t
          f          \  }}|                     |d           |                     |                                d           |                     t                    5  t          j        | j        d          \  }}ddd           n# 1 swxY w Y   | j        	                    dd          j
        }|                     t                    5  t          j        |d          \  }}ddd           dS # 1 swxY w Y   dS )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   s   6ty"EEy%%%5577;;;6ty8+NNy###5577;;;z** 	L 	L#:49dKKE9	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L v$$S$//2|,, 	G 	G#:4FFE9	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs$   DDDE,,E03E0N)r   r   r   r:   rE   r   r   r   r<   r<   H   s2         G G G G Gr   r<   c                       e Zd ZdZd ZdS )TestSelectionz/ High-level routes to generate a selection
    c                 ^   | j                             dd          }|j        ddddf         }t          j        dt          g d          |          }|                     |t          j                   t          j        dd|          }|                     |t          j                   t          j        dt          j	        g d	          |          }|                     |t          j
                   t          j        dd
|          }|                     |t          j                   |                     t                    5  t          j        dd|           d d d            n# 1 swxY w Y   t          j        d||          }|                     |t          j                   |                     t                    5  t          j        d|d            d d d            n# 1 swxY w Y   |                     t                    5  t          j        d||           d d d            n# 1 swxY w Y   t          j        d||          }|                     ||           |                     t                    5  t          j        d||           d d d            d S # 1 swxY w Y   d S )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   sg   v$$VY77#qu- ZtGGG}}d33b#"4555 Z|T22b#"4555 jrx(E(E(EFFMMc3#5666 j4((c3#6777 y)) 	, 	,Jvud+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, jFD11c3=111 y)) 	- 	-Jvvt,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- y)) 	- 	-Jvvt,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- jC..S!!! y)) 	* 	*JvsD)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*sH   E''E+.E+G%%G),G)
H--H14H1>J""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      s/         ! ! ! ! ! ! ! ! ! # # # # # # # # #                    H   (; (; (; (; (; (; (; (;TG G G G G= G G G./* /* /* /* /*M /* /* /* /* /*r   