a
    zn„f³ú ã                   @  sÂ  d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	m
Z
 ddlZddlZddlZddlZddlZddlmZ e d¡ZG dd„ dƒZd<eeedejjjd	ddd
ddddddœdd„Zd=eeedejjjddd
dddddœdd„ZG dd„ dƒZdd„ ZG dd„ de	ƒZe d¡Ze d¡ZG dd„ deƒZ dd„ Z!dd„ Z"d d!„ Z#d"d#„ Z$d$d%„ Z%d&d'„ Z&d(d)„ Z'd*d+„ Z(d,d-„ Z)d.d/„ Z*d0d1„ Z+d2d3„ Z,d4d5„ Z-d6d7„ Z.d8d9„ Z/G d:d;„ d;e
ƒZ0dS )>a;  
This module defines behaviors for :doc:`uproot.behaviors.TBranch.TBranch` and
:doc:`uproot.behaviors.TBranch.HasBranches` (both ``TBranch`` and
``TTree``).

Most of the functionality of TTree-reading is implemented here.

See :doc:`uproot.models.TBranch` for deserialization of the ``TBranch``
objects themselves.
é    )ÚannotationsN)ÚIterableÚMappingÚMutableMapping)Ú	no_filterÚu1c                   @  s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )Ú_NoClosec                 C  s
   || _ d S ©N©Úhasbranches)Úselfr   © r   ú[/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/uproot/behaviors/TBranch.pyÚ__init__!   s    z_NoClose.__init__c                 C  s   | S r	   r   ©r   r   r   r   Ú	__enter__$   s    z_NoClose.__enter__c                 C  s   d S r	   r   )r   Zexception_typeZexception_valueÚ	tracebackr   r   r   Ú__exit__'   s    z_NoClose.__exit__c                 C  s   t | j|ƒS r	   )Úgetattrr   )r   Úattrr   r   r   Ú__getattr__*   s    z_NoClose.__getattr__c                 C  s
   | j | S r	   r
   ©r   Úwherer   r   r   Ú__getitem__-   s    z_NoClose.__getitem__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r       s
   r   ú100 MBÚakF)Úfilter_nameÚfilter_typenameÚfilter_branchÚaliasesÚlanguageÚ	step_sizeÚdecompression_executorÚinterpretation_executorÚlibraryÚ
ak_add_docÚhowÚreportÚcustom_classesÚallow_missingc                k  s<  t jj| fddi|¤Ž} t|	|
dƒ\}	}
t jj |¡}d}| D ]ø\}}t j |||||¡}|dur>|�¾ zp|j|||||||||	|
||||d�D ]D}|rÂ|\}}| 	||¡}| 
|¡}||fV  q�| 	||¡}|V  q�W n2 t jj�y
   |�rY W d  ƒ q>n‚ Y n0 ||j7 }W d  ƒ q>1 �s,0    Y  q>dS )u
  
    Args:
        files: See below.
        expressions (None, str, or list of str): Names of ``TBranches`` or
            aliases to convert to arrays or mathematical expressions of them.
            Uses the ``language`` to evaluate. If None, all ``TBranches``
            selected by the filters are included.
        cut (None or str): If not None, this expression filters all of the
            ``expressions``.
        filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
            filter to select ``TBranches`` by name.
        filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
            filter to select ``TBranches`` by type.
        filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
            filter to select ``TBranches`` using the full
            :doc:`uproot.behaviors.TBranch.TBranch` object. If the function
            returns False or None, the ``TBranch`` is excluded; if the function
            returns True, it is included with its standard
            :ref:`uproot.behaviors.TBranch.TBranch.interpretation`; if an
            :doc:`uproot.interpretation.Interpretation`, this interpretation
            overrules the standard one.
        aliases (None or dict of str â†’ str): Mathematical expressions that
            can be used in ``expressions`` or other aliases (without cycles).
            Uses the ``language`` engine to evaluate. If None, only the
            :ref:`uproot.behaviors.TBranch.TBranch.aliases` are available.
        language (:doc:`uproot.language.Language`): Language used to interpret
            the ``expressions`` and ``aliases``.
        step_size (int or str): If an integer, the maximum number of entries to
            include in each iteration step; if a string, the maximum memory size
            to include. The string must be a number followed by a memory unit,
            such as "100 MB".
        decompression_executor (None or Executor with a ``submit`` method): The
            executor that is used to decompress ``TBaskets``; if None, a
            :doc:`uproot.source.futures.TrivialExecutor` is created.
        interpretation_executor (None or Executor with a ``submit`` method): The
            executor that is used to interpret uncompressed ``TBasket`` data as
            arrays; if None, a :doc:`uproot.source.futures.TrivialExecutor`
            is created.
        library (str or :doc:`uproot.interpretation.library.Library`): The library
            that is used to represent arrays. Options are ``"np"`` for NumPy,
            ``"ak"`` for Awkward Array, and ``"pd"`` for Pandas.
        ak_add_doc (bool): If True and ``library="ak"``, add the TBranch ``title``
            to the Awkward ``__doc__`` parameter of the array.
        how (None, str, or container type): Library-dependent instructions
            for grouping. The only recognized container types are ``tuple``,
            ``list``, and ``dict``. Note that the container *type itself*
            must be passed as ``how``, not an instance of that type (i.e.
            ``how=tuple``, not ``how=()``).
        report (bool): If True, this generator yields
            (arrays, :doc:`uproot.behaviors.TBranch.Report`) pairs; if False,
            it only yields arrays. The report has data about the ``TFile``,
            ``TTree``, and global and local entry ranges.
        custom_classes (None or dict): If a dict, override the classes from
            the :doc:`uproot.reading.ReadOnlyFile` or ``uproot.classes``.
        allow_missing (bool): If True, skip over any files that do not contain
            the specified ``TTree``.
        options: See below.

    Iterates through contiguous chunks of entries from a set of files.

    For example:

    .. code-block:: python

        >>> for array in uproot.iterate("files*.root:tree", ["x", "y"], step_size=100):
        ...     # each of the following have 100 entries
        ...     array["x"], array["y"]

    Allowed types for the ``files`` parameter:

    * str/bytes: relative or absolute filesystem path or URL, without any colons
      other than Windows drive letter or URL schema.
      Examples: ``"rel/file.root"``, ``"C:\abs\file.root"``, ``"http://where/what.root"``
    * str/bytes: same with an object-within-ROOT path, separated by a colon.
      Example: ``"rel/file.root:tdirectory/ttree"``
    * pathlib.Path: always interpreted as a filesystem path or URL only (no
      object-within-ROOT path), regardless of whether there are any colons.
      Examples: ``Path("rel:/file.root")``, ``Path("/abs/path:stuff.root")``
    * glob syntax in str/bytes and pathlib.Path.
      Examples: ``Path("rel/*.root")``, ``"/abs/*.root:tdirectory/ttree"``
    * dict: keys are filesystem paths, values are objects-within-ROOT paths.
      Example: ``{{"/data_v1/*.root": "ttree_v1", "/data_v2/*.root": "ttree_v2"}}``
    * already-open TTree objects.
    * iterables of the above.

    Options (type; default):

    * handler (:doc:`uproot.source.chunk.Source` class; None)
    * timeout (float for HTTP, int for XRootD; 30)
    * max_num_elements (None or int; None)
    * num_workers (int; 1)
    * use_threads (bool; False on the emscripten platform (i.e. in a web browser), else True)
    * num_fallback_workers (int; 10)
    * begin_chunk_size (memory_size; 403, the smallest a ROOT file can be)
    * minimal_ttree_metadata (bool; True)

    See also :ref:`uproot.behaviors.TBranch.HasBranches.iterate` to iterate
    within a single file.

    Other file entry points:

    * :doc:`uproot.reading.open`: opens one file to read any of its objects.
    * :doc:`uproot.behaviors.TBranch.iterate` (this function): iterates through
      chunks of contiguous entries in ``TTrees``.
    * :doc:`uproot.behaviors.TBranch.concatenate`: returns a single concatenated
      array from ``TTrees``.
    * :doc:`uproot._dask.dask`: returns an unevaluated Dask array from ``TTrees``.
    Ústeps_allowedFNr   )ÚexpressionsÚcutr   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   )ÚuprootÚ_utilÚregularize_filesÚ_regularize_executorsÚinterpretationr'   Ú_regularize_libraryÚregularize_object_pathÚiterateÚglobal_indexÚ	to_globalÚ
exceptionsÚKeyInFileErrorÚnum_entries)Úfilesr.   r/   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   ÚoptionsÚglobal_offsetÚ	file_pathÚobject_pathr   ÚitemÚarraysr   r   r   r7   1   sT     ÿ
ÿò

r7   )r   r    r!   r"   r#   r%   r&   r'   r(   r)   r+   r,   c                K  s  t jj| fddi|¤Ž} t||	dƒ\}}	t jj |
¡}
g }d}| D ]À\}}t j |||||¡}|durB|�ˆ z4|j|||||||||	d|
||d�}|
 	||¡}W n. t j
jyÎ   |rÈY W d  ƒ qBn‚ Y n0 | |¡ ||j7 }W d  ƒ qB1 sø0    Y  qB|
 |¡S )uÍ  
    Args:
        files: See below.
        expressions (None, str, or list of str): Names of ``TBranches`` or
            aliases to convert to arrays or mathematical expressions of them.
            Uses the ``language`` to evaluate. If None, all ``TBranches``
            selected by the filters are included.
        cut (None or str): If not None, this expression filters all of the
            ``expressions``.
        filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
            filter to select ``TBranches`` by name.
        filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
            filter to select ``TBranches`` by type.
        filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
            filter to select ``TBranches`` using the full
            :doc:`uproot.behaviors.TBranch.TBranch` object. If the function
            returns False or None, the ``TBranch`` is excluded; if the function
            returns True, it is included with its standard
            :ref:`uproot.behaviors.TBranch.TBranch.interpretation`; if an
            :doc:`uproot.interpretation.Interpretation`, this interpretation
            overrules the standard one.
        aliases (None or dict of str â†’ str): Mathematical expressions that
            can be used in ``expressions`` or other aliases (without cycles).
            Uses the ``language`` engine to evaluate. If None, only the
            :ref:`uproot.behaviors.TBranch.TBranch.aliases` are available.
        language (:doc:`uproot.language.Language`): Language used to interpret
            the ``expressions`` and ``aliases``.
        decompression_executor (None or Executor with a ``submit`` method): The
            executor that is used to decompress ``TBaskets``; if None, a
            :doc:`uproot.source.futures.TrivialExecutor` is created.
        interpretation_executor (None or Executor with a ``submit`` method): The
            executor that is used to interpret uncompressed ``TBasket`` data as
            arrays; if None, a :doc:`uproot.source.futures.TrivialExecutor`
            is created.
        library (str or :doc:`uproot.interpretation.library.Library`): The library
            that is used to represent arrays. Options are ``"np"`` for NumPy,
            ``"ak"`` for Awkward Array, and ``"pd"`` for Pandas.
        ak_add_doc (bool): If True and ``library="ak"``, add the TBranch ``title``
            to the Awkward ``__doc__`` parameter of the array.
        how (None, str, or container type): Library-dependent instructions
            for grouping. The only recognized container types are ``tuple``,
            ``list``, and ``dict``. Note that the container *type itself*
            must be passed as ``how``, not an instance of that type (i.e.
            ``how=tuple``, not ``how=()``).
        custom_classes (None or dict): If a dict, override the classes from
            the :doc:`uproot.reading.ReadOnlyFile` or ``uproot.classes``.
        allow_missing (bool): If True, skip over any files that do not contain
            the specified ``TTree``.
        options: See below.

    Returns an array with data from a set of files concatenated into one.

    For example:

    .. code-block:: python

        >>> array = uproot.concatenate("files*.root:tree", ["x", "y"])

    Depending on the number of files, the number of selected ``TBranches``, and
    the size of your computer's memory, this function might not have enough
    memory to run.

    Allowed types for the ``files`` parameter:

    * str/bytes: relative or absolute filesystem path or URL, without any colons
      other than Windows drive letter or URL schema.
      Examples: ``"rel/file.root"``, ``"C:\abs\file.root"``, ``"http://where/what.root"``
    * str/bytes: same with an object-within-ROOT path, separated by a colon.
      Example: ``"rel/file.root:tdirectory/ttree"``
    * pathlib.Path: always interpreted as a filesystem path or URL only (no
      object-within-ROOT path), regardless of whether there are any colons.
      Examples: ``Path("rel:/file.root")``, ``Path("/abs/path:stuff.root")``
    * glob syntax in str/bytes and pathlib.Path.
      Examples: ``Path("rel/*.root")``, ``"/abs/*.root:tdirectory/ttree"``
    * dict: keys are filesystem paths, values are objects-within-ROOT paths.
      Example: ``{{"/data_v1/*.root": "ttree_v1", "/data_v2/*.root": "ttree_v2"}}``
    * already-open TTree objects.
    * iterables of the above.

    Options (type; default):

    * handler (:doc:`uproot.source.chunk.Source` class; None)
    * timeout (float for HTTP, int for XRootD; 30)
    * max_num_elements (None or int; None)
    * num_workers (int; 1)
    * use_threads (bool; False on the emscripten platform (i.e. in a web browser), else True)
    * num_fallback_workers (int; 10)
    * begin_chunk_size (memory_size; 403, the smallest a ROOT file can be)
    * minimal_ttree_metadata (bool; True)

    Other file entry points:

    * :doc:`uproot.reading.open`: opens one file to read any of its objects.
    * :doc:`uproot.behaviors.TBranch.iterate`: iterates through chunks of
      contiguous entries in ``TTrees``.
    * :doc:`uproot.behaviors.TBranch.concatenate` (this function): returns a
      single concatenated array from ``TTrees``.
    * :doc:`uproot._dask.dask`: returns an unevaluated Dask array from ``TTrees``.
    r-   FNr   )r.   r/   r   r    r!   r"   r#   r%   r&   Úarray_cacher'   r(   r)   )r0   r1   r2   r3   r4   r'   r5   r6   rC   r8   r:   r;   Úappendr<   Úconcatenate)r=   r.   r/   r   r    r!   r"   r#   r%   r&   r'   r(   r)   r+   r,   r>   Z
all_arraysZglobal_startr@   rA   r   rC   r   r   r   rF   â   sJ    vÿ
ÿó
*rF   c                   @  s®   e Zd ZdZd d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 )!ÚReportaK  
    Args:
        source (:doc:`uproot.behaviors.TBranch.HasBranches`): The
            object (:doc:`uproot.behaviors.TBranch.TBranch` or
            :doc:`uproot.behaviors.TTree.TTree`) that this batch of data
            came from.
        tree_entry_start (int): First entry in the batch, counting zero at
            the start of the current ``TTree`` (current file).
        tree_entry_stop (int): First entry *after* the batch (last entry plus
            one), counting zero at the start of the ``TTree`` (current file).
        global_offset (int): Number of entries between the start of iteration
            and the start of this ``TTree``. The
            :ref:`uproot.behaviors.TBranch.Report.global_entry_start` and
            :ref:`uproot.behaviors.TBranch.Report.global_entry_stop` are
            equal to :ref:`uproot.behaviors.TBranch.Report.tree_entry_start`
            and :ref:`uproot.behaviors.TBranch.Report.tree_entry_stop` plus
            ``global_offset``.

    Information about the current iteration of
    :ref:`uproot.behaviors.TBranch.HasBranches.iterate` (the method) or
    :doc:`uproot.behaviors.TBranch.iterate` (the function).

    Since the :ref:`uproot.behaviors.TBranch.HasBranches.iterate` method
    only iterates over data from one ``TTree``, its ``global_offset`` is always
    zero; :ref:`uproot.behaviors.TBranch.Report.global_entry_start` and
    :ref:`uproot.behaviors.TBranch.Report.global_entry_stop` are equal to
    :ref:`uproot.behaviors.TBranch.Report.tree_entry_start` and
    :ref:`uproot.behaviors.TBranch.Report.tree_entry_stop`, respectively.

    r   c                 C  s   || _ || _|| _|| _d S r	   )Ú_sourceÚ_tree_entry_startÚ_tree_entry_stopÚ_global_offset)r   ÚsourceÚtree_entry_startÚtree_entry_stopr?   r   r   r   r   £  s    zReport.__init__c                 C  s(   d  | j| jt| jjjd | jj ƒ¡S )Nz#<Report start={} stop={} source={}>ú:)ÚformatÚglobal_entry_startÚglobal_entry_stopÚreprrH   Úfiler@   rA   r   r   r   r   Ú__repr__©  s
    ýzReport.__repr__c                 C  s   | j S )z 
        The object (:doc:`uproot.behaviors.TBranch.TBranch` or
        :doc:`uproot.behaviors.TTree.TTree`) that this batch of data
        came from.
        )rH   r   r   r   r   rL   °  s    zReport.sourcec                 C  s   | j jS )zd
        The :doc:`uproot.behaviors.TTree.TTree` that this batch of data
        came from.
        )rH   Útreer   r   r   r   rV   ¹  s    zReport.treec                 C  s   | j jS )zc
        The :doc:`uproot.reading.ReadOnlyFile` that this batch of data
        came from.
        )rH   rT   r   r   r   r   rT   Á  s    zReport.filec                 C  s
   | j jjS )zt
        The path/name of the :doc:`uproot.reading.ReadOnlyFile` that
        this batch of data came from.
        )rH   rT   r@   r   r   r   r   r@   É  s    zReport.file_pathc                 C  s   | j S )zw
        First entry in the batch, counting zero at the start of the current
        ``TTree`` (current file).
        )rI   r   r   r   r   rM   Ñ  s    zReport.tree_entry_startc                 C  s   | j S )zŠ
        First entry *after* the batch (last entry plus one), counting zero at
        the start of the ``TTree`` (current file).
        )rJ   r   r   r   r   rN   Ù  s    zReport.tree_entry_stopc                 C  s   | j | j S )zz
        First entry in the batch, counting zero at the start of iteration
        (potentially over many files).
        ©rI   rK   r   r   r   r   rQ   á  s    zReport.global_entry_startc                 C  s   | j | j S )z–
        First entry *after* the batch (last entry plust one), counting zero at
        the start of iteration (potentially over many files).
        ©rJ   rK   r   r   r   r   rR   é  s    zReport.global_entry_stopc                 C  s   | j | j S )zb
        A synonym for
        :ref:`uproot.behaviors.TBranch.Report.global_entry_start`.
        rW   r   r   r   r   Ústartñ  s    zReport.startc                 C  s   | j | j S )za
        A synonym for
        :ref:`uproot.behaviors.TBranch.Report.global_entry_stop`.
        rX   r   r   r   r   Ústopù  s    zReport.stopc                 C  s   | j S )a¦  
        Number of entries between the start of iteration and the start of this
        ``TTree``. The
        :ref:`uproot.behaviors.TBranch.Report.global_entry_start` and
        :ref:`uproot.behaviors.TBranch.Report.global_entry_stop` are
        equal to :ref:`uproot.behaviors.TBranch.Report.tree_entry_start`
        and :ref:`uproot.behaviors.TBranch.Report.tree_entry_stop` plus
        ``global_offset``.
        )rK   r   r   r   r   r?     s    zReport.global_offsetc                 C  s   t | j| j| j|ƒS )z¬
        Copies the data in this :doc:`uproot.behaviors.TBranch.Report` to
        another with a new
        :ref:`uproot.behaviors.TBranch.Report.global_offset`.
        )rG   rH   rI   rJ   )r   r?   r   r   r   r9     s    ÿzReport.to_globalN)r   )r   r   r   Ú__doc__r   rU   ÚpropertyrL   rV   rT   r@   rM   rN   rQ   rR   rY   rZ   r?   r9   r   r   r   r   rG   ƒ  s4   











rG   c                 C  s$   |r t | ƒjdkr |j| jjd< | S )Nzawkward.highlevelr[   )Útyper   ÚtitleZlayoutÚ
parameters)Úarrayr   r(   r   r   r   Ú_ak_add_doc  s    ra   c                   @  s´  e Zd ZdZedd„ ƒZeeedddddejdœ	d	d
„Z	d:eeede
jjjdddddddddœdd„Zd;eeede
jjjddddddddddœdd„Zeeeddddœdd„Zeeeddœdd„Zeeedddœdd„Zeeedddœdd „Zeeeddddœd!d"„Zeeeddœd#d$„Zeeeddddœd%d&„Zeeedddœd'd(„Zd)d*„ Zd<eeede
jjjddd+œd,d-„Zeeeddœd.d/„Zd0d1„ Zd2d3„ Zd4d5„ Zed6d7œd8d9„ƒZdS )=ÚHasBranchesa  
    Abstract class of behaviors for anything that "has branches," namely
    :doc:`uproot.behaviors.TTree.TTree` and
    :doc:`uproot.behaviors.TBranch.TBranch`, which mostly consist of array-reading
    methods.

    A :doc:`uproot.behaviors.TBranch.HasBranches` is 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  s
   |   d¡S )zÎ
        The list of :doc:`uproot.behaviors.TBranch.TBranch` directly under
        this :doc:`uproot.behaviors.TTree.TTree` or
        :doc:`uproot.behaviors.TBranch.TBranch` (i.e. not recursive).
        Ú	fBranches©Úmemberr   r   r   r   Úbranches1  s    zHasBranches.branchesTé   é   é   )	r   r    r!   Ú	recursiveÚ
full_pathsÚ
name_widthÚtypename_widthÚinterpretation_widthÚstreamc       	         C  s~  |dk rt dƒ‚|dk r t dƒ‚|dk r0t dƒ‚d|› d|› d|› d|› d|› d|› d	�}
|	 |
 d
dd¡¡ |	 dd|  d d|  d d|  d ¡ t| tƒrÈ|	 |
 | j| jt| jƒ¡d ¡ | j	|||||d�D ]œ\}}|j}t|jƒ}t
|ƒ|k�r|d|d … d }t
|ƒ|k�r8|d|d … d }t
|ƒ|k�rZ|d|d … d }|	 |
 |||¡ d¡d ¡ qÜdS )ut	  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, recursively descend into the branches'
                branches.
            full_paths (bool): If True, include the full path to each subbranch
                with slashes (``/``); otherwise, use the descendant's name as
                the display name.
            name_width (int): Number of characters to reserve for the ``TBranch``
                names.
            typename_width (int): Number of characters to reserve for the C++
                typenames.
            interpretation_width (int): Number of characters to reserve for the
                :doc:`uproot.interpretation.Interpretation` displays.
            stream (object with a ``write(str)`` method): Stream to write the
                output to.

        Interactively display the ``TBranches``.

        For example,

        .. code-block::

            name                 | typename             | interpretation
            ---------------------+----------------------+-----------------------------------
            event_number         | int32_t              | AsDtype('>i4')
            trigger_isomu24      | bool                 | AsDtype('bool')
            eventweight          | float                | AsDtype('>f4')
            MET                  | TVector2             | AsStridedObjects(Model_TVector2_v3
            jetp4                | std::vector<TLorentz | AsJagged(AsStridedObjects(Model_TL
            jetbtag              | std::vector<float>   | AsJagged(AsDtype('>f4'), header_by
            jetid                | std::vector<bool>    | AsJagged(AsDtype('bool'), header_b
        é   z'name_width' must be at least 3z#'typename_width' must be at least 3z)'interpretation_width' must be at least 3z{0:Ú.z} | {1:z} | {2:Ú}ÚnameÚtypenamer4   Ú
ú-z-+-©r   r    r!   rj   rk   Nz...ú )Ú
ValueErrorÚwriterP   Ú
isinstanceÚTBranchrs   rt   rS   r4   Ú	iteritemsÚlenÚrstrip)r   r   r    r!   rj   rk   rl   rm   rn   ro   Ú	formatterrs   Úbranchrt   Úinterpr   r   r   Úshow:  s\    5*ÿþýüûúÿ

ÿÿû
ÿzHasBranches.showNÚinheritr   F)r   r    r!   r"   r#   Úentry_startÚ
entry_stopr%   r&   rD   r'   r(   r)   c          !        sZ  t ˆƒ}tˆtƒrd|du rdt|ƒdkrdtj ˆ¡‰ˆjj||||‡‡fdd„||ˆˆ|
|ˆ ˆ|d�S t	ˆj
jˆˆƒ\‰‰t|
|ˆjƒ\}
}tˆ ˆjƒ‰ tjj ˆ¡‰‡ ‡‡‡‡fdd„}tˆ|ƒ}tˆ||||ˆ||||ƒ
\}}}g }tƒ }|D ]X\}}|d D ]F}|j|v�r | |j¡ | ˆˆ¡D ]\}}| |||f¡ �q(�q qðd	|i}tˆ||ˆˆ|
|ˆ|d
|ƒ ~t|||ˆ||ƒ ˆ du�rtƒ }|D ]€\}}|d D ]l}|j|v�r¦| |j¡ ||j }|du�rˆj› d|› d|j› dˆ› dˆ› dˆj› �}||j ˆ |< �q¦�q–| ˆ||||ˆjjˆj¡} ~dd„ |D ƒ}t ˆ !| ||¡ˆ|ƒS )u®  
        Args:
            expressions (None, str, or list of str): Names of ``TBranches`` or
                aliases to convert to arrays or mathematical expressions of them.
                Uses the ``language`` to evaluate. If None, all ``TBranches``
                selected by the filters are included.
            cut (None or str): If not None, this expression filters all of the
                ``expressions``.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. If the function
                returns False or None, the ``TBranch`` is excluded; if the function
                returns True, it is included with its standard
                :ref:`uproot.behaviors.TBranch.TBranch.interpretation`; if an
                :doc:`uproot.interpretation.Interpretation`, this interpretation
                overrules the standard one.
            aliases (None or dict of str â†’ str): Mathematical expressions that
                can be used in ``expressions`` or other aliases (without cycles).
                Uses the ``language`` engine to evaluate. If None, only the
                :ref:`uproot.behaviors.TBranch.TBranch.aliases` are available.
            language (:doc:`uproot.language.Language`): Language used to interpret
                the ``expressions`` and ``aliases``.
            entry_start (None or int): The first entry to include. If None, start
                at zero. If negative, count from the end, like a Python slice.
            entry_stop (None or int): The first entry to exclude (i.e. one greater
                than the last entry to include). If None, stop at
                :ref:`uproot.behaviors.TTree.TTree.num_entries`. If negative,
                count from the end, like a Python slice.
            decompression_executor (None or Executor with a ``submit`` method): The
                executor that is used to decompress ``TBaskets``; if None, the
                file's :ref:`uproot.reading.ReadOnlyFile.decompression_executor`
                is used.
            interpretation_executor (None or Executor with a ``submit`` method): The
                executor that is used to interpret uncompressed ``TBasket`` data as
                arrays; if None, the file's :ref:`uproot.reading.ReadOnlyFile.interpretation_executor`
                is used.
            array_cache ("inherit", None, MutableMapping, or memory size): Cache of arrays;
                if "inherit", use the file's cache; if None, do not use a cache;
                if a memory size, create a new cache of this size.
            library (str or :doc:`uproot.interpretation.library.Library`): The library
                that is used to represent arrays. Options are ``"np"`` for NumPy,
                ``"ak"`` for Awkward Array, and ``"pd"`` for Pandas.
            ak_add_doc (bool): If True and ``library="ak"``, add the TBranch ``title``
                to the Awkward ``__doc__`` parameter of the array.
            how (None, str, or container type): Library-dependent instructions
                for grouping. The only recognized container types are ``tuple``,
                ``list``, and ``dict``. Note that the container *type itself*
                must be passed as ``how``, not an instance of that type (i.e.
                ``how=tuple``, not ``how=()``).

        Returns a group of arrays from the ``TTree``.

        For example:

        .. code-block:: python

            >>> my_tree["x"].array()
            <Array [-41.2, 35.1, 35.1, ... 32.4, 32.5] type='2304 * float64'>
            >>> my_tree["y"].array()
            <Array [17.4, -16.6, -16.6, ... 1.2, 1.2, 1.2] type='2304 * float64'>

        See also :ref:`uproot.behaviors.TBranch.TBranch.array` to read a single
        ``TBranch`` as an array.

        See also :ref:`uproot.behaviors.TBranch.HasBranches.iterate` to iterate over
        the array in contiguous ranges of entries.
        Nr   c                   s   | ˆu oˆ | ƒS r	   r   ©r�   ©r!   r   r   r   Ú<lambda>   ó    z$HasBranches.arrays.<locals>.<lambda>)r.   r/   r   r    r!   r"   r#   r…   r†   r%   r&   rD   r'   r)   c                   sF   ˆ d ur>ˆj › d| › d|j › dˆ› dˆ› dˆj› �}ˆ  |¡S d S d S ©NrO   rv   ©Ú	cache_keyrs   Úget©Ú
branchnamer4   r�   ©rD   r…   r†   r'   r   r   r   Úget_from_cache  s    ,
z*HasBranches.arrays.<locals>.get_from_cacherf   r(   FrO   rv   c                 S  s(   g | ] \}}|d  r|d s||f‘qS ©Ú
is_primaryÚis_cutr   ©Ú.0ÚeÚcr   r   r   Ú
<listcomp>i  s   z&HasBranches.arrays.<locals>.<listcomp>)"Ú
_keys_deepr{   r|   r~   r0   r1   Úregularize_filterÚparentrC   Ú_regularize_entries_start_stoprV   r<   r3   Ú_fileÚ_regularize_array_cacher4   r'   r5   Ú_regularize_aliasesÚ_regularize_expressionsÚsetr�   ÚaddÚentries_to_ranges_or_basketsrE   Ú_ranges_or_baskets_to_arraysÚ_fix_asgroupedrs   Úcompute_expressionsrT   r@   rA   ra   Úgroup)!r   r.   r/   r   r    r!   r"   r#   r…   r†   r%   r&   rD   r'   r(   r)   Úkeysr’   rC   Úexpression_contextÚbranchid_interpretationÚranges_or_basketsÚcheckedÚ_Úcontextr�   Ú
basket_numÚrange_or_basketÚinterp_optionsÚ
expressionr4   r�   Úoutputr   )rD   r…   r†   r!   r'   r   r   rC   ž  sÊ    Zò
ÿÿ
ö

ýõú	


,ùÿÿzHasBranches.arraysr   )r   r    r!   r"   r#   r…   r†   r$   r%   r&   r'   r(   r)   r*   c          )      #  sŠ  t ˆƒ}tˆtƒrp|du rpt|ƒdkrptj ˆ ¡‰ ˆjj||||‡ ‡fdd„||||	|
|||||d�E dH  �nt	ˆj
j||	ƒ\}}	t||ˆjƒ\}}tjj |¡}tˆ|ƒ}tˆ||||ˆ |||dd„ ƒ
\}}}tˆ|
||	|ƒ}i }t||	|ƒD �]�}t|| |	ƒ}|| dk�rqòg }tƒ }|D ]†\}}|d D ]r}|j|v�r4| |j¡ | ||¡D ]F\}}| |j|f¡} | du �r�| |||f¡ n| ||| f¡ �q\�q4�q$i }d|i}!tˆ||||||||d	|!ƒ t||||||ƒ | ˆ||||ˆjj ˆj!¡}"~d
d„ |D ƒ}#t"| #|"|#|¡ˆ|ƒ}$i }%|D ].\}}}&|&j$\}'}(|(|k�r0|&|%|j|f< �q0|%}|�r~|$t%ˆ||ƒfV  qò|$V  qòdS )u¶  
        Args:
            expressions (None, str, or list of str): Names of ``TBranches`` or
                aliases to convert to arrays or mathematical expressions of them.
                Uses the ``language`` to evaluate. If None, all ``TBranches``
                selected by the filters are included.
            cut (None or str): If not None, this expression filters all of the
                ``expressions``.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. If the function
                returns False or None, the ``TBranch`` is excluded; if the function
                returns True, it is included with its standard
                :ref:`uproot.behaviors.TBranch.TBranch.interpretation`; if an
                :doc:`uproot.interpretation.Interpretation`, this interpretation
                overrules the standard one.
            aliases (None or dict of str â†’ str): Mathematical expressions that
                can be used in ``expressions`` or other aliases (without cycles).
                Uses the ``language`` engine to evaluate. If None, only the
                :ref:`uproot.behaviors.TBranch.TBranch.aliases` are available.
            language (:doc:`uproot.language.Language`): Language used to interpret
                the ``expressions`` and ``aliases``.
            entry_start (None or int): The first entry to include. If None, start
                at zero. If negative, count from the end, like a Python slice.
            entry_stop (None or int): The first entry to exclude (i.e. one greater
                than the last entry to include). If None, stop at
                :ref:`uproot.behaviors.TTree.TTree.num_entries`. If negative,
                count from the end, like a Python slice.
            step_size (int or str): If an integer, the maximum number of entries to
                include in each iteration step; if a string, the maximum memory size
                to include. The string must be a number followed by a memory unit,
                such as "100 MB".
            decompression_executor (None or Executor with a ``submit`` method): The
                executor that is used to decompress ``TBaskets``; if None, the
                file's :ref:`uproot.reading.ReadOnlyFile.decompression_executor`
                is used.
            interpretation_executor (None or Executor with a ``submit`` method): The
                executor that is used to interpret uncompressed ``TBasket`` data as
                arrays; if None, the file's :ref:`uproot.reading.ReadOnlyFile.interpretation_executor`
                is used.
            library (str or :doc:`uproot.interpretation.library.Library`): The library
                that is used to represent arrays. Options are ``"np"`` for NumPy,
                ``"ak"`` for Awkward Array, and ``"pd"`` for Pandas.
            ak_add_doc (bool): If True and ``library="ak"``, add the TBranch ``title``
                to the Awkward ``__doc__`` parameter of the array.
            how (None, str, or container type): Library-dependent instructions
                for grouping. The only recognized container types are ``tuple``,
                ``list``, and ``dict``. Note that the container *type itself*
                must be passed as ``how``, not an instance of that type (i.e.
                ``how=tuple``, not ``how=()``).
            report (bool): If True, this generator yields
                (arrays, :doc:`uproot.behaviors.TBranch.Report`) pairs; if False,
                it only yields arrays. The report has data about the ``TFile``,
                ``TTree``, and global and local entry ranges.

        Iterates through contiguous chunks of entries from the ``TTree``.

        For example:

        .. code-block:: python

            >>> for array in tree.iterate(["x", "y"], step_size=100):
            ...     # each of the following have 100 entries
            ...     array["x"], array["y"]

        See also :ref:`uproot.behaviors.TBranch.HasBranches.arrays` to read
        everything in a single step, without iteration.

        See also :doc:`uproot.behaviors.TBranch.iterate` to iterate over many
        files.
        Nr   c                   s   | ˆu oˆ | ƒS r	   r   r‡   rˆ   r   r   r‰   Ø  rŠ   z%HasBranches.iterate.<locals>.<lambda>)r.   r/   r   r    r!   r"   r#   r…   r†   r$   r%   r&   r'   r)   r*   c                 S  s   d S r	   r   ©r�   r4   r   r   r   r‰   ý  rŠ   rf   r(   Tc                 S  s(   g | ] \}}|d  r|d s||f‘qS r“   r   r–   r   r   r   rš   H  s   þz'HasBranches.iterate.<locals>.<listcomp>)&r›   r{   r|   r~   r0   r1   rœ   r�   r7   rž   rV   r<   r3   rŸ   r4   r'   r5   r¡   r¢   Ú_regularize_step_sizeÚrangeÚminr£   r�   r¤   r¥   rŽ   rE   r¦   r§   r¨   rT   r@   rA   ra   r©   Zentry_start_stoprG   ))r   r.   r/   r   r    r!   r"   r#   r…   r†   r$   r%   r&   r'   r(   r)   r*   rª   rC   r«   r¬   Z
entry_stepZprevious_basketsZsub_entry_startZsub_entry_stopr­   r®   r¯   r°   r�   r±   r²   Zprevious_basketr³   rµ   Zminimized_expression_contextÚoutZnext_basketsÚbasketZbasket_entry_startZbasket_entry_stopr   rˆ   r   r7   q  sø    _ñ
ÿÿ
öü
ÿÿýÿ
ÿÿõú	ùþý

zHasBranches.iterate©r   r    r!   rj   rk   Úignore_duplicatesc             	   C  s   t | j||||||d�ƒS )uW  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only return the names of branches directly accessible
                under this object.
            full_paths (bool): If True, include the full path to each subbranch
                with slashes (``/``); otherwise, use the descendant's name as
                the output name.
            ignore_duplicates (bool): If True, return a set of the keys; otherwise, return the full list of keys.

        Returns the names of the subbranches as a list of strings.
        r¼   )ÚlistÚiterkeys)r   r   r    r!   rj   rk   r½   r   r   r   rª   a  s    úÿzHasBranches.keys©r   r    r!   rj   c                C  s   t | j||||d�ƒS )uº  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only return branches that are directly accessible
                under this object.

        Returns the subbranches as a list of
        :doc:`uproot.behaviors.TBranch.TBranch`.

        (Note: with ``recursive=False``, this is the same as
        :ref:`uproot.behaviors.TBranch.HasBranches.branches`.)
        rÀ   )r¾   Ú
itervalues)r   r   r    r!   rj   r   r   r   ÚvaluesŠ  s    üÿzHasBranches.valuesrw   c                C  s   t | j|||||d�ƒS )uQ  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only return (name, branch) pairs for branches
                directly accessible under this object.
            full_paths (bool): If True, include the full path to each subbranch
                with slashes (``/``) in the name; otherwise, use the descendant's
                name as the name without modification.

        Returns (name, branch) pairs of the subbranches as a list of 2-tuples
        of (str, :doc:`uproot.behaviors.TBranch.TBranch`).
        rw   )r¾   r}   ©r   r   r    r!   rj   rk   r   r   r   Úitems¯  s    ûÿzHasBranches.itemsc                C  s   t | j|||||d�ƒS )u&  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only return (name, typename) pairs for branches
                directly accessible under this object.
            full_paths (bool): If True, include the full path to each subbranch
                with slashes (``/``) in the name; otherwise, use the descendant's
                name as the name without modification.

        Returns (name, typename) pairs of the subbranches as a dict of
        str â†’ str.
        rw   )ÚdictÚitertypenamesrÃ   r   r   r   Ú	typenamesÖ  s    ûÿzHasBranches.typenamesc          	      c  s*   | j ||||||d�D ]\}}|V  qdS )u_  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only return the names of branches directly accessible
                under this object.
            full_paths (bool): If True, include the full path to each subbranch
                with slashes (``/``); otherwise, use the descendant's name as
                the output name.
            ignore_duplicates (bool): If True, return a set of the keys; otherwise, return the full list of keys.


        Returns the names of the subbranches as an iterator over strings.
        r¼   N©r}   )	r   r   r    r!   rj   rk   r½   Úkr¯   r   r   r   r¿   ý  s    úzHasBranches.iterkeysc                c  s(   | j ||||dd�D ]\}}|V  qdS )uÁ  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only return branches that are directly accessible
                under this object.

        Returns the subbranches as an iterator over
        :doc:`uproot.behaviors.TBranch.TBranch`.

        (Note: with ``recursive=False``, this is the same as
        :ref:`uproot.behaviors.TBranch.HasBranches.branches`.)
        Frw   NrÈ   )r   r   r    r!   rj   r¯   Úvr   r   r   rÁ   &  s    ûzHasBranches.itervaluesc                c  s&  t j |¡}t j |¡}|du r&t}nt|ƒr0ntd|›�ƒ‚tƒ }| jD ]Ö}|tu sbt|| |ƒr¬|tu st||j	ƒr¬|tu s„||ƒr¬|r”|j
|v r”n| |j
¡ |j
|fV  |rJ|j|t|||d�D ]Z\}	}
|rà|j
› d|	› �n|	}|tu søt|| |
ƒrÄ|�r
||v �r
qÄ| |¡ ||
fV  qÄqJdS )uË  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only return (name, branch) pairs for branches
                directly accessible under this object.
            full_paths (bool): If True, include the full path to each subbranch
                with slashes (``/``) in the name; otherwise, use the descendant's
                name as the name without modification.
            ignore_duplicates (bool): If True, return a set of the keys; otherwise, return the full list of keys.


        Returns (name, branch) pairs of the subbranches as an iterator over
        2-tuples of (str, :doc:`uproot.behaviors.TBranch.TBranch`).
        Nz?filter_branch must be None or a function: TBranch -> bool, not )rj   r   r    r!   rk   ú/)r0   r1   rœ   r   ÚcallableÚ	TypeErrorr£   rf   Ú_filter_name_deeprt   rs   r¤   r}   )r   r   r    r!   rj   rk   r½   Zkeys_setr�   Zk1rÊ   Zk2r   r   r   r}   K  sV     ÿ
þ
ýûûúúû
ÿ
zHasBranches.iteritemsc                c  s.   | j |||||d�D ]\}}||jfV  qdS )u8  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only return (name, typename) pairs for branches
                directly accessible under this object.
            full_paths (bool): If True, include the full path to each subbranch
                with slashes (``/``) in the name; otherwise, use the descendant's
                name as the name without modification.

        Returns (name, typename) pairs of the subbranches as an iterator over
        2-tuples of (str, str).
        rw   N)r}   rt   )r   r   r    r!   rj   rk   rÉ   rÊ   r   r   r   rÆ   ™  s    ûzHasBranches.itertypenamesc                 C  s   |   ¡ S )zJ
        Supports key-completion in an IPython or Jupyter kernel.
        )r¿   r   r   r   r   Ú_ipython_key_completions_¿  s    z%HasBranches._ipython_key_completions_)r   r    r!   r"   r#   r…   r†   c                C  sf   t j |¡}t| jj|	|
ƒ\}	}
t| ƒ}t| |ƒ}t| ||||||||dd„ ƒ
\}}}t	| ||	|
|ƒS )uR  
        Args:
            memory_size (int or str): An integer is interpreted as a number of
                bytes and a string must be a number followed by a unit, such as
                "100 MB".
            expressions (None, str, or list of str): Names of ``TBranches`` or
                aliases to convert to arrays or mathematical expressions of them.
                Uses the ``language`` to evaluate. If None, all ``TBranches``
                selected by the filters are included.
            cut (None or str): If not None, this expression filters all of the
                ``expressions``.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            aliases (None or dict of str â†’ str): Mathematical expressions that
                can be used in ``expressions`` or other aliases (without cycles).
                Uses the ``language`` engine to evaluate. If None, only the
                :ref:`uproot.behaviors.TBranch.TBranch.aliases` are available.
            language (:doc:`uproot.language.Language`): Language used to interpret
                the ``expressions`` and ``aliases``.
            entry_start (None or int): The first entry to include. If None, start
                at zero. If negative, count from the end, like a Python slice.
            entry_stop (None or int): The first entry to exclude (i.e. one greater
                than the last entry to include). If None, stop at
                :ref:`uproot.behaviors.TTree.TTree.num_entries`. If negative,
                count from the end, like a Python slice.

        Returns an *approximate* step size as a number of entries to read
        a given ``memory_size`` in each step.

        This method does not actually read the ``TBranch`` data or compute any
        expressions to arrive at its estimate. It only uses metadata from the
        already-loaded ``TTree``; it only needs ``language`` to parse the
        expressions, not to evaluate them.

        In addition, the estimate is based on compressed ``TBasket`` sizes
        (the amount of data that would have to be read), not uncompressed
        ``TBasket`` sizes (the amount of data that the final arrays would use
        in memory, without considering ``cuts``).

        This is the algorithm that
        :ref:`uproot.behaviors.TBranch.HasBranches.iterate` uses to convert a
        ``step_size`` expressed in memory units into a number of entries.
        c                 S  s   d S r	   r   r¶   r   r   r   r‰     rŠ   z-HasBranches.num_entries_for.<locals>.<lambda>)
r0   r1   Úmemory_sizerž   rV   r<   r›   r¡   r¢   Ú_hasbranches_num_entries_for)r   rÐ   r.   r/   r   r    r!   r"   r#   r…   r†   Útarget_num_bytesrª   rC   r«   r¬   r   r   r   Únum_entries_forÅ  s*    ?
ÿ
ö

ÿzHasBranches.num_entries_forc                C  sH   d}| j ||||d�D ](}|du r.t|jƒ}q| t|jƒ¡}qt|ƒS )u  
        Args:
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by name.
            filter_typename (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select ``TBranches`` by type.
            filter_branch (None or function of :doc:`uproot.behaviors.TBranch.TBranch` â†’ bool, :doc:`uproot.interpretation.Interpretation`, or None): A
                filter to select ``TBranches`` using the full
                :doc:`uproot.behaviors.TBranch.TBranch` object. The ``TBranch`` is
                included if the function returns True, excluded if it returns False.
            recursive (bool): If True, descend into any nested subbranches.
                If False, only consider branches directly accessible under this
                object. (Only applies when ``branches=None``.)

        Returns entry offsets in which ``TBasket`` boundaries align in the
        specified set of branches.

        If this :doc:`uproot.behaviors.TBranch.TBranch` has no subbranches,
        the output is identical to
        :ref:`uproot.behaviors.TBranch.TBranch.entry_offsets`.
        NrÀ   )rÁ   r£   Úentry_offsetsÚintersectionÚsorted)r   r   r    r!   rj   Zcommon_offsetsr�   r   r   r   Úcommon_entry_offsets  s    ü
z HasBranches.common_entry_offsetsc              	   C  sH  |}t j |¡r| j| S t|tƒr2t j |¡}ntd|›�ƒ‚| d¡r\d}|dd … }nd}| j	 
|¡}|d urx|S d|v rä| }z$| d¡D ]}|dkr�|| }q�W n6 t jyÞ   t j|| j|d�| jj| jd�d ‚Y n0 |S |�r$t| |ƒ}|d u�r|S t j|| j|d�| jj| jd�‚n t j|| j|d�| jj| jd�‚d S )	Nz*where must be an integer or a string, not rË   Fé   TÚ ©rj   )rª   r@   rA   )r0   r1   Úisintrf   r{   ÚstrÚ
ensure_strrÍ   Ú
startswithÚ_lookuprŽ   Úsplitr;   rª   rŸ   r@   rA   Ú_get_recursive)r   r   Zoriginal_whererj   ÚgotÚthisZpiecer   r   r   r   G  sZ    



üû


ü
üzHasBranches.__getitem__c                 c  s   | j E d H  d S r	   )rf   r   r   r   r   Ú__iter__~  s    zHasBranches.__iter__c                 C  s
   t | jƒS r	   )r~   rf   r   r   r   r   Ú__len__�  s    zHasBranches.__len__z!uproot.source.chunk.Source | None)Úreturnc                 C  s*   t | tjjƒr&t | jtjjƒr&| jjS dS )z„Returns the associated source of data for this container, if it exists

        Returns: uproot.source.chunk.Source or None
        N)r{   r0   ÚmodelÚModelrŸ   ÚreadingZReadOnlyFilerL   r   r   r   r   rL   „  s
    
ÿzHasBranches.source)NN)NN)NN)r   r   r   r[   r\   rf   r   ÚsysÚstdoutrƒ   r0   r#   ÚpythonÚpython_languagerC   r7   rª   rÂ   rÄ   rÇ   r¿   rÁ   r}   rÆ   rÏ   rÓ   r×   r   rä   rå   rL   r   r   r   r   rb     sò   
õf  ýï V  ýî tø,ú(ù*ù*ø,ú(øQù&	  üô[ú*7rb   z(.*\.)*([^\.\[\]]*)(\[.*\])*z*(.*\.)*([^\.\[\]]*)\.([^\.\[\]]*)(\[.*\])*c                   @  s¬  e Zd ZdZdd„ ZdPddddddœd	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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/d0„ ƒZed1d2„ ƒZed3d4„ ƒZed5d6„ ƒZed7d8„ ƒZd9d:„ Zd;d<„ Zd=d>„ Z d?d@„ Z!dAdB„ Z"edCdD„ ƒZ#dEdF„ Z$dGdH„ Z%dIdJ„ Z&ddddKe'j(fdLdM„Z)dKe*fdNdO„Z+dS )Qr|   aµ  
    Behaviors for a ``TBranch``, which mostly consist of array-reading methods.

    Since a :doc:`uproot.behaviors.TBranch.TBranch` 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_branch["subbranch"]
        my_branch["subbranch"]["subsubbranch"]
        my_branch["subbranch/subsubbranch"]
    c              	   C  s^   t | ƒdkr.d| j› d| j›dt| ƒd›d�S d| j› d| j›dt | ƒ› dt| ƒd›d�	S d S )	Nr   ú<rx   z at 0xZ012xú>z (z subbranches) at 0x)r~   Ú	classnamers   Úidr   r   r   r   rU   ¤  s    "zTBranch.__repr__Nr„   r   F)r%   r&   rD   r'   r(   c                  s�  |du rˆj }nt|ƒ}tˆjˆˆƒ\‰‰t||ˆjƒ\}}tˆ ˆjƒ‰ tj j 	ˆ¡‰‡ ‡‡‡‡fdd„}	i }
g }i }t
ˆˆjˆ||	|
||ddƒ
 g }tƒ }|D ]h\}}|d D ]V}|j|vr°t||j tj jjƒs°| |j¡ | ˆˆ¡D ]\}}| |||f¡ qìq°q d|i}tˆ||ˆˆ||ˆ|
d|ƒ t|
||ˆd|ƒ ˆ du�r†ˆj› dˆj› d|j› dˆ› d	ˆ› dˆj› �}|
ˆj ˆ |< |
ˆj S )
a°
  
        Args:
            interpretation (None or :doc:`uproot.interpretation.Interpretation`): An
                interpretation of the ``TBranch`` data as an array. If None, the
                standard :ref:`uproot.behaviors.TBranch.TBranch.interpretation`
                is used, which is derived from
                :doc:`uproot.interpretation.identify.interpretation_of`.
            entry_start (None or int): The first entry to include. If None, start
                at zero. If negative, count from the end, like a Python slice.
            entry_stop (None or int): The first entry to exclude (i.e. one greater
                than the last entry to include). If None, stop at
                :ref:`uproot.behaviors.TTree.TTree.num_entries`. If negative,
                count from the end, like a Python slice.
            decompression_executor (None or Executor with a ``submit`` method): The
                executor that is used to decompress ``TBaskets``; if None, the
                file's :ref:`uproot.reading.ReadOnlyFile.decompression_executor`
                is used.
            interpretation_executor (None or Executor with a ``submit`` method): The
                executor that is used to interpret uncompressed ``TBasket`` data as
                arrays; if None, the file's :ref:`uproot.reading.ReadOnlyFile.interpretation_executor`
                is used.
            array_cache ("inherit", None, MutableMapping, or memory size): Cache of arrays;
                if "inherit", use the file's cache; if None, do not use a cache;
                if a memory size, create a new cache of this size.
            library (str or :doc:`uproot.interpretation.library.Library`): The library
                that is used to represent arrays. Options are ``"np"`` for NumPy,
                ``"ak"`` for Awkward Array, and ``"pd"`` for Pandas.
            ak_add_doc (bool): If True and ``library="ak"``, add the TBranch ``title``
                to the Awkward ``__doc__`` parameter of the array.

        Returns the ``TBranch`` data as an array.

        For example:

        .. code-block:: python

            >>> array = tree
            >>> array = tree.arrays(["x", "y"])    # only reads branches "x" and "y"
            >>> array
            <Array [{x: -41.2, y: 17.4}, ... {x: 32.5, y: 1.2}], type='2304 * {"x": float64,...'>
            >>> array["x"]
            <Array [-41.2, 35.1, 35.1, ... 32.4, 32.5] type='2304 * float64'>
            >>> array["y"]
            <Array [17.4, -16.6, -16.6, ... 1.2, 1.2, 1.2] type='2304 * float64'>

        See also :ref:`uproot.behaviors.TBranch.HasBranches.arrays` to read
        multiple ``TBranches`` into a group of arrays or an array-group.
        Nc                   sF   ˆ d ur>ˆj › d| › d|j › dˆ› dˆ› dˆj› �}ˆ  |¡S d S d S r‹   rŒ   r�   r‘   r   r   r’   ô  s    ,
z%TBranch.array.<locals>.get_from_cacheTFrf   r(   rO   rv   )r4   Ú_regularize_interpretationrž   r<   r3   rŸ   r    r0   r'   r5   Ú_regularize_branchnamers   r£   r�   r{   ÚgroupedÚ	AsGroupedr¤   r¥   rE   r¦   r§   )r   r4   r…   r†   r%   r&   rD   r'   r(   r’   rC   r«   r¬   r­   r®   r¯   r°   r�   r±   r²   r³   r�   r   r‘   r   r`   ª  s†    <ÿÿöþ
ýõú	
.zTBranch.arrayc                 O  s<   | j dd�}|dkr |i kr |S tj |g|¢R i |¤ŽS d S )NÚnp)r'   r   )r`   Únumpy)r   ÚargsÚkwargsrº   r   r   r   Ú	__array__8  s    zTBranch.__array__c                 C  s
   |   d¡S )zä
        Name of the ``TBranch``.

        Note that ``TBranch`` names are not guaranteed to be unique; it is
        sometimes necessary to address a branch by its
        :ref:`uproot.behaviors.TBranch.TBranch.index`.
        ÚfNamerd   r   r   r   r   rs   ?  s    	zTBranch.namec                 C  s
   |   d¡S )z+
        Title of the ``TBranch``.
        ZfTitlerd   r   r   r   r   r^   J  s    zTBranch.titlec                 C  s0   t | jtjjjƒrdnd}| jj› |› | j› �S )z1
        Object path of the ``TBranch``.
        rO   rË   )r{   Ú_parentr0   Ú	behaviorsÚTTreer�   rA   rs   ©r   Úsepr   r   r   rA   Q  s    zTBranch.object_pathc                 C  sL   | j du rFt| jtjjjƒr dnd}| jj› |› | j› d| j	› d�| _ | j S )z…
        String that uniquely specifies this ``TBranch`` in its path, to use as
        part of object and array cache keys.
        NrO   rË   ú(ú))
Ú
_cache_keyr{   rü   r0   rý   rþ   r�   r�   rs   Úindexrÿ   r   r   r   r�   Y  s    
"zTBranch.cache_keyc                 C  s.   t | jjƒD ]\}}|| u r|  S qt‚dS )zõ
        Integer position of this ``TBranch`` in its parent's list of branches.

        Useful for cases in which the
        :ref:`uproot.behaviors.TBranch.TBranch.name` is not unique: the
        non-recursive index is always unique.
        N)Ú	enumerater�   rf   ÚAssertionError)r   Úir�   r   r   r   r  d  s    	
zTBranch.indexc              
   C  sX   | j du rRztjj | i ¡| _ W n0 tjjjyP } z|| _ W Y d}~n
d}~0 0 | j S )aå  
        The standard :doc:`uproot.interpretation.Interpretation` of this
        ``TBranch`` as an array, derived from
        :doc:`uproot.interpretation.identify.interpretation_of`.

        If no interpretation could be found, the value of this property
        would be a :doc:`uproot.interpretation.identify.UnknownInterpretation`,
        which is a Python ``Exception``. Since the exception is *returned*,
        rather than *raised*, a branch lacking an interpretation is not a fatal
        error.

        However, any attempt to use this exception object as an
        :doc:`uproot.interpretation.Interpretation` causes it to raise itself:
        attempting to read a branch lacking an interpretation is a fatal error.
        N)Ú_interpretationr0   r4   ÚidentifyZinterpretation_ofÚUnknownInterpretation)r   Úerrr   r   r   r4   s  s    
ÿ
zTBranch.interpretationc                 C  s   | j du rdS | j jS dS )a  
        The C++ typename of the ``TBranch``, derived from its
        :ref:`uproot.behaviors.TBranch.TBranch.interpretation`. If the
        interpretation is
        :doc:`uproot.interpretation.identify.UnknownInterpretation`, the
        typename is ``"unknown"``.
        NÚunknown)r4   rt   r   r   r   r   rt   �  s    	
zTBranch.typenamec                 C  s   t |  d¡ƒS )a  
        The number of entries in the ``TBranch``, as reported by ``fEntries``.

        In principle, this could disagree with the
        :ref:`uproot.behaviors.TTree.TTree.num_entries`, which is from the
        ``TTree``'s ``fEntries``.

        The ``TBranch`` also has a ``fEntryNumber``, which ought to be equal to
        the ``TBranch`` and ``TTree``'s ``fEntries``, and the last value of
        :ref:`uproot.behaviors.TBranch.TBranch.entry_offsets` ought to be
        equal to the number of entries as well.
        ÚfEntries)Úintre   r   r   r   r   r<   ›  s    zTBranch.num_entriesc              	   C  sÀ   | j dkrdg}n|  d¡d| j d …  ¡ }|d }| jD ]}| |d |j ¡ q<|d | jkr¸| jdur¸t| jtjj	j
ƒs¸td|› dtdd	„ | jD ƒƒ› d
| j› d| jj› �ƒ‚n|S dS )a”  
        The starting and stopping entry numbers for all the ``TBaskets`` in the
        ``TBranch`` as a list of increasing, non-negative integers.

        The number of ``entry_offsets`` in this list of integers is one more
        than the number of ``TBaskets``. The first is ``0`` and the last is
        the number of entries
        (:ref:`uproot.behaviors.TBranch.TBranch.num_entries`).
        r   ÚfBasketEntryNrØ   éÿÿÿÿzentries in normal baskets (z) plus embedded baskets (c                 s  s   | ]}|j V  qd S r	   )r<   )r—   r»   r   r   r   Ú	<genexpr>Ç  rŠ   z(TBranch.entry_offsets.<locals>.<genexpr>z.) don't add up to expected number of entries (z
)
in file )Ú_num_normal_basketsre   ÚtolistÚembedded_basketsrE   r<   r4   r{   r0   rô   rõ   ry   ÚsumrŸ   r@   )r   rº   Znum_entries_normalr»   r   r   r   rÔ   «  s,    

ÿþÿýÿþÿzTBranch.entry_offsetsc              	   C  sâ   d|  kr| j k r8n n|  d¡}|| ||d  fS d|  krN| jk r¶n nd| j }| j dkrhd}n|  d¡| j  }| jD ]0}||krœ|||j f  S |d7 }||j7 }q~t‚n(td| j›d| j› d|› d| jj	› �ƒ‚dS )	z_
        The starting and stopping entry number for ``TBasket`` number ``basket_num``.
        r   r  rØ   úbranch ú has z/ baskets; cannot get starting entry for basket ú	
in file N)
r  re   Únum_basketsr  r<   r  Ú
IndexErrorrs   rŸ   r@   )r   r±   r  Zbaskets_beforeZentries_beforer»   r   r   r   Úbasket_entry_start_stopÎ  s*    


ÿþÿzTBranch.basket_entry_start_stopc                 C  s    | }t |tjjjƒs|j}q|S )z›
        The ``TTree`` to which this ``TBranch`` belongs. The branch might be
        deeply nested; this property ascends all the way to the top.
        )r{   r0   rý   rþ   r�   ©r   rº   r   r   r   rV   ì  s    zTBranch.treec                 C  s   t | jtjjjƒS )z}
        True if this branch's immediate :ref:`uproot.model.Model.parent`
        is the ``TTree``; False otherwise.
        )r{   r�   r0   rý   rþ   r   r   r   r   Ú	top_level÷  s    zTBranch.top_levelc           
      C  sö  | j du �rðt | j¡ d¡}t | j¡}| jddd�}| jddd�}|du�rŒ|dk�rŒ| jj 	|¡}|du�rð|t
|ƒ }| | jj¡D ]J}|j|krŒ|du sÌ|dksÌ|jdu sÌ|jjdksÌ|jj|krŒ|| _  qØqŒ| j du �r\|du�r\| d¡}| | jj¡D ]T}|j|k�r| j |j¡}| | jj¡D ]}	|	j|k�r2|	| _  �qR�q2 �q\�q| j d¡dk�s„| jjd	dd�|k�rðd| _nd|du�rð|dk�rð|dk�rÊd| _| jj 	| jd	dd�¡}n| jj 	|¡}|du�rð|t
|ƒ | _ | j S )
a/  
        The ``TStreamerInfo`` or ``TStreamerElement`` for this ``TBranch``,
        which may be None.

        If the :ref:`uproot.reading.ReadOnlyFile.streamers` have not yet been
        read, this method *might* cause them to be read. (Only
        ``TBranchElements`` can have streamers.)
        Né   ÚfParentNameT)Znone_if_missingÚ
fClassNamerÙ   ZTClonesArrayZfClonesName)Ú	_streamerÚ_branch_clean_nameÚmatchrs   r©   Ú_branch_clean_parent_namere   rŸ   Z	streamersrŽ   ÚmaxZwalk_membersr�   Zstreamer_namedrt   Ú_streamer_isTClonesArray)
r   Z
clean_nameZclean_parentnamer  r   ÚmatchesZstreamerinfoÚelementZsubstreamerinfoZ
subelementr   r   r   Ústreamerÿ  sl    


ÿþý
ü
û
ÿÿ

ÿÿþ
ÿ
zTBranch.streamerc                 C  s   | j S )zÇ
        Auxiliary data used in deserialization. This is a *copy* of the
        ``context`` dict at the time that the ``TBranch`` was deserialized
        with ``"in_TBranch": True`` added.
        )Ú_contextr   r   r   r   r°   D  s    zTBranch.contextc                 C  s   | j jS )uß  
        The :ref:`uproot.behaviors.TTree.TTree.aliases`, 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).
        )rV   r"   r   r   r   r   r"   M  s    zTBranch.aliasesc                 C  sJ   | j }t|tjjƒr&| d¡r&|j}qt|tjjƒrB| d¡rB|S dS dS )z
        The ``TBranch`` object in which this branch's "counts" reside or None
        if this branch has no "counts".
        ZTLeafr|   N)Ú
count_leafr{   r0   rç   rè   Zis_instancer�   r  r   r   r   Úcount_branch\  s    zTBranch.count_branchc                 C  s(   |   d¡}t|ƒdkrdS |d   d¡S )zp
        The ``TLeaf`` object of this branch's "counts" or None if this branch
        has no "counts".
        ZfLeavesrØ   Nr   Z
fLeafCount)re   r~   )r   Úleavesr   r   r   r+  j  s    
zTBranch.count_leafc                 C  s   t jj |  d¡¡S )a,  
        A :doc:`uproot.compression.Compression` object describing the
        compression setting for the ``TBranch``.

        Note that different ``TBranches`` in a ``TTree`` can be compressed
        differently from each other, and they can be compressed differently
        from the file's global compression setting.

        It is also *in principle possible* for the blocks in each ``TBasket``
        to be compresssed differently: see
        :ref:`uproot.models.TBasket.Model_TBasket.block_compression_info` if
        you're paranoid.
        Z	fCompress)r0   ÚcompressionZCompressionZ	from_codere   r   r   r   r   r.  u  s    zTBranch.compressionc                 C  s
   |   d¡S )a3  
        The number of compressed bytes in all ``TBaskets`` of this ``TBranch``,
        including the TKey headers (which are always uncompressed).

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

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

        See :ref:`uproot.behaviors.TBranch.TBranch.compressed_bytes` and
        :ref:`uproot.behaviors.TBranch.TBranch.uncompressed_bytes`.
        )Úfloatr0  r/  r   r   r   r   Úcompression_ratioœ  s    	zTBranch.compression_ratioc                 C  s   | j t| jƒ S )z¹
        The number of ``TBaskets`` in this ``TBranch``, including both normal
        (free) ``TBaskets`` and
        :ref:`uproot.behaviors.TBranch.TBranch.embedded_baskets`.
        )r  r~   r  r   r   r   r   r  §  s    zTBranch.num_basketsc              	   C  s    d|  kr| j k rJn n0|  |¡\}}tjjj ||d|i| j| j| ¡S d|  kr`| jk rtn n| j	|| j   S t
d| j›d| j› d|› d| jj› �ƒ‚dS )zØ
        The :doc:`uproot.models.TBasket.Model_TBasket` at index ``basket_num``.

        It may be a normal (free) ``TBasket`` or one of the
        :ref:`uproot.behaviors.TBranch.TBranch.embedded_baskets`.
        r   r±   r  r  z baskets; cannot get basket r  N)r  Úbasket_chunk_cursorr0   ÚmodelsÚTBasketÚModel_TBasketÚreadrŸ   r  r  r  rs   r@   )r   r±   ÚchunkÚcursorr   r   r   r»   °  s    
ÿÿÿzTBranch.basketc              	   C  sÌ   d|  kr| j k r\n nB|  d¡| }||  |¡ }tjj |¡}| jj ||¡}||fS d|  krr| j	k r n n*t
d| j›d| j › d|› d| jj› �ƒ‚n(t
d| j›d| j	› d|› d| jj› �ƒ‚d	S )
aß  
        Returns a :doc:`uproot.source.chunk.Chunk` and
        :doc:`uproot.source.cursor.Cursor` as a 2-tuple for a given
        ``basket_num``.

        If the file source is :doc:`uproot.source.file.MemmapSource`
        and the file gets closed, accessing the Chunk would cause
        a segfault. If that's a possibility, be sure to call
        :doc:`uproot.source.chunk.Chunk.detach_memmap` to ensure
        that any memmap-derived data gets copied for safety.
        r   ÚfBasketSeekr  r  z8 normal baskets; cannot get chunk and cursor for basket z2 because only normal baskets have cursors
in file z1 baskets; cannot get cursor and chunk for basket r  N)r  re   Úbasket_compressed_bytesr0   rL   r9  ÚCursorrŸ   r8  r  r  rs   r@   ©r   r±   rY   rZ   r9  r8  r   r   r   r3  Ä  s*    ÿþÿÿþÿzTBranch.basket_chunk_cursorc              	   C  s„   d|  kr| j k r,n nt|  d¡| ƒS d|  krB| jk rXn n| j|| j   jS td| j›d| j› d|› d| jj	› �ƒ‚dS )ac  
        The number of compressed bytes for the ``TBasket`` at ``basket_num``,
        including the TKey header.

        The number of compressed bytes is specified in the ``TBranch`` metadata
        and can be determined without reading any additional data. The
        uncompressed bytes requires reading the ``TBasket``'s ``TKey`` at least.
        r   ZfBasketBytesr  r  ú" baskets; cannot get basket chunk r  N)
r  r  re   r  r  r/  r  rs   rŸ   r@   ©r   r±   r   r   r   r;  ã  s    	ÿÿÿzTBranch.basket_compressed_bytesc                 C  s6   d|  kr| j k r&n n|  |¡jS |  |¡jS dS )aN  
        The number of uncompressed bytes for the ``TBasket`` at ``basket_num``,
        including the TKey header.

        The number of uncompressed bytes cannot be determined without reading a
        ``TKey``, which are small, but may be slow for remote connections because
        of the latency of round-trip requests.
        r   N)r  r»   r0  Ú
basket_keyZdata_uncompressed_bytesr?  r   r   r   Úbasket_uncompressed_bytesø  s    	z!TBranch.basket_uncompressed_bytesc              	   C  sÎ   d|  kr| j k rnn nT|  d¡| }|tjjj }tjj |¡}| j	j 
||¡}tjj||i | j	| dd�S d|  kr„| jk r¢n ntd| j›d|› d�ƒ‚n(td| j›d| j› d	|› d
| j	j› �ƒ‚dS )zì
        The ``TKey`` (:doc:`uproot.reading.ReadOnlyKey`) for the ``TBasket``
        at ``basket_num``.

        Only applies to normal (free) ``TBaskets``, not
        :ref:`uproot.behaviors.TBranch.TBranch.embedded_baskets`.
        r   r:  F)Zread_stringsr  z basket z) is an embedded basket, which has no TKeyr  r>  r  N)r  re   r0   ré   Z_key_format_bigÚsizerL   r9  r<  rŸ   r8  ZReadOnlyKeyr  ry   rs   r  r@   r=  r   r   r   r@  	  s"    ÿÿÿÿzTBranch.basket_keyc                 C  s˜   | j du r’| j ¡ }tjjj | jj	|i | j
| j
| ¡}| j�F g | _ |D ]*}|durH| jt| j ƒ |_| j  |¡ qHW d  ƒ n1 sˆ0    Y  | j S )zµ
        The ``TBaskets`` that are embedded within the ``TBranch`` metadata,
        usually because the ROOT process that was writing the file closed
        unexpectedly.
        N)Ú_embedded_basketsZ_cursor_basketsÚcopyr0   r4  Z	TObjArrayZModel_TObjArrayOfTBasketsr7  rV   r8  rŸ   Ú_embedded_baskets_lockr  r~   Ú_basket_numrE   )r   r9  Zbasketsr»   r   r   r   r  %	  s    


ÿÿ,zTBranch.embedded_basketsc           
      C  sÌ   | j }g }|d }t|dd… ƒD ]¤\}}||k rÂ||krÂd|  krP| jk r„n n0|  d¡| }||  |¡ }	| |||	ff¡ n>d|  krš| jk r´n n| ||  |¡f¡ nt| j	|fƒ‚|}q"|S )a˜  
        Returns a list of (start, stop) integer pairs for free (normal)
        ``TBaskets`` and :doc:`uproot.models.TBasket.Model_TBasket` objects
        for embedded ``TBaskets``.

        The intention is for this list to be updated in place, replacing
        (start, stop) integer pairs with
        :doc:`uproot.models.TBasket.Model_TBasket` objects as they get
        read and interpreted.
        r   rØ   Nr:  )
rÔ   r  r  re   r;  rE   r  r»   r  rs   )
r   r…   r†   rÔ   rº   rY   r±   rZ   Z
byte_startZ	byte_stopr   r   r   r¥   <	  s    z$TBranch.entries_to_ranges_or_basketsc                 C  s  |   d¡}i | _|   d¡D ]"}|  d¡}|| jvr|| j|< qd | _d | _d | _d| _d | _t|ƒ| _d| jd< d| jd< d	| _	t
|   d
¡ƒD ]*\}}	|	d	ks¦||krª qº|  j	d7  _	qŽ|   d¡}
t|
ƒ| j	k�rd|   d
¡t|
ƒd  }||  t|
ƒd ¡ }tjj |¡}| jj ||¡}tjjj ||ddi| j| j| ¡}t |
|
d |  d¡ ¡ }
| jd< |   d¡|
| j	 k�rˆg | _d | _nd|  d¡�rÜg | _|   d¡D ].}|d u�r¤| j	t| jƒ |_| j |¡ �q¤d | _nd | _t ¡ | _d| j j!v �r| j   d¡  d¡| _"| S )NÚfWriteBasketrc   rû   Fr   ZbreadcrumbsTZ
in_TBranchr   r:  rØ   r  Zread_basketr  ZfNevBufr  ZfBasketsZfIOFeaturesZfIOBits)#re   rß   r  Z	_typenamer!  r&  r  rÅ   r*  r  r  r~   r;  r0   rL   r9  r<  rŸ   r8  r4  r5  r6  r7  r÷   rE   Z_membersrC  rE  Z
has_memberrF  Ú	threadingÚLockrü   ÚmembersZ_tree_iofeatures)r   r8  r9  r°   rT   rG  r�   rs   r  Úxr  rY   rZ   Zbasket_headerr»   r   r   r   ÚpostprocessW	  s`    







ÿÿ
ÿ
zTBranch.postprocessc                 C  sj   z|  | j¡ W nT tjjjyd } z6td|›d|j› d| jj› d| j	› �ƒ|‚W Y d }~n
d }~0 0 d S )Nz1cannot produce Awkward Arrays for interpretation z because

    ze

instead, try library="np" rather than library="ak" or globally set uproot.default_library

in file z
in object )
Zawkward_formrT   r0   r4   ÚobjectsZCannotBeAwkwardry   Zbecauser@   rA   )r   r4   r  r   r   r   Ú_awkward_check—	  s    þúùÿ	÷zTBranch._awkward_checkr   c           
      C  s^   |   |¡}tjjj | jj|¡}|du r8tjj d¡}	ntjj |¡}	|	j	|||||d� dS )aw
  
        Args:
            entry (int): Entry number to inspect. Note: this debugging routine
                is not applicable to data without entry offsets (nor would it
                be needed).
            skip_bytes (int): Number of bytes to skip before presenting the
                remainder of the ``entry``. May be negative, to examine the
                byte stream before the ``entry``.
            limit_bytes (None or int): Number of bytes to limit the output to.
                A line of debugging output (without any ``offset``) is 20 bytes,
                so multiples of 20 show full lines. If None, everything is
                shown to the end of the ``entry``, which might be large.
            dtype (None, ``numpy.dtype``, or its constructor argument): If None,
                present only the bytes as decimal values (0-255). Otherwise,
                also interpret them as an array of a given NumPy type.
            offset (int): Number of bytes to skip before interpreting a ``dtype``;
                can be helpful if the numerical values are out of phase with
                the first byte shown. Not to be confused with ``skip_bytes``,
                which determines which bytes are shown at all. Any ``offset``
                values that are equivalent modulo ``dtype.itemsize`` show
                equivalent interpretations.
            stream (object with a ``write(str)`` method): Stream to write the
                debugging output to.

        Presents the data for one entry as raw bytes.

        Example output with ``dtype=">f4"`` and ``offset=3``.

        .. code-block::

            --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
            123 123 123  63 140 204 205  64  12 204 205  64  83  51  51  64 140 204 205  64
              {   {   {   ? --- --- ---   @ --- --- ---   @   S   3   3   @ --- --- ---   @
                                    1.1             2.2             3.3             4.4
                --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
                176   0   0  64 211  51  51  64 246 102 102  65  12 204 205  65  30 102 102  66
                --- --- ---   @ ---   3   3   @ ---   f   f   A --- --- ---   A ---   f   f   B
                        5.5             6.6             7.7             8.8             9.9
                --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
                202   0   0  67  74   0   0  67 151 128   0 123 123
                --- --- ---   C   J --- ---   C --- --- ---   {   {
                      101.0           202.0           303.0
        Nr   )Úlimit_bytesÚdtypeÚoffsetro   )
Údebug_arrayr0   rL   r8  ÚChunkÚwraprŸ   r9  r<  Údebug)
r   ÚentryÚ
skip_bytesrO  rP  rQ  ro   Údatar8  r9  r   r   r   rU  ¦	  s    4

ÿzTBranch.debugc                 C  sf   t  |¡}tjj tjj d¡¡}| j|||d dd�d |d… }|dt	|ƒ|j
 |j
 …  |¡S )aæ  
        Args:
            entry (int): Entry number to inspect. Note: this debugging routine
                is not applicable to data without entry offsets (nor would it
                be needed).
            skip_bytes (int): Number of bytes to skip before presenting the
                remainder of the ``entry``. May be negative, to examine the
                byte stream before the ``entry``.
            dtype (``numpy.dtype`` or its constructor argument): Data type in
                which to interpret the data. (The size of the array returned is
                truncated to this ``dtype.itemsize``.)

        Like :ref:`uproot.behaviors.TBranch.TBranch.debug`, but returns a
        NumPy array for further inspection.
        r   rØ   rö   )r…   r†   r'   r   N)r÷   rP  r0   r4   ÚjaggedÚAsJaggedÚ	numericalÚAsDtyper`   r~   ÚitemsizeÚview)r   rV  rW  rP  r4   rº   r   r   r   rR  ä	  s    
ÿÿþþzTBranch.debug_array)NNN),r   r   r   r[   rU   r`   rú   r\   rs   r^   rA   r�   r  r4   rt   r<   rÔ   r  rV   r  r)  r°   r"   r,  r+  r.  r/  r0  r2  r  r»   r3  r;  rA  r@  r  r¥   rL  rN  rê   rë   rU  Únp_uint8rR  r   r   r   r   r|   •  s”      üö 










"



D













@ù
>r|   c                 C  s\   |j  }}| |ƒrdS ||ur<|j}||ur|j d | }q||krP| |ƒrPdS | d| ƒS )NTrË   )rs   r�   )r   r   r�   Úshallowrs   r   r   r   rÎ   þ	  s    
rÎ   c                 C  sj   t ƒ }| jdd�D ]R}|j}| |¡ || urL|j}|| ur&|jd | }q&| |¡ | d| ¡ q|S )NTrÚ   rË   )r£   rÁ   rs   r¤   r�   )r   rº   r�   rs   r   r   r   r›   
  s    

r›   c                 C  sB   | j  |¡}|d ur|S | jD ]}t||ƒ}|d ur|  S qd S r	   )rß   rŽ   rf   rá   )r   r   râ   r�   r   r   r   rá   
  s    


rá   c                 C  sx   |d u rd}n|dk r|| 7 }t | td|ƒƒ}|d u r<| }n|dk rL|| 7 }t | td|ƒƒ}||k rh|}t|ƒt|ƒfS )Nr   )r¹   r%  r  )r<   r…   r†   r   r   r   rž   %
  s    rž   c                 C  sV   |d u r2| d u rt jj ¡ } |d u rNt jj ¡ }n| d u r@|j} |d u rN|j}| |fS r	   )r0   rL   ÚfuturesZTrivialExecutorr%   r&   )r%   r&   rT   r   r   r   r3   8
  s    r3   c                 C  s`   t | tƒr| S t | tƒr&| dkr&|jS | d u r2d S tj | ¡sHt | tƒrTtj | ¡S t	dƒ‚d S )Nr„   z<array_cache must be None, a MutableMapping, or a memory size)
r{   r   rÜ   Z_array_cacher0   r1   rÛ   ÚcacheZLRUArrayCacherÍ   )rD   rT   r   r   r   r    F
  s    
r    c                 C  s*   |d u r| j S t| j ƒ}| |¡ |S d S r	   )r"   rÅ   Úupdate)r   r"   Znew_aliasesr   r   r   r¡   S
  s
    

r¡   c                 C  sR   t | tjjƒr| S t | tjƒr,tjj | ¡S t | ¡}| d¡}tjj | ¡S d S )Nrï   )	r{   r0   r4   ZInterpretationr÷   rP  r[  r\  Znewbyteorder)r4   rP  r   r   r   rò   \
  s    

rò   c
                 C  s  |||ƒ}
|
d ur|
||j < t|tjjjƒ}t|tjjjƒržg }|j 	¡ D ]<\}}t
| ||| |||||d|	ƒ
 | |d d d ¡ qJ| |¡ d ||j < n|g}|j |v rÜ||j  j |j krætd||j  ›d|›�ƒ‚n
|||j < ||	|d|dœ}| ||f¡ d S )	NFr  rØ   rf   z9a branch cannot be loaded with multiple interpretations: z and T©r”   r•   Ú	is_jaggedÚ	is_branchrf   )r�   r{   r0   r4   rY  rZ  rô   rõ   ÚsubbranchesrÄ   ró   ÚextendrE   ry   )r   r�   r�   r4   r’   rC   r«   r¬   r”   r•   râ   re  rf   ÚsubnameZ	subinterpr™   r   r   r   ró   g
  sV    

ö


ÿÿÿÿÿ
ûró   c                 C  s*  |	dk}|   |¡}|d ur8t| |||j||||||
ƒ
 nî|  ||¡}d}g }| |||| jj| j¡D ]�}||	v r¢td t	|ƒd 
dd„ | ¡ D ƒ¡| jj| j¡ƒ‚t| ||||||||g |	¢|‘R dd ƒ |d d d	 rÞd
}| |d d d ¡ qd||
|d|dœ}|d u�r||d< | ||f¡ d S )Nr   FzHsymbol {} is recursively defined with aliases:

    {}

in file {} at {}z
    c                 s  s    | ]\}}|› d |› �V  qdS )z: Nr   )r—   rÉ   rÊ   r   r   r   r  Ú
  rŠ   z)_regularize_expression.<locals>.<genexpr>r  rØ   re  Trf   rd  Úrename)rŽ   ró   r4   Zfree_symbolsrT   r@   rA   ry   rP   rS   ÚjoinrÄ   Ú_regularize_expressionrh  rE   )r   r´   rª   r"   r#   r’   rC   r«   r¬   Zsymbol_pathr•   rj  r”   r�   Z
to_computere  Zexpression_branchesÚsymbolr™   r   r   r   rl  ¦
  sx    
öûøÿôû
rl  c
                 C  sÒ  i }
g }i }|d u rv| j |||ddd�D ]H\}}t|jtjjjtjjjfƒs(t| | 	|¡||||	|
||dd|ƒ q(�nt|t
ƒr t| |||||	|
||ddd ƒ nòt|tƒ�r„t|tƒrÀ| ¡ }n^g }|D ]T}t|t
ƒræ| |d f¡ qÈt|tƒ�rt|ƒdk�r| |¡ qÈtdt|ƒ ƒ‚qÈ|D ]^\}}|d u �rTt| |||||	|
||ddd ƒ n*| | }t|ƒ}t| ||||	|
||ddƒ
 �q"ntd|›�ƒ‚|d u �ržn*t|t
ƒ�rÈt| |||||	|
||ddd ƒ |
||fS )NTFrw   r   r  z]iterable of expressions must be strings or name, Interpretation pairs (length-2 tuples), not zÔexpressions must be None (for all branches), a string (single branch or expression), a list of strings (multiple), or a dict or list of name, Interpretation pairs (branch names and their new Interpretation), not )r}   r{   r4   r0   r	  r
  rô   rõ   rl  Z	getter_ofrÜ   r   rÅ   rÄ   rE   Útupler~   rÍ   rS   rò   ró   )r   r.   r/   r   r    r!   rª   r"   r#   r’   rC   r«   r¬   r�   r�   rÄ   r´   r‚   r   r   r   r¢   þ
  sä    ûþþô

ô


þÿ
ôÿö
ýÿ
ôr¢   c              
     sj  t  ¡ ‰
i ‰i ‰g }i }i ‰d}i }ˆD ]}dˆ|< q(ˆD ]š\}}}ˆ|j  d7  < |jˆvrji ˆ|j< t|tƒr¸t|ƒdkr¸t|d ƒt|d ƒf}| |¡ ||f||< |ˆ|< n
ˆ
 |¡ |d7 }|||j< q:ˆ 	¡ D ]r\}}ˆ| dk�r|ˆ v�r| 
i dddgˆ	d ˆ¡ˆ |< tˆ	tjjjƒrÞt|tjjjƒrÞ||v rÞ||  |¡ qÞˆjjj|ˆ
d� dd„ ‰‡‡
‡‡‡‡fdd„}d	d
„ ˆD ƒ‰‡ ‡‡‡‡‡‡‡‡	‡
f
dd„}tˆ ƒtˆƒk �rfˆ
 ¡ }t|tjjjƒ�r ||j|jf }|j||g|¢R Ž  n^t|tjjjƒ�r | ||¡ n>|d u �r,n2t|tƒ�rVt|ƒdk�rVtjjj|Ž  nt |ƒ‚d }�q®d S )Nr   rØ   r  )Únotificationsc                 S  s    | | \}}}|||f| |< d S r	   r   )r­   Úoriginal_indexr»   r�   r±   r²   r   r   r   ÚreplaceË  s    z-_ranges_or_baskets_to_arrays.<locals>.replacec                   s†   zVt jj | j¡}t jjj | |d|iˆ j	ˆ j	|¡}ˆ| j| j
f }ˆrTˆˆ||ƒ W n  tyv   ˆ t ¡ ¡ Y n0 ˆ |¡ d S )Nr±   )r0   rL   r9  r<  rY   r4  r5  r6  r7  rŸ   rZ   Ú	ExceptionÚputrê   Úexc_info)r8  r�   r±   r9  r»   rp  )r   ro  Úrange_original_indexr­   rq  Úupdate_ranges_or_basketsr   r   Úchunk_to_basketÏ  s     
úz5_ranges_or_baskets_to_arrays.<locals>.chunk_to_basketc                 S  s   i | ]}|t  ¡ “qS r   )rH  Úlocal)r—   rK  r   r   r   Ú
<dictcomp>â  rŠ   z0_ranges_or_baskets_to_arrays.<locals>.<dictcomp>c                   s.  zü| j d usJ ‚| j}ˆ|j }ˆ|j }t|jƒ}ˆ|j |d< | | j| j| |||  d¡ˆˆ¡|| j < | j	t
|| j  ƒkr¾td| j › d|j› d| j	› dt
|| j  ƒ› d|› d|jj› �ƒ‚d } t
|ƒˆ|j krú| |ˆˆ|jˆ|ˆ¡ˆ |j< | ¡  W n" t�y   ˆ	 t ¡ ¡ Y n0 ˆ	 d ¡ d S )	NÚforthZfKeylenzbasket z in tree/branch z+ has the wrong number of entries (expected z, obtained z) when interpreted as z
    in file )r±   r�   r�   rÅ   r°   Zbasket_arrayrX  Zbyte_offsetsre   r<   r~   ry   rA   rT   r@   Úfinal_arrayrÔ   Úclearrr  rs  rê   rt  )r»   r�   r4   Zbasket_arraysr°   )
rC   Úbranchid_arraysr¬   Úbranchid_num_basketsr…   r†   Úforth_contextr³   r'   ro  r   r   Úbasket_to_arrayä  sX    


ø

ÿÿÿþÿù

z5_ranges_or_baskets_to_arrays.<locals>.basket_to_arrayrp   )!ÚqueueÚQueuer�   r{   rn  r~   r  rE   rs  rÄ   r{  r0   r4   r'   ZAwkwardrM  Z	AsObjectsrN  rŸ   rL   ÚchunksrŽ   r8  rS  rY   rZ   Úsubmitr4  r5  r6  ra  Zdelayed_raiser  )r   r­   r¬   r…   r†   r%   r&   r'   rC   rv  r³   ÚrangesZ
range_argsrp  Zbranchid_to_branchr�   r�   r±   r²   r4   rw  r€  Úobjrø   r   )rC   r}  r¬   r~  r…   r†   r  r   r³   r'   ro  ru  r­   rq  rv  r   r¦   Œ  sl    




þ


ÿÿþý/
r¦   c                 C  sÊ   d}t |ƒD ]¸\}\}}	|	d r|	d d }
||
j }t|tjjjƒr| |
j d u sXJ ‚t|||… ƒ}i }g }|jD ],}|
| }| |j ||< | 	||| f¡ qvt
| |||¡|
|ƒ| |
j< |}qd S )Nr   rf  rf   r  )r  r�   r{   r0   r4   rô   rõ   rÅ   rg  rE   ra   r©   )rC   r«   r¬   r'   r)   r(   Zindex_startZ
index_stopr¯   r°   r�   r4   Zlimited_contextZ	subarraysZ
subcontextri  Z	subbranchr   r   r   r§   )  s$    

ÿ
r§   c                 C  s¨   d}| j dd�D ]X}|j|v r|j}|d }t|dd … ƒD ]*\}	}
||
k rb||krb|| |	¡7 }|
}q<q|| }|dkr€d}ntt|| | ƒƒ}|dkr dS |S d S )Ng        TrÚ   r   rØ   )rÁ   r�   rÔ   r  r;  r  Úround)r   rÒ   r…   r†   r¬   Útotal_bytesr�   rÔ   rY   r±   rZ   Ztotal_entriesr<   r   r   r   rÑ   D  s     
rÑ   c                 C  s4   t j |¡r|S t j |d|›�¡}t| ||||ƒS )NzTnumber of entries or memory size string with units (such as '100 MB') required, not )r0   r1   rÛ   rÐ   rÑ   )r   r$   r…   r†   r¬   rÒ   r   r   r   r·   \  s    ÿþ
ÿr·   c                   @  sL   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dS )Ú	_WrapDictc                 C  s
   || _ d S r	   ©rÅ   )r   rÅ   r   r   r   r   l  s    z_WrapDict.__init__c                 C  s
   t | jƒS r	   )rÜ   rÅ   r   r   r   r   Ú__str__o  s    z_WrapDict.__str__c                 C  s
   t | jƒS r	   )rS   rÅ   r   r   r   r   rU   r  s    z_WrapDict.__repr__c                 C  s
   | j | S r	   rŠ  r   r   r   r   r   u  s    z_WrapDict.__getitem__c                 C  s   || j |< d S r	   rŠ  )r   r   Úwhatr   r   r   Ú__setitem__x  s    z_WrapDict.__setitem__c                 C  s   | j |= d S r	   rŠ  r   r   r   r   Ú__delitem__{  s    z_WrapDict.__delitem__c                 c  s   | j E d H  d S r	   rŠ  r   r   r   r   rä   ~  s    z_WrapDict.__iter__c                 C  s
   t | jƒS r	   )r~   rÅ   r   r   r   r   rå   �  s    z_WrapDict.__len__N)r   r   r   r   r‹  rU   r   r�  rŽ  rä   rå   r   r   r   r   r‰  k  s   r‰  )NN)NN)1r[   Ú
__future__r   r�  Úrerê   rH  Úcollections.abcr   r   r   r÷   r0   Zuproot.interpretation.groupedZuproot.language.pythonZuproot.source.chunkZuproot._utilr   rP  r_  r   r#   rì   rí   r7   rF   rG   ra   rb   Úcompiler"  r$  r|   rÎ   r›   rá   rž   r3   r    r¡   rò   ró   rl  r¢   r¦   r§   rÑ   r·   r‰  r   r   r   r   Ú<module>   s²   

  ýî 4  ýð "         z

      o	?X  