
    d
                     J    d Z ddlZddlmZ d Zd Z G d d          Zd	 ZdS )
z7
    Implements a portion of the selection operations.
    N   )h5sc                 V    t          |          dk    r }n` j        t          d          t           fd|D                       rt          d          t	          j         fd|D                       }t          |          dk    r|j        |d                  d         }n|}||fS )z Returns a 2-tuple containing:

    1. Output dataset dtype
    2. Dtype containing HDF5-appropriate description of destination
    r   Nz+Field names only allowed for compound typesc              3   *   K   | ]}|j         vV  d S N)names).0xdataset_dtypes     4lib/python3.11/site-packages/h5py/_hl/selections2.py	<genexpr>zread_dtypes.<locals>.<genexpr>   s+      99aQm))999999    z#Field does not appear in this type.c                 :    g | ]}|j         |         d          fS )r   )fields)r	   namer   s     r   
<listcomp>zread_dtypes.<locals>.<listcomp>"   s+     Y Y Y4$(<T(B1(E!F Y Y Yr      )lenr   
ValueErroranynpdtyper   )r   r   format_dtypeoutput_dtypes   `   r   read_dtypesr      s     5zzQ$			$FGGG	99995999	9	9 [>??? x Y Y Y YSX Y Y YZZ
5zzQ#*584Q7 $%%r   c                     | j         dk    rt          d          |dk    rd}n|t          fk    rd}nt          d          |                                 }|                                 ||fS )z Returns a 2-tuple containing:

    1. Output dataset shape
    2. HDF5 dataspace containing source selection.

    Works for scalar datasets.
     z1Illegal selection function for non-scalar datasetN-Illegal slicing argument for scalar dataspace)shapeRuntimeErrorEllipsisr   	get_space
select_all)dsidargs	out_shapesource_spaces       r   read_selections_scalarr(   .   s     zRNOOOrzz 			(				 HIII>>##Ll""r   c                       e Zd ZdZd Zd ZdS )ScalarReadSelectionz5
        Implements slicing for scalar datasets.
    c                     |dk    rd | _         n#|t          fk    rd| _         nt          d          t          j        t          j                  | _        || _        d S )Nr   r   )mshaper!   r   r   createSCALARmspacefspace)selfr0   r%   s      r   __init__zScalarReadSelection.__init__P   sW    2::DKKh[  DKKLMMMj,,r   c              #   \   K   | j                                          | j        | j         fV  d S r   )r/   r#   r0   )r1   s    r   __iter__zScalarReadSelection.__iter__[   s5         k4;&&&&&&r   N)__name__
__module____qualname____doc__r2   r4   r   r   r   r*   r*   J   s<         	 	 	' ' ' ' 'r   r*   c                 T    | j         dk    rt          | |          S t                      )zn Top-level dispatch function for reading.

    At the moment, only supports reading from scalar datasets.
    r   )r   r*   NotImplementedError)r0   r%   s     r   select_readr;   _   s-    
 |r"64000


r   )	r8   numpyr    r   r   r(   r*   r;   r   r   r   <module>r>      s              & & &:# # #8' ' ' ' ' ' ' '*         r   