o
    g’×i  ã                   @   sŒ   d Z ddlZddlZddlm  mZ ddlm  m	Z
 ddlmZmZ G dd„ deƒZG dd„ deƒZG d	d
„ d
eƒZG dd„ deƒZdS )z0
    Tests for the (internal) selections module
é    Né   )ÚTestCaseÚ	make_namec                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚBaseSelectionc                 C   s*   t  |  ¡ d¡| _| j ddd¡j| _d S )NÚwÚx© Úf4)Úh5pyÚFileÚmktempÚfÚcreate_datasetÚidÚdsid©Úselfr   r   úX/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/h5py/tests/test_selections.pyÚsetUp   s   zBaseSelection.setUpc                 C   s   | j r
| j  ¡  d S d S )N)r   Úcloser   r   r   r   ÚtearDown   s   ÿzBaseSelection.tearDownN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s    r   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚTestTypeGenerationzU
        Internal feature: Determine output types from dataset dtype and fields.
    c                 C   s<   t  d¡}t |d¡\}}|  ||¡ |  |t  d¡¡ dS )z. Non-compound types are handled appropriately Úir   N)ÚnpÚdtypeÚsel2Úread_dtypesÚassertEqual©r   ÚdtÚoutÚformatr   r   r   Útest_simple$   s   
zTestTypeGeneration.test_simplec                 C   sJ   t  d¡}|  t¡ t |d¡\}}W d  ƒ dS 1 sw   Y  dS )z3 Field names for non-field types raises ValueError r   ©ÚaN)r   r   ÚassertRaisesÚ
ValueErrorr   r   r!   r   r   r   Útest_simple_fieldexc+   s   
"ÿz'TestTypeGeneration.test_simple_fieldexcc                 C   sÞ   t  g d¢¡}t |d¡\}}|  ||¡ |  ||¡ t |d¡\}}|  ||¡ |  |t  ddg¡¡ t |d¡\}}|  |t  d¡¡ |  |t  dg¡¡ |  t¡ t |d¡\}}W d	  ƒ d	S 1 shw   Y  d	S )
z( Compound types with elemental subtypes )©r'   r   ©Úbr   )Úcz|S10r   )r'   r-   r+   r,   r&   r   )ÚjÚkN)r   r   r   r   r    r(   r)   r!   r   r   r   Útest_compound_simple1   s   "ÿz'TestTypeGeneration.test_compound_simpleN)r   r   r   Ú__doc__r%   r*   r1   r   r   r   r   r      s
    r   c                   @   ó   e Zd ZdZdd„ ZdS )ÚTestScalarSliceRuleszD
        Internal feature: selections rules for scalar datasets
    c                 C   sî   t  | jd¡\}}|  |d¡ |  | ¡ d¡ t  | jtf¡\}}|  |d¡ |  | ¡ d¡ |  t¡ t  | jd¡\}}W d  ƒ n1 sHw   Y  | j 	t
ƒ dd¡j}|  t¡ t  |d¡\}}W d  ƒ dS 1 spw   Y  dS )z* Permissible arguments for scalar slicing r   Nr   )r   r	   )r   Úread_selections_scalarr   r    Úget_select_npointsÚEllipsisr(   r)   r   r   r   r   ÚRuntimeError)r   ÚshapeÚ	selectionr   r   r   r   Ú	test_argsN   s   ÿ"ÿzTestScalarSliceRules.test_argsN)r   r   r   r2   r;   r   r   r   r   r4   H   s    r4   c                   @   r3   )ÚTestSelectionz/ High-level routes to generate a selection
    c                 C   sÆ  | j  tƒ dd¡}|jdd…dd…f }t dtg d¢ƒ|¡}|  |tj¡ t dd|¡}|  |tj¡ t dt	 
g d	¢¡|¡}|  |tj¡ t dd
|¡}|  |tj¡ |  t¡ t dd|¡ W d   ƒ n1 slw   Y  t d||¡}|  |tj¡ |  t¡ t d|d ¡ W d   ƒ n1 s–w   Y  |  t¡ t d||¡ W d   ƒ n1 s²w   Y  t d||¡}|  ||¡ |  t¡ t d||¡ W d   ƒ d S 1 sÜw   Y  d S )N)éd   r=   r	   r   r=   )é
   ©r   é   é   )r?   )é   )TFFFTr   )r=   Úfoo)r   r   r   Ú	regionrefÚselÚselectÚlistÚassertIsInstanceÚFancySelectionr   ÚarrayÚPointSelectionÚSimpleSelectionr(   Ú	TypeErrorÚ	Selectionr    )r   ÚdsetÚregrefÚstÚst1Úst2Úst3Úst4r   r   r   Útest_selectiond   s4   ÿÿÿ"ÿzTestSelection.test_selectionN)r   r   r   r2   rV   r   r   r   r   r<   _   s    r<   )r2   Únumpyr   r
   Úh5py._hl.selectionsÚ_hlÚ
selectionsrE   Úh5py._hl.selections2Úselections2r   Úcommonr   r   r   r   r4   r<   r   r   r   r   Ú<module>   s   		*