a
    zn„f,  ã                   @  sh   d Z ddlmZ ddlZddlZddlZe d¡Ze d¡Ze 	d¡Z
G dd„ dejjƒZeejd	< dS )
zô
This module defines a versionless model for ``TBasket``, including much of the
functionality of basket-reading.

Includes both "embedded" ``TBaskets`` (as a member of TBranch) and "free"
``TBaskets`` (top-level objects, located by ``TKeys``).
é    )ÚannotationsNz>ihiIhhz>Hiiiiz>i4c                   @  sÎ   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZd'dd„Z	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd „ ƒZed!d"„ ƒZd#d$„ Zd%d&„ Zd
S )(ÚModel_TBasketa  
    A versionless :doc:`uproot.model.Model` for ``TBasket``.

    Since this model is versionless and most of its functionality is internal
    (not to be directly accessed by most users), it is defined on the model
    instead of creating a behavior class to mix in functionality.
    c                 C  s6   | j d ur| j nd}d|› d| jj›dt| ƒd›d�S )Nz	(unknown)z	<TBasket z of z at 0xZ012xú>)Ú_basket_numÚ_parentÚnameÚid)ÚselfÚ
basket_num© r   úX/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/uproot/models/TBasket.pyÚ__repr__    s    zModel_TBasket.__repr__c                 C  s   | j S )a  
        The raw but uncompressed data in the ``TBasket``, which combines data
        content with entry offsets, if the latter exists.

        If there are no entry offsets, this is identical to
        :ref:`uproot.models.TBasket.Model_TBasket.data`.
        )Ú	_raw_data©r	   r   r   r   Úraw_data$   s    	zModel_TBasket.raw_datac                 C  s   | j S )zõ
        The uncompressed data content in the ``TBasket``, not including any
        entry offsets, if they exist.

        If there are no entry offsets, this is identical to
        :ref:`uproot.models.TBasket.Model_TBasket.raw_data`.
        )Ú_datar   r   r   r   Údata/   s    	zModel_TBasket.datac                 C  s   | j S )ag  
        The index where each entry starts and stops in the
        :ref:`uproot.models.TBasket.Model_TBasket.data`, not including header.

        The first offset is ``0`` and the number of offsets is one greater than
        the number of entries, such that the last offset is the length of
        :ref:`uproot.models.TBasket.Model_TBasket.data`.
        )Ú_byte_offsetsr   r   r   r   Úbyte_offsets:   s    
zModel_TBasket.byte_offsetsNÚakFc              
   C  sp   |du r| j j}tjj |¡}d|i}| | j| j| | j | j j| j	d ||¡}| 
|gd| jd| jg|| j |¡S )zú
        The ``TBasket`` data and entry offsets as an array, given an
        :doc:`uproot.interpretation.Interpretation` (or the ``TBranch`` parent's
        :ref:`uproot.behaviors.TBranch.TBranch.interpretation`) and a
        ``library``.
        NÚ
ak_add_docÚfKeylenr   )r   ÚinterpretationÚuprootÚlibraryZ_regularize_libraryÚbasket_arrayr   r   ÚcontextÚ_membersZfinal_arrayÚnum_entries)r	   r   r   r   Zinterp_optionsr   r   r   r   ÚarrayF   s.    øùzModel_TBasket.arrayc                 C  sF   | j j}|dur>|j}|| j }|| jd  }|j||dd�S dS dS )a   
        The number of items in each entry as a NumPy array, derived from the
        parent ``TBranch``'s
        :ref:`uproot.behaviors.TBranch.TBranch.count_branch`. If there is
        no such branch (e.g. the data are ``std::vector``), then this method
        returns None.
        Né   Únp)Úentry_startÚ
entry_stopr   )r   Úcount_branchÚentry_offsetsr   r   )r	   r$   r%   r"   r#   r   r   r   Úcountsh   s    	
ÿzModel_TBasket.countsc                 C  s   | j S )zG
        The index of this ``TBasket`` within its ``TBranch``.
        )r   r   r   r   r   r
   |   s    zModel_TBasket.basket_numc                 C  s   | j  | j¡S )zO
        The starting and stopping entry numbers for this ``TBasket``.
        )r   Zbasket_entry_start_stopr   r   r   r   r   Úentry_start_stopƒ   s    zModel_TBasket.entry_start_stopc                 C  s   | j S )zž
        The instance version of the ``TKey`` for this ``TBasket`` (which is
        deserialized along with the ``TBasket``, unlike normal objects).
        )Ú_key_versionr   r   r   r   Úkey_versionŠ   s    zModel_TBasket.key_versionc                 C  s
   | j d S )z<
        The number of entries in this ``TBasket``.
        ÚfNevBuf©r   r   r   r   r   r   ’   s    zModel_TBasket.num_entriesc                 C  s   | j d | j d kS )a  
        If this ``TBasket`` is embedded within its ``TBranch`` (i.e. must be
        deserialized as part of the ``TBranch``), then ``is_embedded`` is True.

        If this ``TBasket`` is a free-standing object, then ``is_embedded`` is
        False.
        ÚfNbytesr   r+   r   r   r   r   Úis_embedded™   s    	zModel_TBasket.is_embeddedc                 C  s   | j d | j d  S )zÞ
        The number of bytes for the uncompressed data, including the TKey header.

        If the ``TBasket`` is uncompressed, this is equal to
        :ref:`uproot.models.TBasket.Model_TBasket.compressed_bytes`.
        r   ÚfObjlenr+   r   r   r   r   Úuncompressed_bytes¤   s    z Model_TBasket.uncompressed_bytesc                 C  s
   | j d S )a  
        The number of bytes for the compressed data, including the TKey header
        (which is always uncompressed).

        If the ``TBasket`` is uncompressed, this is equal to
        :ref:`uproot.models.TBasket.Model_TBasket.uncompressed_bytes`.
        r,   r+   r   r   r   r   Úcompressed_bytes®   s    	zModel_TBasket.compressed_bytesc                 C  s   | j S )a¢  
        For compressed ``TBaskets``, a tuple of 3-tuples containing

        ``(name of algorithm, num compressed bytes, num uncompressed bytes)``

        to describe the actual compression algorithms and sizes encountered in
        each block of data.

        The name of the algorithm can be ``"ZLIB"``, ``"LZMA"``, ``"LZ4"``, or
        ``"ZSTD"``.

        For uncompressed ``TBaskets``, this is None.
        )Ú_block_compression_infor   r   r   r   Úblock_compression_info¹   s    z$Model_TBasket.block_compression_infoc                 C  s   | j d | j d  S )z 
        The byte position of the boundary between data content and entry offsets.

        Equal to ``self.member("fLast") - self.member("fKeylen")``.
        ÚfLastr   r+   r   r   r   r   ÚborderÊ   s    zModel_TBasket.borderc                 C  s   d S )Nr   )r	   ÚchunkÚcursorr   r   r   r   Úread_numbytes_versionÓ   s    z#Model_TBasket.read_numbytes_versionc                 C  sÜ  t j |¡d urt jj ¡ ‚t| jt jj	j	ƒs2J ‚| 
d¡| _| |t|¡\| jd< | _| jd< | jd< | jd< | jd< | | jj| jd  tj d ¡ | |t|¡\| jd< | jd	< | jd
< | jd< | jd< | d¡ d | _| 
dd¡�sd | _d | _d | _d S | j�rè| jd
 }| jd }| jd }| ¡ }|| | | jd k�r˜| |d| jd  |¡ t¡}| d¡ |dd … | jd  | _| j | jd< nd | _| | jd ¡ d | _| j dk�rÔt!j"dt!j#d�| _n| || j |¡| _nð| jd | jd  }	| jd }
|	|
k�rXg | _t j$ %||i |	|
| j¡}t&| jƒ| _| 
d|
t j'j( )d¡|¡| _n| ¡ }| ||
|¡| _| j |
k�rÊ| jd | j … | _| j| j d …  t¡}|dd … | jd  | _| j | jd< n| j| _d | _d S )Nr
   r,   r.   ZfDatimer   ZfCycler    ZfVersionZfBufferSizeZfNevBufSizer*   r3   Zread_basketTé   é   éüÿÿÿéÿÿÿÿr   )Údtype)*r   Z_awkwardforthZget_forth_objr   ÚobjectsZCannotBeForthÚ
isinstancer   Z	behaviorsZTBranchÚgetr   ÚfieldsÚ_tbasket_format1r   r(   Úmove_toZ_cursorÚindexÚ_tbasket_format2ÚsizeÚskipr1   r   r   r   r-   Zdetach_memmapÚbytesr   ÚviewÚ_tbasket_offsets_dtyper4   ÚnumpyÚemptyZuint8ÚcompressionÚ
decompressÚtupleÚsourcer6   ZCursor)r	   r5   r6   r   ÚfileZmaybe_entry_sizer   Z
key_lengthZraw_byte_offsetsr0   r/   Zuncompressedr   r   r   Úread_membersÖ   sž    	ùÿ
ú



ÿþ


úüÿzModel_TBasket.read_members)Nr   F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r   r&   r
   r'   r)   r   r-   r/   r0   r2   r4   r7   rQ   r   r   r   r   r      s>   





"







	



r   ZTBasket)rU   Ú
__future__r   ÚstructrJ   r   ÚStructrA   rD   r<   rI   ÚmodelZModelr   Úclassesr   r   r   r   Ú<module>   s   


  2