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ZddlZg d¢Z	ddgZ
e d¡Zdd	„ Zd
d„ ZddddddddddddddddœZe d¡Ze dd dd „ eD ƒ¡ d! ¡Ze d"¡Ze d#¡Ze d$¡Ze d%¡Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ ZdGd/d0„Zd1d2„ ZdHd3d4„ZdId5d6„Zd7d8„ Z G d9d:„ d:ƒZ!G d;d<„ d<e!ƒZ"G d=d>„ d>ƒZ#G d?d@„ d@ƒZ$G dAdB„ dBe!ƒZ%G dCdD„ dDe"ƒZ&G dEdF„ dFe"ƒZ'dS )JaŠ  
This module defines utilities for modeling C++ objects as Python objects and the
:doc:`uproot.model.Model` class, which is the superclass of all objects that
are read from ROOT files.

The :doc:`uproot.model.VersionedModel` class is the superclass of all models
whose deserialization routines are specialized by ROOT class version.

A :doc:`uproot.model.DispatchByVersion` subclass selects a versioned model
after reading its version bytes.

The :doc:`uproot.model.UnknownClass` and
:doc:`uproot.model.UnknownClassVersion` are placeholders for data that could
not be modeled, either because the class has no streamer or no streamer for its
version.
é    )ÚannotationsN)ZTStreamerInfoZTStreamerElementZTStreamerArtificialZTStreamerBaseZTStreamerBasicPointerZTStreamerBasicTypeZTStreamerLoopZTStreamerObjectZTStreamerObjectAnyZTStreamerObjectAnyPointerZTStreamerObjectPointerZTStreamerSTLZTStreamerSTLstringZTStreamerStringÚTListÚ	TObjArrayZTClonesArrayÚ
TObjStringÚTStringr   Úu1c                  C  s@   ddl } ddl} ddl} ddl} i }tD ]}| j| ||< q(|S )zx
    Returns the basic classes that are needed to load other classes (streamers,
    TList, TObjArray, TObjString).
    r   N)Zuproot.models.TListZuproot.models.TObjArrayZuproot.models.TObjStringZuproot.streamersÚbootstrap_classnamesÚclasses)ÚuprootÚcustom_classesÚ	classname© r   úO/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/uproot/model.pyÚbootstrap_classes:   s    r   c                  C  s"  ddl m}  i t_i t_| tjƒ | tjjƒ | tjjƒ | tjj	ƒ | tjj
ƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ | tjjƒ dS )z 
    Removes all classes from ``uproot.classes`` and ``uproot.unknown_classes``
    and refills ``uproot.classes`` with original versions of these classes.
    r   ©ÚreloadN)Ú	importlibr   r
   r	   Úunknown_classesZ	streamersÚmodelsZTObjectr   ZTArrayZTNamedr   Z	THashListr   r   ZTAttZTDatimeZTRefZTTableZTTreeZTBranchZTLeafZTBasketZRNTupleZTHZTGraphZTMatrixTZTTimer   r   r   r   Úreset_classesK   s2    
r   ÚboolÚcharzunsigned charÚshortzunsigned shortÚintzunsigned intÚlongzunsigned longz	long longzunsigned long longZsize_tÚfloatÚdoublezlong double)ZBool_tZChar_tZUChar_tZShort_tZUShort_tZInt_tZUInt_tZLong_tZULong_tZLong64_tZ	ULong64_tZSize_tZFloat_tZDouble_tZLongDouble_tz\s*(<|>|,|::)\s*z[<,](ú|c                 C  s   g | ]}t  |¡‘qS r   )ÚreÚescape)Ú.0Úpr   r   r   Ú
<listcomp>‚   ó    r"   z)[>,]s   [^a-zA-Z0-9]+s!   .*_([0-9a-f][0-9a-f])+_v([0-9]+)$s   .*_v([0-9]+)$s   _(([0-9a-f][0-9a-f])+)_c                   s,   |   d¡‰ t‡ fdd„tdtˆ ƒdƒD ƒƒS )Né   c                 3  s$   | ]}t ˆ ||d  … dƒV  qdS )é   é   N)r   )r    Úi©Úgr   r   Ú	<genexpr>�   r#   z,_classname_decode_convert.<locals>.<genexpr>r   r%   )ÚgroupÚbytesÚrangeÚlen)Zhex_charactersr   r(   r   Ú_classname_decode_convert‹   s    
r/   c                 C  s&   |   d¡}dd dd„ |D ƒ¡ d S )Nr   ó   _r#   c                 s  s   | ]}|d ›  ¡ V  qdS )Ú02xN)Úencode©r    Úxr   r   r   r*   ’   r#   z,_classname_encode_convert.<locals>.<genexpr>)r+   Újoin)Zbad_charactersr)   r   r   r   Ú_classname_encode_convert�   s    
r6   c                 C  sv   | durrt  td| ¡} t | ¡}|durr| d¡\}}| ||… }t| }| d|… | | |d…  } t | ¡}q | S )zù
    Removes spaces around ``<``, ``>``, and ``::`` characters in a classname
    so that they can be matched by string name.

    If ``classname`` is None, this function returns None. Otherwise, it must be
    a string and it returns a string.
    Nz\1r$   )r   ÚsubÚ_classname_regularizeÚ_classname_regularize_typeÚsearchÚspanÚ_root_alias_to_c_primitive)r   ÚmÚstartÚstopÚtokenÚreplacementr   r   r   Úclassname_regularize•   s    
rB   c                 C  s´   |   d¡r| dd…  ¡ }n*|   d¡r8| dd…  ¡ }ntd| › �ƒ‚t |¡durZd}nBt |¡}|du rrd}n*t| d¡ƒ}|dt| d¡ƒ d … }t	 
t|¡}| ¡ |fS )	aG  
    Converts a Python (encoded) classname, such as ``Model_Some_3a3a_Thing``
    into a C++ (decoded) classname, such as ``Some::Thing``.

    C++ classnames can include namespace delimiters (``::``) and template
    arguments (``<`` and ``>``), which have to be translated into
    ``[A-Za-z_][A-Za-z0-9_]*`` for Python. Non-conforming characters and also
    underscores are translated to their hexadecimal equivalents and surrounded
    by underscores. Additionally, Python models of C++ classes are prepended
    with ``Model_`` (or ``Unknown_`` if a streamer isn't found).
    ÚUnknown_é   NÚModel_é   znot an encoded classname: r$   r%   )Ú
startswithr2   Ú
ValueErrorÚ_classname_decode_antiversionÚmatchÚ_classname_decode_versionr   r+   r.   Ú_classname_decode_patternr7   r/   Údecode)Úencoded_classnameÚrawÚversionr=   Úoutr   r   r   Úclassname_decode­   s    


rR   Fc                 C  s`   |rdnd}|   |¡r$td| › �ƒ‚|du r0dn
dt|ƒ }|  ¡ }t t|¡}|| ¡  | S )a  
    Converts a C++ (decoded) classname, such as ``Some::Thing`` into a Python
    classname (encoded), such as ``Model_Some_3a3a_Thing``.

    If ``version`` is a number such as ``2``, the Python name is suffixed by
    version, such as ``Model_Some_3a3a_Thing_v2``.

    If ``unknown`` is True, the ``Model_`` prefix becomes ``Unknown_``.

    C++ classnames can include namespace delimiters (``::``) and template
    arguments (``<`` and ``>``), which have to be translated into
    ``[A-Za-z_][A-Za-z0-9_]*`` for Python. Non-conforming characters and also
    underscores are translated to their hexadecimal equivalents and surrounded
    by underscores. Additionally, Python models of C++ classes are prepended
    with ``Model_`` (or ``Unknown_`` if a streamer isn't found).
    rC   rE   zclassname is already encoded: NÚ Ú_v)rG   rH   Ústrr2   Ú_classname_encode_patternr7   r6   rM   )r   rP   ÚunknownÚprefixÚvrO   rQ   r   r   r   Úclassname_encodeÎ   s    
rZ   c                 C  sB   |   ¡ }t |¡durdS t |¡}|du r0dS t| d¡ƒS dS )zî
    Extracts a version number from a Python (encoded) classname, if it has one.

    For example, ``Model_Some_3a3a_Thing_v2`` returns ``2``.

    A name without a version number, such as ``Model_Some_3a3a_Thing``, returns
    None.
    Nr$   )r2   rI   rJ   rK   r   r+   )rN   rO   r=   r   r   r   Úclassname_versionê   s    	
r[   c                 C  sŠ   |du rt j}d}nd}| | ¡}|du r>td| › d|› �ƒ‚|dur‚t|tƒr‚| |¡}|durf|S td| › d|› d|› �ƒ‚n|S dS )aA  
    Returns a class with a given C++ (decoded) classname.

    If ``version`` is None, no attempt is made to find a specific version.

    * If the class is a :doc:`uproot.model.DispatchByVersion`, then this is
      object returned.
    * If the class is a versionless model, then this is the object returned.

    If ``version`` is an integer, an attempt is made to find the specific
    version.

    * If the class is a :doc:`uproot.model.DispatchByVersion`, then it is
      queried for a versioned model.
    * If the class is a versionless model, then this is the object returned.

    If ``custom_classes`` are provided, then these are searched (exclusively)
    for the class. If ``custom_classes`` is None, then ``uproot.classes`` is
    used.

    No classes are created if a class is not found (an error is raised).
    Nzthe 'custom_classes' dictzuproot.classeszno class named z in z with version )r
   r	   ÚgetrH   Ú
isinstanceÚDispatchByVersionÚclass_of_version)r   rP   r   r	   ÚwhereÚclsÚversioned_clsr   r   r   Úclass_namedþ   s    

ÿrc   c                 C  s@   t | |ƒ | ¡}|du rdS |dur8t|tƒr8| |¡S dS dS )zw
    Returns True if :doc:`uproot.model.class_named` would find a class,
    False if it would raise an exception.
    NFT)Úmaybe_custom_classesr\   r]   r^   Úhas_version)r   rP   r   ra   r   r   r   Úhas_class_named,  s    
rf   c                 C  s   |du s| t v rtjS |S dS )z¿
    Passes through ``custom_classes`` if it is not None; returns
    ``uproot.classes`` otherwise.

    Some ``classnames`` are never custom (see ``uproot.model.never_from_streamers``).
    N)Únever_from_streamersr
   r	   )r   r   r   r   r   rd   ;  s    rd   c                   @  sÐ  e Zd ZdZg Zg Zi ZdZdZdZ	dZ
dZdZdd„ Z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dd„ Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd „ ƒZdXd"d#„ZdYd$d%„Zed&d'„ ƒZd(d)„ Zd*d+„ Z ed,d-„ ƒZ!ed.d/„ ƒZ"ed0d1„ ƒZ#e$d2d3„ ƒZ%e$dZd4d5„ƒZ&d6d7„ Z'e$d8d9„ ƒZ(e$d[d:d;„ƒZ)d<d=„ Z*d>d?„ Z+d@dA„ Z,dBdC„ Z-dDdE„ Z.dFdG„ Z/dHdI„ Z0dJdK„ Z1dLdM„ Z2dNdO„ Z3dPdQ„ Z4dRdS„ Z5d\dTdU„Z6d]dVdW„Z7dS )^ÚModelaH	  
    Abstract class for all objects extracted from ROOT files (except for
    :doc:`uproot.reading.ReadOnlyFile`, :doc:`uproot.reading.ReadOnlyDirectory`,
    and :doc:`uproot.reading.ReadOnlyKey`).

    A model is instantiated from a file using the :ref:`uproot.model.Model.read`
    classmethod or synthetically using the :ref:`uproot.model.Model.empty`
    classmethod, not through a normal constructor.

    Models point back to the file from which they were created, though only a
    few classes (named in ``uproot.reading.must_be_attached``) have an open,
    readable file attached; the rest have a :doc:`uproot.reading.DetachedFile`
    with information about the file, while not holding the file open.

    Uproot recognizes *some* of ROOT's thousands of classes, by way of methods
    and properties defined in :doc:`uproot.behaviors`. Examples include

    * :doc:`uproot.behaviors.TTree.TTree`
    * :doc:`uproot.behaviors.TH1.TH1`

    These classes are the most convenient to work with and have specialized
    documentation.

    Classes that don't have any predefined behaviors are still usable through
    their member data.

    * :ref:`uproot.model.Model.members`: a dict of C++ member names and values
      directly in this class.
    * :ref:`uproot.model.Model.all_members`: a dict of C++ member names and
      values in this class or any superclasses.
    * :ref:`uproot.model.Model.member`: method that takes a C++ member name
      and returns its value (from this or any superclass).
    * :ref:`uproot.model.Model.has_member`: method that takes a C++ member
      name and returns True if it exists (in this or any superclass), False
      otherwise.

    Accessing a data structure through its C++ members may be a prelude to
    adding custom behaviors for it. Before we know what conveniences to add, we
    need to know how they'll be used: this information comes from the user
    community.

    Pythonic models don't follow the same class inheritance tree as their C++
    counterparts: most of them are direct subclasses of
    :doc:`uproot.model.Model`, :doc:`uproot.model.DispatchByVersion`, or
    :doc:`uproot.model.VersionedModel`. To separate an object's members
    from its superclass members, a model instance is created for each and
    the superclass parts are included in a list called
    :ref:`uproot.model.Model.bases`.
    Nr   Fc                 C  s<   | j d u rd}nd| j › d�}d| j› |› dt| ƒd›d�S )NrS   z
 (version ú)ú<ú at 0xÚ012xú>)Úclass_versionr   Úid)ÚselfrP   r   r   r   Ú__repr__…  s    
zModel.__repr__c                 C  s    t | jtjjƒr| jj ¡  | S ©N)r]   Ú_filer
   ÚreadingÚReadOnlyFileÚsourceÚ	__enter__©rp   r   r   r   rw   Œ  s    zModel.__enter__c                 C  s&   t | jtjjƒr"| jj |||¡ d S rr   )r]   rs   r
   rt   ru   rv   Ú__exit__)rp   Zexception_typeZexception_valueÚ	tracebackr   r   r   ry   ‘  s    zModel.__exit__c                 C  s   t | jƒd S )z×
        The C++ (decoded) classname of the modeled class.

        See :doc:`uproot.model.classname_decode`,
        :doc:`uproot.model.classname_encode`, and
        :doc:`uproot.model.classname_version`.
        r   ©rR   rN   rx   r   r   r   r   •  s    	zModel.classnamec                 C  s
   t | ƒjS )a  
        The Python (encoded) classname of the modeled class. May or may not
        include version.

        See :doc:`uproot.model.classname_decode`,
        :doc:`uproot.model.classname_encode`, and
        :doc:`uproot.model.classname_version`.
        )ÚtypeÚ__name__rx   r   r   r   rN      s    
zModel.encoded_classnamec                 C  s   t | jƒd S )zë
        The version number of the modeled class (int) if any; None otherwise.

        See :doc:`uproot.model.classname_decode`,
        :doc:`uproot.model.classname_encode`, and
        :doc:`uproot.model.classname_version`.
        r$   r{   rx   r   r   r   rn   ¬  s    	zModel.class_versionc                 C  s   | j S )z–
        A cursor pointing to the start of this instance in the byte stream
        (before :ref:`uproot.model.Model.read_numbytes_version`).
        )Ú_cursorrx   r   r   r   Úcursor·  s    zModel.cursorc                 C  s   | j S )zã
        A :doc:`uproot.reading.ReadOnlyFile`, which may be open and readable,
        or a :doc:`uproot.reading.DetachedFile`, which only contains
        information about the original file (not an open file handle).
        )rs   rx   r   r   r   Úfile¿  s    z
Model.filec                 C  s   t | jtjjƒr| j ¡  dS )zœ
        Closes the file from which this object is derived, if such a file is
        still attached (i.e. not :doc:`uproot.reading.DetachedFile`).
        N)r]   rs   r
   rt   ru   Úcloserx   r   r   r   r�   È  s    zModel.closec                 C  s    t | jtjjƒr| jjS dS dS )zÖ
        True if the associated file is known to be closed; False if it is known
        to be open. If the associated file is detached
        (:doc:`uproot.reading.DetachedFile`), then the value is None.
        N)r]   rs   r
   rt   ru   Úclosedrx   r   r   r   r‚   Ð  s    zModel.closedc                 C  s   | j S )zž
        The object that was deserialized before this one in recursive descent,
        usually the containing object (or the container's container).
        )Ú_parentrx   r   r   r   ÚparentÜ  s    zModel.parentc                 C  s   | j du r| S | j S )aT  
        The Python instance corresponding to the concrete (instantiated) class
        in C++, which is ``self`` if this is the concrete class or another
        object if this is actually a holder of superclass members for that other
        object (i.e. if this object is in the other's
        :ref:`uproot.model.Model.bases`).
        N)Ú	_concreterx   r   r   r   Úconcreteä  s    	
zModel.concretec                 C  s   | j S )z¸
        A dict of C++ member data directly associated with this class (i.e. not
        its superclasses). For all members, see
        :ref:`uproot.model.Model.all_members`.
        )Ú_membersrx   r   r   r   Úmembersñ  s    zModel.membersc                 C  s,   i }| j D ]}| |j¡ q
| | j¡ |S )z˜
        A dict of C++ member data for this class and its superclasses. For only
        direct members, see :ref:`uproot.model.Model.members`.
        )Ú_basesÚupdateÚall_membersr‡   )rp   rQ   Úbaser   r   r   r‹   ú  s
    
zModel.all_membersTc                 C  s:   || j v rdS |r6t| jƒD ]}|j|dd�r dS qdS )z 
        Returns True if calling :ref:`uproot.model.Model.member` with the same
        arguments would return a value; False if the member is missing.
        T©ÚallF)r‡   Úreversedr‰   Ú
has_member)rp   ÚnamerŽ   rŒ   r   r   r   r�     s    
zModel.has_memberc              
   C  s–   || j v r| j | S |rHt| jƒD ]$}|j|dd�r"|j|dd�  S q"|rPdS tj|d t| ƒj	t| ƒj
d dd„ | jD ƒ¡¡t| jddƒd	�‚dS )
a�  
        Args:
            name (str): The name of the member datum to retrieve.
            all (bool): If True, recursively search all superclasses in
                :ref:`uproot.model.Model.bases`. Otherwise, search the
                direct class only.
            none_if_missing (bool): If a member datum doesn't exist in the
                search path, ``none_if_missing=True`` has this function return
                None, but ``none_if_missing=False`` would have it raise an
                exception. Note that None is a possible value for some member
                data.

        Returns a C++ member datum by name.
        Tr�   Nz.{}.{} has only the following members:

    {}
z, c                 s  s   | ]}t |ƒV  qd S rr   )Úreprr3   r   r   r   r*   4  r#   zModel.member.<locals>.<genexpr>Ú	file_path)Zbecauser“   )r‡   r�   r‰   r�   Úmemberr
   ZKeyInFileErrorÚformatr|   Ú
__module__r}   r5   r‹   Úgetattrrs   )rp   r‘   rŽ   Znone_if_missingrŒ   r   r   r   r”     s"    

úözModel.memberc                 C  s   | j S )a  
        List of :doc:`uproot.model.Model` objects representing superclass data
        for this object in the order given in C++ (opposite method resolution
        order).

        * If this object has no superclasses, ``bases`` is empty.
        * If it has one superclass, which itself might have superclasses,
          ``bases`` has length 1.
        * Only if this object *multiply inherits* from more than one superclass
          at the same level does ``bases`` have length greater than 1.

        Since multiple inheritance is usually avoided, ``bases`` rarely has
        length greater than 1. A linear chain of superclasses deriving from
        super-superclasses is represented by ``bases`` containing an object
        whose ``bases`` contains objects.
        )r‰   rx   r   r   r   Úbases9  s    zModel.basesc                   s~   dd„ |D ƒ}t dd„ |D ƒƒ}g }t| dg ƒD ]H‰ tˆ |ƒsTt‡ fdd„|D ƒƒr^| ˆ ¡ tˆ tƒr0| ˆ j|Ž ¡ q0|S )z¿
        Extracts instances from :ref:`uproot.model.Model.bases` by Python class
        type.

        The ``cls`` arguments may be Python classes or C++ classname strings to match.
        c                 S  s   g | ]}t |tƒrt|ƒ‘qS r   ©r]   rU   rB   r3   r   r   r   r"   T  r#   zModel.base.<locals>.<listcomp>c                 s  s   | ]}t |tƒs|V  qd S rr   ©r]   rU   r3   r   r   r   r*   U  r#   zModel.base.<locals>.<genexpr>r‰   c                 3  s   | ]}t ˆ d dƒ|kV  qdS )r   N)r—   ©r    Ún©r4   r   r   r*   Y  s   )Útupler—   r]   ÚanyÚappendrh   ÚextendrŒ   )rp   ra   Ú	cpp_namesÚpy_typesrQ   r   r�   r   rŒ   M  s    ÿ

z
Model.basec                   sZ   dd„ |D ƒ}t dd„ |D ƒƒ}tˆ |ƒs@t‡ fdd„|D ƒƒrDdS tˆ j|Ž ƒdkS dS )	z¶
        Returns True if this object matches a given type in the C++ class hierarchy.

        The ``cls`` arguments may be Python classes or C++ classname strings to match.
        c                 S  s   g | ]}t |tƒrt|ƒ‘qS r   r™   r3   r   r   r   r"   g  r#   z%Model.is_instance.<locals>.<listcomp>c                 s  s   | ]}t |tƒs|V  qd S rr   rš   r3   r   r   r   r*   h  r#   z$Model.is_instance.<locals>.<genexpr>c                 3  s   | ]}ˆ j |kV  qd S rr   )r   r›   rx   r   r   r*   j  r#   Tr   N)rž   r]   rŸ   r.   rŒ   )rp   ra   r¢   r£   r   rx   r   Úis_instancea  s
     zModel.is_instancec                 C  s   | j S )aû  
        Number of bytes expected in the (uncompressed) serialization of this
        instance.

        This value may be None (unknown before reading) or an integer.

        If the value is an integer and the object exists (no exceptions in
        :ref:`uproot.model.Model.read`), then the expected number of bytes
        agreed with the actual number of bytes, and this numer is reliable.

        If this object is re-serialized, it won't necessarily occupy the same
        number of bytes.
        )Ú
_num_bytesrx   r   r   r   Ú	num_byteso  s    zModel.num_bytesc                 C  s   | j S )a…  
        Version of this instance as read from the byte stream.

        If this model is versioned (:doc:`uproot.model.VersionedModel`), the
        ``instance_version`` ought to be equal to the
        :ref:`uproot.model.Model.class_version`.

        If this model is versionless, the ``instance_version`` contains new
        information about the actual version deserialized.
        )Ú_instance_versionrx   r   r   r   Úinstance_version€  s    zModel.instance_versionc                 C  s   | j S )zi
        True if the object was serialized in ROOT's memberwise format; False
        otherwise.
        )Ú_is_memberwiserx   r   r   r   Úis_memberwiseŽ  s    zModel.is_memberwisec                 C  s   t jj t| jƒd ¡‚dS )aj  
        Args:
            cls (subclass of :doc:`uproot.model.Model`): This class.
            file (:doc:`uproot.reading.ReadOnlyFile`): File to use to generate
                :doc:`uproot.model.Model` classes from its
                :ref:`uproot.reading.ReadOnlyFile.streamers` and ``file_path``
                for error messages.
            context (dict): Context for the Form-generation; defaults are
                the remaining arguments below.
            index_format (str): Format to use for indexes of the
                ``awkward.forms.Form``; may be ``"i32"``, ``"u32"``, or
                ``"i64"``.
            header (bool): If True, include header fields of each C++ class.
            tobject_header (bool): If True, include header fields of each ``TObject``
                base class.
            breadcrumbs (tuple of class objects): Used to check for recursion.
                Types that contain themselves cannot be Awkward Arrays because the
                depth of instances is unknown.

        The ``awkward.forms.Form`` to use to put objects of type type in an
        Awkward Array.
        r   N)r
   ÚinterpretationÚobjectsZCannotBeAwkwardrR   r}   )ra   r€   Úcontextr   r   r   Úawkward_form–  s    ÿzModel.awkward_formc                 C  s   t jj t| jƒd ¡‚dS )aò  
        Args:
            cls (subclass of :doc:`uproot.model.Model`): This class.
            file (:doc:`uproot.reading.ReadOnlyFile`): File to use to generate
                :doc:`uproot.model.Model` classes from its
                :ref:`uproot.reading.ReadOnlyFile.streamers` and ``file_path``
                for error messages.
            header (bool): If True, assume the outermost object has a header.
            tobject_header (bool): If True, assume that ``TObjects`` have headers.
            original (None, :doc:`uproot.model.Model`, or :doc:`uproot.containers.Container`): The
                original, non-strided model or container.
            breadcrumbs (tuple of class objects): Used to check for recursion.
                Types that contain themselves cannot be strided because the
                depth of instances is unknown.

        Returns a list of (str, ``numpy.dtype``) pairs to build a
        :doc:`uproot.interpretation.objects.AsStridedObjects` interpretation.
        r   N)r
   r«   r¬   ZCannotBeStridedrR   r}   )ra   r€   ÚheaderÚtobject_headerÚbreadcrumbsÚoriginalr   r   r   Ústrided_interpretation²  s    ÿzModel.strided_interpretationc                 C  sŽ   i }| j D ] }| ¡ }t|tƒr
| |¡ q
| j ¡ D ]H\}}t|tƒrV| ¡ ||< q6t|tj	tj
fƒrv| ¡ ||< q6|||< q6| j|d< |S )z›
        Serializes this object in its ROOT JSON form (as Python lists and dicts,
        which can be passed to ``json.dump`` or ``json.dumps``).
        Z	_typename)r‰   Útojsonr]   ÚdictrŠ   rˆ   Úitemsrh   ÚnumpyÚnumberZndarrayÚtolistr   )rp   rQ   rŒ   ÚtmpÚkrY   r   r   r   r´   Ì  s    




zModel.tojsonc                 C  sD   |   | ¡}d|_d|_d|_d|_i |_g |_d|_d|_d|_	|S )z�
        Creates a model instance (of subclass ``cls``) with no data; all
        required attributes are None or empty.
        NF)
Ú__new__r~   rs   rƒ   r…   r‡   r‰   r¥   r§   r©   )ra   rp   r   r   r   Úemptyà  s    
zModel.emptyc              	   C  sè  |   | ¡}| ¡ |_||_||_||_i |_g |_d|_d|_	d|_
| dd¡}	g |	¢|‘R |d< |j||||d� tj |¡}
|
durªtjjdtj |¡› �ddid	�}| d
d¡�rª|j}| |||¡ |j| }|dkrø|
durø|j |› d�¡ t| tƒ�rª|j	t| jƒk�rª|j	du�rª| |j|j	¡}t|jƒt| jƒk�rª| |jj¡ |	|d< |
du�r||
 |¡ |
 |¡ |j |||||||d�}|
du�r¦|
 !¡  |S | dd¡�r"|jdu �rö|j	|j"k�röd|_	|j}|
du�r"|j# $d¡ n,|j	dk�r"|
du�r|j d¡ | %d¡ | d
d¡�r¬|j&||||d� |
du�rxtj |¡}d|› �|_'|
 |¡ |
 |¡ | (||||¡ |
du�rš|
 !¡  |j)||||d� | *|||¡ |j+||||d� | ,||||¡}|	|d< |S )a  
        Args:
            cls (subclass of :doc:`uproot.model.Model`): Class to instantiate.
            chunk (:doc:`uproot.source.chunk.Chunk`): Buffer of contiguous data
                from the file :doc:`uproot.source.chunk.Source`.
            cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
                that ``chunk``.
            context (dict): Auxiliary data used in deserialization.
            file (:doc:`uproot.reading.ReadOnlyFile`): An open file object,
                capable of generating new :doc:`uproot.model.Model` classes
                from its :ref:`uproot.reading.ReadOnlyFile.streamers`.
            selffile (:doc:`uproot.reading.CommonFileMethods`): A possibly
                :doc:`uproot.reading.DetachedFile` associated with this object.
            parent (None or calling object): The previous ``read`` in the
                recursive descent.
            concrete (None or :doc:`uproot.model.Model` instance): If None,
                this model corresponds to the concrete (instantiated) class in
                C++. Otherwise, this model represents a superclass part of the
                object, and ``concrete`` points to the concrete instance.

        Creates a model instance by reading data from a file.
        NFr±   r   )Úchunkr   r­   r€   zwrong-instance-version ÚoffsetsÚi64)r‘   Úform_detailsrt   Tr   z stream skip
©r†   Ú
in_TBranchéÿÿÿÿz4 stream skip
é   zstart-of-model )-r¼   Úcopyr~   rs   rƒ   r…   r‡   r‰   r¥   r§   r©   r\   Úhook_before_readr
   Ú_awkwardforthÚget_forth_objÚNodeÚget_first_key_numberÚ_indexÚread_numbytes_versionÚpre_coder    Ú
issubclassÚVersionedModelr[   r}   rc   r   Úmove_toÚindexÚadd_nodeÚpush_active_nodeÚreadÚpop_active_nodern   Z	_pre_codeÚpopÚskipÚhook_before_read_membersr‘   Úread_membersÚhook_after_read_membersÚcheck_numbytesÚhook_before_postprocessÚpostprocess)ra   r¾   r   r­   r€   Úselffiler„   r†   rp   Zold_breadcrumbsÚ	forth_objÚforth_stashZ
temp_indexÚlengthZcorrect_clsÚtemp_varÚkeyrQ   r   r   r   rÕ   ò  s¨    

þ
ÿþý
ÿ


ù	



ÿ



ÿÿz
Model.readc                 C  s(   ddl }|j |||¡\| _| _| _dS )a•  
        Args:
            chunk (:doc:`uproot.source.chunk.Chunk`): Buffer of contiguous data
                from the file :doc:`uproot.source.chunk.Source`.
            cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
                that ``chunk``.
            context (dict): Auxiliary data used in deserialization.

        Reads the number of bytes and instance version from the byte stream,
        which is usually 6 bytes (4 + 2). Bits with special meanings are
        appropriately masked out.

        Some types don't have a 6-byte header or handle it differently; in
        those cases, this method should be overridden.
        r   N)Úuproot.deserializationÚdeserializationÚnumbytes_versionr¥   r§   r©   ©rp   r¾   r   r­   r
   r   r   r   rÍ   j  s    üýzModel.read_numbytes_versionc                 C  s   dS )aó  
        Args:
            chunk (:doc:`uproot.source.chunk.Chunk`): Buffer of contiguous data
                from the file :doc:`uproot.source.chunk.Source`.
            cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
                that ``chunk``.
            context (dict): Auxiliary data used in deserialization.
            file (:doc:`uproot.reading.ReadOnlyFile`): An open file object,
                capable of generating new :doc:`uproot.model.Model` classes
                from its :ref:`uproot.reading.ReadOnlyFile.streamers`.

        Reads the member data for this class. The abstract class
        :doc:`uproot.model.Model` has an empty ``read_members`` method; this
        *must* be overridden by subclasses.
        Nr   ©rp   r¾   r   r­   r€   r   r   r   rÚ   ‚  s    zModel.read_membersc                 C  s4   ddl }|j || j|| j| j|t| jddƒ¡ dS )a÷  
        Args:
            chunk (:doc:`uproot.source.chunk.Chunk`): Buffer of contiguous data
                from the file :doc:`uproot.source.chunk.Source`.
            cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
                that ``chunk``.
            context (dict): Auxiliary data used in deserialization.

        Reads nothing; checks the expected number of bytes against the actual
        movement of the ``cursor`` at the end of the object, possibly raising
        a :doc:`uproot.deserialization.DeserializationError` exception.

        If :ref:`uproot.model.Model.num_bytes` is None, this method does
        nothing.

        It is *possible* that a subclass would override this method, but not
        likely.
        r   Nr“   )rå   ræ   Znumbytes_checkr~   r¥   r   r—   rs   rè   r   r   r   rÜ   “  s    ùzModel.check_numbytesc                 C  s   | S )aÜ  
        Args:
            chunk (:doc:`uproot.source.chunk.Chunk`): Buffer of contiguous data
                from the file :doc:`uproot.source.chunk.Source`.
            cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
                that ``chunk``.
            context (dict): Auxiliary data used in deserialization.
            file (:doc:`uproot.reading.ReadOnlyFile`): An open file object,
                capable of generating new :doc:`uproot.model.Model` classes
                from its :ref:`uproot.reading.ReadOnlyFile.streamers`.

        Called for any additional processing after the object has been fully
        read.

        The return value from this method is the object that actually represents
        the ROOT data, which might be a different instance or even a different
        type from this class. The default in :doc:`uproot.model.Model` is to
        return ``self``.

        Note that for versioned models,
        :ref:`uproot.model.VersionedModel.postprocess` is called first, then
        :ref:`uproot.model.DispatchByVersion.postprocess` is called on its
        output, allowing a :doc:`uproot.model.DispatchByVersion` to refine all
        data of its type, regardless of version.
        r   ré   r   r   r   rÞ   ²  s    zModel.postprocessc                 K  s   dS )zc
        Called in :ref:`uproot.model.Model.read`, before any data have been
        read.
        Nr   ©rp   Úkwargsr   r   r   rÇ   Î  s    zModel.hook_before_readc                 K  s   dS )z´
        Called in :ref:`uproot.model.Model.read`, after
        :ref:`uproot.model.Model.read_numbytes_version` and before
        :ref:`uproot.model.Model.read_members`.
        Nr   rê   r   r   r   rÙ   Ô  s    zModel.hook_before_read_membersc                 K  s   dS )z­
        Called in :ref:`uproot.model.Model.read`, after
        :ref:`uproot.model.Model.read_members` and before
        :ref:`uproot.model.Model.check_numbytes`.
        Nr   rê   r   r   r   rÛ   Û  s    zModel.hook_after_read_membersc                 K  s   dS )z¬
        Called in :ref:`uproot.model.Model.read`, after
        :ref:`uproot.model.Model.check_numbytes` and before
        :ref:`uproot.model.Model.postprocess`.
        Nr   rê   r   r   r   rÝ   â  s    zModel.hook_before_postprocessc                 C  s   d S rr   r   )rp   r²   r   r   r   Ú_to_writable_postprocessé  s    zModel._to_writable_postprocessc           	      C  sF  d }| j rt| ƒ}nJtj | j¡}t|tƒrL|j 	¡ D ]}|j r6|} q^q6n|d ur^|j r^|}|d u rxt
d| j› �ƒ‚nÊ| |¡}| j|_| j|_| j|_||_| j|_t|jƒd |_| j|_|d u rÌ|}g |_| jD ]}|j | |¡¡ qØi |_| j ¡ D ]2\}}t|tƒ�r&| d ¡|j|< n
||j|< �q | | ¡ |S d S )Nz this ROOT type is not writable: r$   )Úwritabler|   r
   r	   r\   r   rÏ   r^   Úknown_versionsÚvaluesÚNotImplementedErrorr¼   r~   rs   rƒ   r…   r¥   rR   r}   r§   r©   r‰   r    Ú_to_writabler‡   r¶   r]   rh   rì   )	rp   r†   ra   Zunversionedrb   rQ   rŒ   rä   Úvaluer   r   r   rñ   ì  sF    


ÿ


zModel._to_writablec                 C  s   | j r
| S |  d¡S dS )a  
        Args:
            obj (:doc:`uproot.model.Model` instance of the same C++ class): The
                object to convert to this class version.

        Returns a writable version of this object or raises a NotImplementedError
        if no writable version exists.
        N)Ú_deeply_writablerñ   rx   r   r   r   Úto_writable  s    	zModel.to_writablec                 C  s   t dt| ƒj› d�ƒ‚d S )Nzcan't write z3 instances yet ('serialize' method not implemented))rð   r|   r}   )rp   rQ   r¯   r‘   Ztobject_flagsr   r   r   Ú
_serialize(  s    ÿzModel._serializec                 C  s$   g }|   |d|t d¡¡ d |¡S )a  
        Serialize a object (from num_bytes and version onward) for writing into
        an output ROOT file.

        If a ``name`` is given, override the object's current name.

        This method has not been implemented on all classes (raises
        NotImplementedError).
        Tr   r#   )rõ   r·   Zuint32r5   )rp   r‘   rQ   r   r   r   Ú	serialize-  s    
zModel.serializec                 C  s   t jj| |d�S )ar  
        Args:
            name (str or None): A name for the new PyROOT object.

        Converts this :doc:`uproot.model.Model` into a PyROOT object *if it is writable*.
        A minority of Uproot models are writable, mostly just histograms. Writability
        is necessary for conversion to PyROOT because it is serialized through a
        ROOT TMessage.
        )r‘   )r
   ZpyrootÚ	to_pyroot)rp   r‘   r   r   r   r÷   ;  s    
zModel.to_pyroot)T)TF)FTr   N)N)N)N)8r}   r–   Ú__qualname__Ú__doc__Úbase_names_versionsÚmember_namesÚclass_flagsÚ
class_codeÚclass_streamerÚclass_rawstreamersrí   ró   Ú	behaviorsrq   rw   ry   Úpropertyr   rN   rn   r   r€   r�   r‚   r„   r†   rˆ   r‹   r�   r”   r˜   rŒ   r¤   r¦   r¨   rª   Úclassmethodr®   r³   r´   r½   rÕ   rÍ   rÚ   rÜ   rÞ   rÇ   rÙ   rÛ   rÝ   rì   rñ   rô   rõ   rö   r÷   r   r   r   r   rh   H  sŒ   2













&




 ÿ
w.
rh   c                   @  s    e Zd ZdZdd„ Zdd„ ZdS )rÐ   aá  
    A Python class that models a specific version of a ROOT C++ class.

    Classes that inherit directly from :doc:`uproot.model.Model` are versionless,
    classes that inherit from :doc:`uproot.model.VersionedModel` depend on
    version.

    Note that automatically generated :doc:`uproot.model.VersionedModel` classes
    are placed in the ``uproot.dynamic`` namespace. This namespace can generate
    :doc:`uproot.model.DynamicModel` classes on demand in Python 3.7 and above,
    which automatically generated :doc:`uproot.model.VersionedModel` classes
    rely upon to be pickleable. Therefore, ROOT object types without predefined
    :doc:`uproot.model.Model` classes cannot be pickled in Python versions
    before 3.7.
    c              	   C  s:   | j | j| j| j| j| j| j| jdœdd„ | j 	¡ D ƒfS )N)rú   rû   rü   rý   rþ   rÿ   rí   r   c                 S  s(   i | ] \}}|t |tjƒr tƒ n|“qS r   )r]   Ú_LockPlaceholderÚ	lock_type©r    r»   rY   r   r   r   Ú
<dictcomp>e  s
   û
ÿz/VersionedModel.__getstate__.<locals>.<dictcomp>)
rú   rû   rü   rý   rþ   rÿ   rí   r   Ú__dict__r¶   rx   r   r   r   Ú__getstate__Y  s    ø
úõzVersionedModel.__getstate__c                 C  s*   |\}}dd„ |  ¡ D ƒ}| j |¡ d S )Nc                 S  s(   i | ] \}}|t |tƒr t ¡ n|“qS r   )r]   r  Ú	threadingÚLockr  r   r   r   r  q  s   ÿz/VersionedModel.__setstate__.<locals>.<dictcomp>)r¶   r  rŠ   )rp   ÚstateÚ
class_dataÚinstance_datar   r   r   Ú__setstate__o  s
    þzVersionedModel.__setstate__N)r}   r–   rø   rù   r  r  r   r   r   r   rÐ   H  s   rÐ   c                   @  s   e Zd Zee ¡ ƒZdS )r  N)r}   r–   rø   r|   r	  r
  r  r   r   r   r   r  x  s   r  c                   @  sh   e Zd ZdZedd„ ƒZeddd	„ƒZed
d„ ƒZedd„ ƒZedd„ ƒZ	eddd„ƒZ
edd„ ƒZdS )r^   a]  
    A Python class that models all versions of a ROOT C++ class by maintaining
    a dict of :doc:`uproot.model.VersionedModel` classes.

    The :ref:`uproot.model.DispatchByVersion.read` classmethod reads the
    instance version number from the byte stream, backs up the
    :doc:`uproot.source.cursor.Cursor` to the starting position, and invokes
    the appropriate :doc:`uproot.model.VersionedModel`'s ``read`` classmethod.

    If a :doc:`uproot.model.VersionedModel` does not exist for the specified
    version, the ``file``'s ``TStreamerInfo`` is queried to attempt to create
    one, and failing that, an :doc:`uproot.model.UnknownClassVersion` is
    created instead.

    Note that :doc:`uproot.model.DispatchByVersion` is not a subclass of
    :doc:`uproot.model.Model`. Instances of this class are not usable as
    stand-ins for ROOT data.
    c                 C  s"   |  t| jƒd d¡}| ||¡S )a$  
        Args:
            cls (subclass of :doc:`uproot.model.DispatchByVersion`): This class.
            file (:doc:`uproot.reading.ReadOnlyFile`): File to use to generate
                :doc:`uproot.model.Model` classes from its
                :ref:`uproot.reading.ReadOnlyFile.streamers` and ``file_path``
                for error messages.
            context (dict): Context for the Form-generation; defaults are
                ``{"index_format": "i64", "header": False, "tobject_header": True, "breadcrumbs": ()}``.
                See below for context argument descriptions.
            index_format (str): Format to use for indexes of the
                ``awkward.forms.Form``; may be ``"i32"``, ``"u32"``, or
                ``"i64"``.
            header (bool): If True, include headers in the Form's ``"uproot"``
                parameters.
            tobject_header (bool): If True, include headers for ``TObject``
                classes in the Form's ``"uproot"`` parameters.
            breadcrumbs (tuple of class objects): Used to check for recursion.
                Types that contain themselves cannot be Awkward Arrays because the
                depth of instances is unknown.

        The ``awkward.forms.Form`` to use to put objects of type type in an
        Awkward Array.
        r   Úmax)rc   rR   r}   r®   )ra   r€   r­   rb   r   r   r   r®   �  s    zDispatchByVersion.awkward_formFTr   Nc                 C  s(   |  t| jƒd d¡}|j||||d�S )aþ  
        Args:
            cls (subclass of :doc:`uproot.model.DispatchByVersion`): This class.
            file (:doc:`uproot.reading.ReadOnlyFile`): File to use to generate
                :doc:`uproot.model.Model` classes from its
                :ref:`uproot.reading.ReadOnlyFile.streamers` and ``file_path``
                for error messages.
            header (bool): If True, assume the outermost object has a header.
            tobject_header (bool): If True, assume that ``TObjects`` have headers.
            original (None, :doc:`uproot.model.Model`, or :doc:`uproot.containers.Container`): The
                original, non-strided model or container.
            breadcrumbs (tuple of class objects): Used to check for recursion.
                Types that contain themselves cannot be strided because the
                depth of instances is unknown.

        Returns a list of (str, ``numpy.dtype``) pairs to build a
        :doc:`uproot.interpretation.objects.AsStridedObjects` interpretation.
        r   r  )r¯   r°   r±   )rc   rR   r}   r³   )ra   r€   r¯   r°   r±   r²   rb   r   r   r   r³   ­  s    ÿz(DispatchByVersion.strided_interpretationc                 C  s>   | j  |¡}|du r:|dkr:t| j ƒdkr:| j t| j ƒ }|S )zÀ
        Returns the class corresponding to a specified ``version`` if it exists.

        If not, this classmethod returns None. No attempt is made to create a
        missing class.
        Nr   )rî   r\   r.   r  )ra   rP   rQ   r   r   r   r_   È  s    z"DispatchByVersion.class_of_versionc                 C  s
   || j v S )z}
        Returns True if a class corresponding to a specified ``version``
        currently exists; False otherwise.
        )rî   )ra   rP   r   r   r   re   Õ  s    zDispatchByVersion.has_versionc           
      C  sÔ   t | jƒ\}}t|ƒ}| ||¡}|du r6| |d¡}|du rj|jdurjtj |¡}| |¡}|durj|S |dur’| 	|¡}||_
|| j|j< |S tj |¡}	|	du rÌtj 	t||dd�tfi ¡}	|	tj|< |	S dS )aú  
        Uses ``file`` to create a new class for a specified ``version``.

        As a side-effect, this new class is added to ``cls.known_versions``
        (for :ref:`uproot.model.DispatchByVersion.class_of_version` and
        :ref:`uproot.model.DispatchByVersion.has_version`).

        If the ``file`` lacks a ``TStreamerInfo`` for the class, this function
        returns a :doc:`uproot.model.UnknownClassVersion` (adding it to
        ``uproo4.unknown_classes`` if it's not already there).
        Nr  T)rW   )rR   r}   rB   Zstreamer_namedr   r
   r	   r\   r_   Ú	new_classrþ   rî   rn   r   Z_utilrZ   ÚUnknownClassVersion)
ra   r€   rP   r   Ú_ÚstreamerZcls2Zversioned_cls2rb   Zunknown_clsr   r   r   r  Ý  s0    

ý
zDispatchByVersion.new_classc                 C  s.  ddl }|j}	|jj|||dd�\}
}}|  |¡}|j |¡}|dur˜|jjd|j |¡› �ddid�}|j|	 }|j	 
|› d	�¡ | |¡ | |¡ |dur¢nP|dur¸|  ||¡}n:| d
d¡rÒ|  |d¡}n td|› dt| jƒd › d�ƒ‚|  |j|||||||d�||||¡}|du�r*| ¡  |S )aÉ  
        Args:
            cls (subclass of :doc:`uproot.model.DispatchByVersion`): This class.
            chunk (:doc:`uproot.source.chunk.Chunk`): Buffer of contiguous data
                from the file :doc:`uproot.source.chunk.Source`.
            cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
                that ``chunk``.
            context (dict): Auxiliary data used in deserialization.
            file (:doc:`uproot.reading.ReadOnlyFile`): An open file object,
                capable of generating new :doc:`uproot.model.Model` classes
                from its :ref:`uproot.reading.ReadOnlyFile.streamers`.
            selffile (:doc:`uproot.reading.CommonFileMethods`): A possibly
                :doc:`uproot.reading.DetachedFile` associated with this object.
            parent (None or calling object): The previous ``read`` in the
                recursive descent.
            concrete (None or :doc:`uproot.model.Model` instance): If None,
                this model corresponds to the concrete (instantiated) class in
                C++. Otherwise, this model represents a superclass part of the
                object, and ``concrete`` points to the concrete instance.

        Reads the instance version number from the byte stream, backs up the
        :doc:`uproot.source.cursor.Cursor` to the starting position, and
        invokes the appropriate :doc:`uproot.model.VersionedModel`'s ``read``
        classmethod.

        If a :doc:`uproot.model.VersionedModel` does not exist for the
        specified version, the ``file``'s ``TStreamerInfo`` is queried to
        attempt to create one, and failing that, an
        :doc:`uproot.model.UnknownClassVersion` is created instead.
        r   NF)Úmovezdispatch-by-version r¿   rÀ   )rÁ   z stream skip 
rÃ   r  zUnknown version z for class z@ that cannot be skipped because its number of bytes is unknown.
rÂ   )rå   rÌ   ræ   rç   r_   rÈ   rÉ   rÊ   rË   rÎ   r    rÓ   rÔ   r  r\   rH   rR   r}   rÞ   rÕ   rÖ   )ra   r¾   r   r­   r€   rß   r„   r†   r
   Ústart_indexr¦   rP   rª   rb   rà   rá   Zbytes_skippedrã   r   r   r   rÕ     sN     ü
þ


ÿÿù

zDispatchByVersion.readc                 C  s   |S )a-  
        Args:
            cls (subclass of :doc:`uproot.model.DispatchByVersion`): This class.
            chunk (:doc:`uproot.source.chunk.Chunk`): Buffer of contiguous data
                from the file :doc:`uproot.source.chunk.Source`.
            cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
                that ``chunk``.
            context (dict): Auxiliary data used in deserialization.
            file (:doc:`uproot.reading.ReadOnlyFile`): An open file object,
                capable of generating new :doc:`uproot.model.Model` classes
                from its :ref:`uproot.reading.ReadOnlyFile.streamers`.

        Called for any additional processing after the object has been fully
        read.

        The return value from this method is the object that actually represents
        the ROOT data, which might be a different instance or even a different
        type from this class. The default in :doc:`uproot.model.Model` is to
        return ``self``.

        Note that for versioned models,
        :ref:`uproot.model.VersionedModel.postprocess` is called first, then
        :ref:`uproot.model.DispatchByVersion.postprocess` is called on its
        output, allowing a :doc:`uproot.model.DispatchByVersion` to refine all
        data of its type, regardless of version.
        r   )ra   rp   r¾   r   r­   r€   r   r   r   rÞ   `  s    zDispatchByVersion.postprocess)FTr   N)N)r}   r–   rø   rù   r  r®   r³   r_   re   r  rÕ   rÞ   r   r   r   r   r^   |  s    
 ÿ


*Wr^   c                   @  s\   e Zd ZdZedd„ ƒZedd„ ƒZdd„ Zdd	d	dej	fd
d„Z
defdd„Zdd„ Zd	S )ÚUnknownClasszÃ
    Placeholder for a C++ class instance that has no
    :doc:`uproot.model.DispatchByVersion` and no ``TStreamerInfo`` in the
    current :doc:`uproot.reading.ReadOnlyFile` to produce one.
    c                 C  s"   |   ¡ }|du rtdƒ‚n|S dS )ak  
        The ``chunk`` of data associated with the unknown class, referred to by
        a weak reference (to avoid memory leaks in
        :doc:`uproot.model.UnknownClass` objects). If the original ``chunk``
        has been garbage-collected, this raises ``RuntimeError``.

        Primarily useful in the :ref:`uproot.model.UnknownClass.debug` method.
        Nz?the 'chunk' associated with this unknown class has been deleted©Ú_chunkÚRuntimeError©rp   r¾   r   r   r   r¾   †  s    
ÿzUnknownClass.chunkc                 C  s   | j S ©z�
        The auxiliary data used in deserialization.

        Primarily useful in the :ref:`uproot.model.UnknownClass.debug` method.
        ©Ú_contextrx   r   r   r   r­   ˜  s    zUnknownClass.contextc                 C  s   d| j › dt| ƒd›d�S )Nz	<Unknown rk   rl   rm   )r   ro   rx   r   r   r   rq   ¡  s    zUnknownClass.__repr__r   Nc                 C  s2   | j  ¡ }| |¡ |j| j| j||||d� dS ©a  
        Args:
            skip_bytes (int): Number of bytes to skip before presenting the
                remainder of the :doc:`uproot.source.chunk.Chunk`. May be
                negative, to examine the byte stream leading up to the attempted
                instantiation. The default, ``0``, starts where the number
                of bytes and version number would be (just before
                :ref:`uproot.model.Model.read_numbytes_version`).
            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 :doc:`uproot.source.chunk.Chunk`,
                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 byte stream at the point where this instance would have been
        deserialized.

        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
        )r­   Úlimit_bytesÚdtypeÚoffsetÚstreamN©r~   rÆ   rØ   Údebugr¾   r  ©rp   Ú
skip_bytesr  r   r!  r"  r   r   r   r   r$  ¤  s    0

úzUnknownClass.debugc                 C  sT   t  |¡}| j ¡ }| |¡ | j |j|| j¡}|dt	|ƒ|j
 |j
 …  |¡S )a  
        Args:
            skip_bytes (int): Number of bytes to skip before presenting the
                remainder of the :doc:`uproot.source.chunk.Chunk`. May be
                negative, to examine the byte stream leading up to the attempted
                instantiation. The default, ``0``, starts where the number
                of bytes and version number would be (just before
                :ref:`uproot.model.Model.read_numbytes_version`).
            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.model.UnknownClass.debug`, but returns a NumPy array
        for further inspection.
        N©r·   r   r~   rÆ   rØ   r¾   Ú	remainderrÒ   r  r.   ÚitemsizeÚview©rp   r&  r   r   rQ   r   r   r   Údebug_arrayß  s
    


zUnknownClass.debug_arrayc                 C  sR   t  |¡| _|| _| jd ur6| | j| | j¡ ¡ ntd| j	› d|j
› �ƒ‚d S )Nzunknown class zG that cannot be skipped because its number of bytes is unknown
in file )ÚweakrefÚrefr  r  r¥   rØ   Údisplacementr~   rH   r   r“   ré   r   r   r   rÚ   õ  s    

þÿzUnknownClass.read_members)r}   r–   rø   rù   r  r¾   r­   rq   ÚsysÚstdoutr$  Únp_uint8r,  rÚ   r   r   r   r   r    s   

ÿ
;r  c                   @  s\   e Zd ZdZedd„ ƒZedd„ ƒZddddejfdd	„Z	de
fd
d„Zdd„ Zdd„ ZdS )r  z’
    Placeholder for a C++ class instance that has no ``TStreamerInfo`` in the
    current :doc:`uproot.reading.ReadOnlyFile` to produce one.
    c                 C  s"   |   ¡ }|du rtdƒ‚n|S dS )aŒ  
        The ``chunk`` of data associated with the class of unknown version,
        referred to by a weak reference (to avoid memory leaks in
        :doc:`uproot.model.UnknownClassVersion` objects). If the original
        ``chunk`` has been garbage-collected, this raises ``RuntimeError``.

        Primarily useful in the :ref:`uproot.model.UnknownClassVersion.debug`
        method.
        NzJthe 'chunk' associated with this class of unknown version has been deletedr  r  r   r   r   r¾   
  s    ÿzUnknownClassVersion.chunkc                 C  s   | j S r  r  rx   r   r   r   r­     s    zUnknownClassVersion.contextr   Nc                 C  s2   | j  ¡ }| |¡ |j| j| j||||d� dS r  r#  r%  r   r   r   r$  '  s    0

úzUnknownClassVersion.debugc                 C  sT   t  |¡}| j ¡ }| |¡ | j |j|| j¡}|dt	|ƒ|j
 |j
 …  |¡S )a  
        Args:
            skip_bytes (int): Number of bytes to skip before presenting the
                remainder of the :doc:`uproot.source.chunk.Chunk`. May be
                negative, to examine the byte stream leading up to the attempted
                instantiation. The default, ``0``, starts where the number
                of bytes and version number would be (just before
                :ref:`uproot.model.Model.read_numbytes_version`).
            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.model.UnknownClassVersion.debug`, but returns a
        NumPy array for further inspection.
        Nr'  r+  r   r   r   r,  b  s
    


zUnknownClassVersion.debug_arrayc                 C  sZ   t  |¡| _|| _| jd ur6| | j| | j¡ ¡ n td| j	› d| j
› d|j› �ƒ‚d S )Nzclass ú with unknown version zB cannot be skipped because its number of bytes is unknown
in file )r-  r.  r  r  r¥   rØ   r/  r~   rH   r   r§   r“   ré   r   r   r   rÚ   x  s    
þÿz UnknownClassVersion.read_membersc                 C  s"   d| j › d| j› dt| ƒd›d�S )Nrj   r3  rk   rl   rm   )r   r§   ro   rx   r   r   r   rq   †  s    zUnknownClassVersion.__repr__)r}   r–   rø   rù   r  r¾   r­   r0  r1  r$  r2  r,  rÚ   rq   r   r   r   r   r    s   

	ÿ
;r  c                   @  s   e Zd ZdZdd„ ZdS )ÚDynamicModela@  
    A :doc:`uproot.model.VersionedModel` subclass generated by any attempt to
    extract it from the ``uproot.dynamic`` namespace in Python 3.7 and later.

    This dynamically generated model allows ROOT object types without predefined
    :doc:`uproot.model.Model` classes to be pickled in Python 3.7 and later.
    c                   sj   t | ƒ‰ |\}}| ¡ D ]\}}tˆ |ƒstˆ ||ƒ qt‡ fdd„|d D ƒƒˆ j ˆ _| j |¡ d S )Nc                 3  s   | ]}|ˆ j vr|V  qd S rr   )Ú	__bases__r3   ©ra   r   r   r*   š  r#   z,DynamicModel.__setstate__.<locals>.<genexpr>r   )r|   r¶   ÚhasattrÚsetattrrž   r5  r  rŠ   )rp   r  r  r  r»   rY   r   r6  r   r  “  s    
ÿÿzDynamicModel.__setstate__N)r}   r–   rø   rù   r  r   r   r   r   r4  Š  s   r4  )NF)NN)NN)(rù   Ú
__future__r   r   r0  r	  r-  r·   r
   r   rg   r   r2  r   r   r<   Úcompiler8   r5   r9   rV   rI   rK   rL   r/   r6   rB   rR   rZ   r[   rc   rf   rd   rh   rÐ   r  r^   r  r  r4  r   r   r   r   Ú<module>   s€   þ
$ñ
ÿ



!

.
      0    