a
    zn„fñ  ã                   @  s2   d Z ddlmZ ddlZG dd„ dejjjƒZdS )z‡
This module defines the behaviors of ``TTree``, which is almost entirely inherited from
functions in :doc:`uproot.behaviors.TBranch`.
é    )ÚannotationsNc                   @  s¤   e Zd ZdZ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edd„ ƒZdd„ ZdS )ÚTTreeaË  
    Behaviors for a ``TTree``, which mostly consist of array-reading methods.

    Since a :doc:`uproot.behaviors.TTree.TTree` is a
    :doc:`uproot.behaviors.TBranch.HasBranches`, it is also a Python
    ``Mapping``, which uses square bracket syntax to extract subbranches:

    .. code-block:: python

        my_tree["branch"]
        my_tree["branch"]["subbranch"]
        my_tree["branch/subbranch"]
        my_tree["branch/subbranch/subsubbranch"]
    c                 C  sN   t | ƒdkr&d| j›dt| ƒd›d�S d| j›dt | ƒ› dt| ƒd›d�S d S )Nr   z<TTree z at 0xZ012xú>z (z branches) at 0x)ÚlenÚnameÚid©Úself© r
   úY/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/uproot/behaviors/TTree.pyÚ__repr__   s    zTTree.__repr__c                 C  s
   |   d¡S )z(
        Name of the ``TTree``.
        ÚfName©Úmemberr   r
   r
   r   r   "   s    z
TTree.namec                 C  s
   |   d¡S )z)
        Title of the ``TTree``.
        ÚfTitler   r   r
   r
   r   Útitle)   s    zTTree.titlec                 C  s   | j jS )z/
        Object path of the ``TTree``.
        )ÚparentÚobject_pathr   r
   r
   r   r   0   s    zTTree.object_pathc                 C  s   | j j j› | j› d| j j› �S )zƒ
        String that uniquely specifies this ``TTree`` in its path, to use as
        part of object and array cache keys.
        ú;)r   Ú	cache_keyr   ZfCycler   r
   r
   r   r   7   s    zTTree.cache_keyc                 C  s
   |   d¡S )as  
        The number of entries in the ``TTree``, as reported by ``fEntries``.

        In principle, this could disagree with the
        :ref:`uproot.behaviors.TBranch.TBranch.num_entries`, which is from the
        ``TBranch``'s ``fEntries``. See that method's documentation for yet more
        ways the number of entries could, in principle, be inconsistent.
        ZfEntriesr   r   r
   r
   r   Únum_entries?   s    
zTTree.num_entriesc                 C  s   | S )z?
        Returns ``self`` because this is a ``TTree``.
        r
   r   r
   r
   r   ÚtreeK   s    z
TTree.treec                 C  s
   |   d¡S )aP  
        The number of compressed bytes in all ``TBaskets`` of all ``TBranches``
        of this ``TTree``, including all the TKey headers (which are always
        uncompressed).

        This information is specified in the ``TTree`` metadata (``fZipBytes``)
        and can be determined without reading any additional data.
        Z	fZipBytesr   r   r
   r
   r   Úcompressed_bytesR   s    
zTTree.compressed_bytesc                 C  s
   |   d¡S )a*  
        The number of uncompressed bytes in all ``TBaskets`` of all ``TBranches``
        of this ``TTree``, including all the TKey headers.

        This information is specified in the ``TTree`` metadata (``fTotBytes``)
        and can be determined without reading any additional data.
        Z	fTotBytesr   r   r
   r
   r   Úuncompressed_bytes^   s    	zTTree.uncompressed_bytesc                 C  s   t | jƒt | jƒ S )zþ
        The number of uncompressed bytes divided by the number of compressed
        bytes for this ``TTree``.

        See :ref:`uproot.behaviors.TTree.TTree.compressed_bytes` and
        :ref:`uproot.behaviors.TTree.TTree.uncompressed_bytes`.
        )Úfloatr   r   r   r
   r
   r   Úcompression_ratioi   s    	zTTree.compression_ratioc                 C  s,   | j ddd�}|du ri S dd„ |D ƒS dS )uÄ  
        The ``TTree``'s ``fAliases``, which are used as the ``aliases``
        argument to :ref:`uproot.behaviors.TBranch.HasBranches.arrays`,
        :ref:`uproot.behaviors.TBranch.HasBranches.iterate`,
        :doc:`uproot.behaviors.TBranch.iterate`, and
        :doc:`uproot.behaviors.TBranch.concatenate` if one is not given.

        The return type is always a dict of str â†’ str, even if there
        are no aliases (an empty dict).
        ZfAliasesT)Znone_if_missingNc                 S  s   i | ]}|  d ¡|  d¡“qS )r   r   r   )Ú.0Úaliasr
   r
   r   Ú
<dictcomp>„   ó    z!TTree.aliases.<locals>.<dictcomp>r   )r	   Úaliasesr
   r
   r   r    t   s    zTTree.aliasesc                 C  s   | j S )aÞ  
        The :doc:`uproot.source.chunk.Chunk` from which this ``TTree`` was
        read (as a strong, not weak, reference).

        The reason the chunk is retained is to read
        :ref:`uproot.behaviors.TBranch.TBranch.embedded_baskets` only if
        necessary (if the file was opened with
        ``options["minimal_ttree_metadata"]=True``, the reading of these
        ``TBaskets`` is deferred until they are accessed).

        Holding a strong reference to a chunk holds a strong reference to
        its :doc:`uproot.source.chunk.Source`, preventing open file handles
        from going out of scope, but so does the
        :doc:`uproot.reading.ReadOnlyFile` that ``TTree`` needs to read data
        on demand.
        )Ú_chunkr   r
   r
   r   Úchunk†   s    zTTree.chunkc                 C  s>   || _ i | _|  d¡D ]"}| d¡}|| jvr|| j|< q| S )NZ	fBranchesr   )r!   Z_lookupr   )r	   r"   ÚcursorÚcontextÚfileÚbranchr   r
   r
   r   Úpostprocessš   s    

zTTree.postprocessN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r   r   r   r   r   r   r    r"   r'   r
   r
   r
   r   r      s2   












r   )r+   Ú
__future__r   ZuprootZ	behaviorsZTBranchZHasBranchesr   r
   r
   r
   r   Ú<module>   s   