a
    zn„f·  ã                   @  s:   d Z ddlmZ ddlZddlZG dd„ dejjjƒZdS )zq
This module defines the behaviors of ``TH2`` and its subclasses (not including
``TProfile2D`` and ``TH2Poly``).
é    )ÚannotationsNc                   @  sX   e Zd ZdZejjjfZedd„ ƒZ	dd„ Z
edd„ ƒZdd	d
„Zdd„ Zddd„ZdS )ÚTH2zƒ
    Behaviors for two-dimensional histograms: descendants of ROOT's
    ``TH2``, not including ``TProfile2D`` or ``TH2Poly``.
    c                 C  s   |   d¡|   d¡fS )NÚfXaxisÚfYaxis)Úmember©Úself© r	   úW/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/uproot/behaviors/TH2.pyÚaxes   s    zTH2.axesc                 C  sP   |dks|dks|dkr"|   d¡S |dks:|dks:|dkrD|   d¡S td	ƒ‚d S )
Nr   éþÿÿÿÚxr   é   éÿÿÿÿÚyr   z1axis must be 0 (-2), 1 (-1) or 'x', 'y' for a TH2)r   Ú
ValueError)r   Úaxisr	   r	   r
   r      s
    

zTH2.axisc                 C  s   dS )NZCOUNTr	   r   r	   r	   r
   Úkind"   s    zTH2.kindFc                 C  sš   t | dƒr| j}nh|  tjjj¡\}tj||j	 
d¡d�}|  d¡ d¡}|  d¡ d¡}t | |d |d ¡¡}|| _|r‚|S |dd	…dd	…f S d S )
NÚ_valuesú=©Údtyper   ZfNbinsr   é   r   r   )Úhasattrr   ÚbaseÚuprootÚmodelsZTArrayZModel_TArrayÚnumpyÚasarrayr   Únewbyteorderr   Ú	transposeÚreshape)r   ÚflowÚvaluesZxaxis_fNbinsZyaxis_fNbinsr	   r	   r
   r#   &   s    
z
TH2.valuesc              	   C  sô   | j dd�}t| dƒr| j}nžtj|jtjd�}| jddd�}|d ur¢t|ƒ|  d¡kr¢tj	||j
 d¡d�}t t ||jd d d	… ¡¡}|d
k}|| ||< n|d
k}|| ||< || _|rÈ||fS |dd	…dd	…f |dd	…dd	…f fS d S )NT©r"   Ú
_variancesr   ZfSumw2)Znone_if_missingZfNcellsr   r   r   r   )r#   r   r%   r   ZzerosÚshapeZfloat64r   Úlenr   r   r   r    r!   )r   r"   r#   Z	variancesZsumw2Zpositiver	   r	   r
   Ú_values_variances6   s     
zTH2._values_variancesc                 C  sN   | j |d�}|  d¡j|d�}|  d¡j|d�}|r@|||ffS |||fS dS )a´  
        Args:
            flow (bool): If True, include underflow and overflow bins; otherwise,
                only normal (finite-width) bins are included.
            dd (bool): If True, the return type follows
                `numpy.histogramdd <https://numpy.org/doc/stable/reference/generated/numpy.histogramdd.html>`__;
                otherwise, it follows `numpy.histogram <https://numpy.org/doc/stable/reference/generated/numpy.histogram.html>`__
                and `numpy.histogram2d <https://numpy.org/doc/stable/reference/generated/numpy.histogram2d.html>`__.

        Converts the histogram into a form like the ones produced by the NumPy
        histogram functions.
        r$   r   r   N)r#   r   Úedges)r   r"   Úddr#   ZxedgesZyedgesr	   r	   r
   Úto_numpyM   s    zTH2.to_numpyN)F)FF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú	behaviorsÚTH1Z
no_inheritÚpropertyr   r   r   r#   r(   r+   r	   r	   r	   r
   r      s   


r   )	r/   Ú
__future__r   r   r   r0   r1   Z	Histogramr   r	   r	   r	   r
   Ú<module>   s   