
    1Vh                         d Z ddlZddlmZ ddlmZ ddlmZ ddlmZmZ dd	l	m
Z
  G d
 dej                        Z G d dej                        Zy)z3
    Implements support for HDF5 dimension scales.
    N   )h5ds)H5pyDeprecationWarning   )base)phil	with_phil)Datasetc                       e Zd ZdZeed               Zej                  ed               Zed        Zed        Z	ed        Z
ed        Zed        Zed	        Zd
 Zd Zd Zd Zd Zed        Zy)DimensionProxyz-
        Represents an HDF5 "dimension".
    c                 t    | j                  t        j                  | j                  | j                              S )z& Get or set the dimension scale label )_dr   	get_label_id
_dimensionselfs    =/home/dcms/DCMS/lib/python3.12/site-packages/h5py/_hl/dims.pylabelzDimensionProxy.label   s&     wwt~~dhh@AA    c                 x    t        j                  | j                  | j                  | j	                  |             y N)r   	set_labelr   r   _e)r   vals     r   r   zDimensionProxy.label#   s$     	txx$''#,?r   c                      || _         || _        y r   )r   r   )r   id_	dimensions      r   __init__zDimensionProxy.__init__)   s    #r   c                 X    t        t        |       | j                  | j                  f      S r   )hashtyper   r   r   s    r   __hash__zDimensionProxy.__hash__.   s     T$Z4??;<<r   c                 0    t        |       t        |      k(  S r   )r!   )r   others     r   __eq__zDimensionProxy.__eq__2   s    DzT%[((r   c              #   @   K   | j                         E d {    y 7 wr   )keysr   s    r   __iter__zDimensionProxy.__iter__6   s     99;s   c                 V    t        j                  | j                  | j                        S r   )r   get_num_scalesr   r   r   s    r   __len__zDimensionProxy.__len__:   s    ""488T__==r   c                 F    t        t              rFg }t        j                   j                   j
                  |j                  d       t        |         S  fd}t        j                   j                   j
                  |d      }|t              t        |      S )Nr   c                 X    t        j                  |       j                        k(  r| S y)z- Iterate over scales to find a matching name N)r   get_scale_namer   )dsiditemr   s    r   fz%DimensionProxy.__getitem__.<locals>.fG   s(    &&t,=K >r   )	
isinstanceintr   iterater   r   appendr
   KeyError)r   r1   scalesr2   ress   ``   r   __getitem__zDimensionProxy.__getitem__>   s}     dC FLL4??FMM1E6$<(( 
 ,,txx!Q?C{tn$3<r   c                     t         5  t        j                  | j                  |j                  | j
                         ddd       y# 1 sw Y   yxY w)zo Attach a scale to this dimension.

        Provide the Dataset of the scale you would like to attach.
        N)r   r   attach_scaler   idr   r   dsets     r   r<   zDimensionProxy.attach_scaleQ   >    
  	BdhhA	B 	B 	B   6AAc                     t         5  t        j                  | j                  |j                  | j
                         ddd       y# 1 sw Y   yxY w)zq Remove a scale from this dimension.

        Provide the Dataset of the scale you would like to remove.
        N)r   r   detach_scaler   r=   r   r>   s     r   rC   zDimensionProxy.detach_scaleY   r@   rA   c           	      J   t         5  g }t        |       dkD  r6t        j                  | j                  | j
                  |j                  d       |D cg c]1  }| j                  t        j                  |            t        |      f3 c}cddd       S c c}w # 1 sw Y   yxY w)zX Get a list of (name, Dataset) pairs with all scales on this
        dimension.
        r   N)
r   lenr   r5   r   r   r6   r   r/   r
   )r   r8   xs      r   itemszDimensionProxy.itemsa   s      	F 4y1}TXXtqI   ,,Q/0'!*=	 		 	s   AB6BBBB"c                     t         5  | j                         D cg c]  \  }}|	 c}}cddd       S c c}}w # 1 sw Y   yxY w)z7 Get a list of names for the scales on this dimension. Nr   rG   )r   key_s      r   r(   zDimensionProxy.keysr   s:     	6(,

5HS!C5	6 	65	6 	6   :4::Ac                     t         5  | j                         D cg c]  \  }}|	 c}}cddd       S c c}}w # 1 sw Y   yxY w)z5 Get a list of Dataset for scales on this dimension. NrI   )r   rK   r   s      r   valueszDimensionProxy.valuesw   s:     	6(,

5HQC5	6 	65	6 	6rL   c                 z    | j                   syd| j                  | j                  t        | j                         fz  S )Nz"<Dimension of closed HDF5 dataset>z)<"%s" dimension %d of HDF5 dataset at %s>)r   r   r   r=   r   s    r   __repr__zDimensionProxy.__repr__|   s3    xx7;**door$((|<= 	>r   N)__name__
__module____qualname____doc__propertyr	   r   setterr   r#   r&   r)   r,   r:   r<   rC   rG   r(   rN   rP    r   r   r   r      s     B  B \\@  @ $ $ = = ) )   > >    $BB"6
6
 > >r   r   c                   h    e Zd ZdZed        Zed        Zed        Zed        Zed        Z	d	dZ
y)
DimensionManagerz
        Represents a collection of dimension associated with a dataset.

        Like AttributeManager, an instance of this class is returned when
        accessing the ".dims" property on a Dataset.
    c                 &    |j                   | _        y)z Private constructor.
        N)r=   r   )r   parents     r   r   zDimensionManager.__init__   s     99r   c                 f    |t        |       dz
  kD  rt        d      t        | j                  |      S )z# Return a Dimension object
        r   zIndex out of range)rE   
IndexErrorr   r   )r   indexs     r   r:   zDimensionManager.__getitem__   s1     3t9q= 122dhh..r   c                 .    | j                   j                  S )z3 Number of dimensions associated with the dataset. )r   rankr   s    r   r,   zDimensionManager.__len__   s     xx}}r   c              #   L   K   t        t        |             D ]	  }| |     yw)z Iterate over the dimensions. N)rangerE   )r   is     r   r)   zDimensionManager.__iter__   s)      s4y! 	Aq'M	s   "$c                 L    | j                   sydt        | j                         z  S )Nz#<Dimensions of closed HDF5 dataset>z!<Dimensions of HDF5 object at %s>)r   r=   r   s    r   rP   zDimensionManager.__repr__   s    xx82R\AAr   c                 ^    t        j                  dt        d       |j                  |       y)zo Create a new dimension, from an initial scale.

        Provide the dataset and a name for the scale.
        zTother_ds.dims.create_scale(ds, name) is deprecated. Use ds.make_scale(name) instead.r   )
stacklevelN)warningswarnr   
make_scale)r   r?   names      r   create_scalezDimensionManager.create_scale   s(    
 	 9,	 	r   N) )rQ   rR   rS   rT   r	   r   r:   r,   r)   rP   rk   rW   r   r   rY   rY      sr      
 / /    
 B B
	r   rY   )rT   rg   rl   r   h5py_warningsr   r   r   r	   datasetr
   CommonStateObjectr   rY   rW   r   r   <module>rp      sE      2  ! j>T++ j>Z1t-- 1r   