
    ;Ph!                     .   d Z ddlmZ ddlmZ ddlmZ  G d d      Z G d de      Z G d	 d
e      Z	 G d de      Z
e
Zd Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      ZddZ G d de      Zy)aY  
Provides classes of simple units that will be used with `.AxesDivider`
class (or others) to determine the size of each Axes. The unit
classes define `get_size` method that returns a tuple of two floats,
meaning relative and absolute sizes, respectively.

Note that this class is nothing more than a simple tuple of two
floats. Take a look at the Divider class to see how these two
values are used.

Once created, the unit classes can be modified by simple arithmetic
operations: addition /subtraction with another unit type or a real number and scaling
(multiplication or division) by a real number.
    )Real)_api)Axesc                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
_Basec                     | |z  S N selfothers     lC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\mpl_toolkits/axes_grid1/axes_size.py__rmul__z_Base.__rmul__   s    e|    c                 F    t        |t              st        S t        ||       S r	   )
isinstancer   NotImplementedFractionr   s     r   __mul__z_Base.__mul__   s    %&!!t$$r   c                     d|z  | z  S )N   r
   r   s     r   __div__z_Base.__div__   s    E	T!!r   c                 d    t        |t              rt        | |      S t        | t        |            S r	   )r   r   AddFixedr   s     r   __add__z_Base.__add__"   s*    eU#tU##tU5\**r   c                     d| z  S )Nr
   )r   s    r   __neg__z_Base.__neg__(   s    Dyr   c                 ,    t        | t        |            S r	   )r   r   r   s     r   __radd__z_Base.__radd__+   s     4u&&r   c                     | | z   S r	   r
   r   s     r   __sub__z_Base.__sub__0   s    vr   c                     t        d      )zJ
        Return two-float tuple with relative and absolute sizes.
        zSubclasses must implement)NotImplementedError)r   renderers     r   get_sizez_Base.get_size3   s     ""=>>r   N)__name__
__module____qualname__r   r   r   r   r   r!   r#   r'   r
   r   r   r   r      s*    %
"+'
?r   r   c                       e Zd ZdZd Zd Zy)r   z
    Sum of two sizes.
    c                      || _         || _        y r	   )_a_b)r   abs      r   __init__zAdd.__init__?   s    r   c                     | j                   j                  |      \  }}| j                  j                  |      \  }}||z   ||z   fS r	   )r-   r'   r.   )r   r&   
a_rel_size
a_abs_size
b_rel_size
b_abs_sizes         r   r'   zAdd.get_sizeC   sI    !%!1!1(!;
J!%!1!1(!;
JJ&
Z(???r   Nr(   r)   r*   __doc__r1   r'   r
   r   r   r   r   :   s    @r   r   c                       e Zd ZdZd Zd Zy)r   zT
    Simple fixed size with absolute part = *fixed_size* and relative part = 0.
    c                 H    t        j                  t        |       || _        y )N
fixed_size)r   check_isinstancer   r<   )r   r<   s     r   r1   zFixed.__init__N   s    dz:$r   c                 &    d}| j                   }||fS N        r;   r   r&   rel_sizeabs_sizes       r   r'   zFixed.get_sizeR   s    ??!!r   Nr7   r
   r   r   r   r   I   s    %"r   r   c                       e Zd ZdZd Zd Zy)Scaledz_
    Simple scaled(?) size with absolute part = 0 and
    relative part = *scalable_size*.
    c                     || _         y r	   _scalable_size)r   scalable_sizes     r   r1   zScaled.__init__^   s
    +r   c                 &    | j                   }d}||fS r?   rG   rA   s       r   r'   zScaled.get_sizea   s    &&!!r   Nr7   r
   r   r   rE   rE   X   s    
,"r   rE   c                 4    | j                         }|dk(  rd}|S )Nauto      ?)
get_aspect)axaspects     r   _get_axes_aspectrQ   i   s    ]]_FMr   c                       e Zd ZdZddZd Zy)AxesXzu
    Scaled size whose relative part corresponds to the data width
    of the *axes* multiplied by the *aspect*.
    Nc                 R    || _         || _        |dk(  r|t        d      || _        y Naxesz%ref_ax must be set when aspect='axes'_axes_aspect
ValueError_ref_axr   rV   rP   ref_axs       r   r1   zAxesX.__init__v   /    
VDEEr   c                     | j                   j                         \  }}| j                  dk(  r.t        | j                        }|t        | j                         z  }n| j                  }t        ||z
        |z  }d}||fS NrV   r@   )rX   get_xlimrY   rQ   r[   absr   r&   l1l2
ref_aspectrP   rB   rC   s           r   r'   zAxesX.get_size}   sq    $$&B<<6!)$,,7J"24::">>F\\Fr"u:f$!!r   rM   Nr7   r
   r   r   rS   rS   p   s    

"r   rS   c                       e Zd ZdZddZd Zy)AxesYzv
    Scaled size whose relative part corresponds to the data height
    of the *axes* multiplied by the *aspect*.
    Nc                 R    || _         || _        |dk(  r|t        d      || _        y rU   rW   r\   s       r   r1   zAxesY.__init__   r^   r   c                     | j                   j                         \  }}| j                  dk(  r+t        | j                        }t        | j                         }n| j                  }t        ||z
        |z  }d}||fS r`   )rX   get_ylimrY   rQ   r[   rb   rc   s           r   r'   zAxesY.get_size   sk    $$&B<<6!)$,,7J%djj1F\\Fr"u:f$!!r   rg   r7   r
   r   r   ri   ri      s    
"r   ri   c                   "    e Zd ZdZd Zd Zd Zy)	MaxExtentzt
    Size whose absolute part is either the largest width or the largest height
    of the given *artist_list*.
    c                 R    || _         t        j                  ddg|       || _        y )Nwidthheight)w_or_h)_artist_listr   check_in_list_w_or_h)r   artist_listrr   s      r   r1   zMaxExtent.__init__   s&    'GX.v>r   c                 :    | j                   j                  |       y r	   )rs   append)r   r/   s     r   
add_artistzMaxExtent.add_artist   s      #r   c                     d}| j                   D cg c]>  }t        |j                  |      | j                        |j                  j
                  z  @ }}t        |d      }||fS c c}w )Nr@   r   )default)rs   getattrget_window_extentru   figuredpimax)r   r&   rB   r/   extent_listrC   s         r   r'   zMaxExtent.get_size   sp     &&(& A''14<<@188<<O& 	 ( {A.!!	(s   AA'N)r(   r)   r*   r8   r1   ry   r'   r
   r   r   rn   rn      s    

$"r   rn   c                   "     e Zd ZdZ fdZ xZS )MaxWidthzS
    Size whose absolute part is the largest width of the given *artist_list*.
    c                 &    t         |   |d       y )Nrp   superr1   r   rv   	__class__s     r   r1   zMaxWidth.__init__   s    g.r   r(   r)   r*   r8   r1   __classcell__r   s   @r   r   r      s    / /r   r   c                   "     e Zd ZdZ fdZ xZS )	MaxHeightzT
    Size whose absolute part is the largest height of the given *artist_list*.
    c                 &    t         |   |d       y )Nrq   r   r   s     r   r1   zMaxHeight.__init__   s    h/r   r   r   s   @r   r   r      s    0 0r   r   c                       e Zd ZdZd Zd Zy)r   zi
    An instance whose size is a *fraction* of the *ref_size*.

    >>> s = Fraction(0.3, AxesX(ax))
    c                 V    t        j                  t        |       || _        || _        y )N)fraction)r   r=   r   _fraction_ref	_fraction)r   r   ref_sizes      r   r1   zFraction.__init__   s!    dX6%!r   c                     | j                   | j                  dfS | j                   j                  |      \  }}|| j                  z  }|| j                  z  }||fS r?   )r   r   r'   )r   r&   rr/   rB   rC   s         r   r'   zFraction.get_size   s^    %>>2%%%%..x8DAq'H'HX%%r   Nr7   r
   r   r   r   r      s    "
&r   r   Nc                     t        | t              rt        |       S t        | t              r#| d   dk(  rt	        t        | dd       dz  |      S t        d      )ac  
    Create a Fixed unit when the first argument is a float, or a
    Fraction unit if that is a string that ends with %. The second
    argument is only meaningful when Fraction unit is created.

    >>> from mpl_toolkits.axes_grid1.axes_size import from_any
    >>> a = from_any(1.2) # => Fixed(1.2)
    >>> from_any("50%", a) # => Fraction(0.5, a)
    r   %Nd   zUnknown format)r   r   r   strr   floatrZ   )sizefraction_refs     r   from_anyr      sV     $T{	D#	8s?E$s),s2LAA
%
&&r   c                   2    e Zd ZdZd d d d dZd Zd Zy	)
_AxesDecorationsSizezT
    Fixed size, corresponding to the size of decorations on a given Axes side.
    c                 4    |j                   | j                   z
  S r	   )xmintight_bbaxes_bbs     r   <lambda>z_AxesDecorationsSize.<lambda>       GLL8==,Hr   c                 4    | j                   |j                   z
  S r	   )xmaxr   s     r   r   z_AxesDecorationsSize.<lambda>       HMMGLL,Hr   c                 4    |j                   | j                   z
  S r	   )yminr   s     r   r   z_AxesDecorationsSize.<lambda>   r   r   c                 4    | j                   |j                   z
  S r	   )ymaxr   s     r   r   z_AxesDecorationsSize.<lambda>   r   r   )leftrightbottomtopc                     t        j                  | j                  |       || _        t	        |t
              r	|g| _        y || _        y )N)	direction)r   rt   _get_size_map
_directionr   r   _ax_list)r   rO   r   s      r   r1   z_AxesDecorationsSize.__init__  s7    4--C# *2t 4"r   c                     t        | j                  D cg c]=  } | j                  | j                     |j	                  |d      |j
                        ? c}      }|j                  d      }||z  }d}||fS c c}w )NF)call_axes_locatorH   r   )r   r   r   r   get_tightbboxbboxpoints_to_pixels)r   r&   rO   szr   rC   rB   s          r   r'   z_AxesDecorationsSize.get_size  s     mm% $ 0Dt/  U CRWWN#% & ''+8!!%s   AA9N)r(   r)   r*   r8   r   r1   r'   r
   r   r   r   r      s'    
 IHHH	M=
"r   r   r	   )r8   numbersr   
matplotlibr   matplotlib.axesr   r   r   r   rE   ScalablerQ   rS   ri   rn   r   r   r   r   r   r
   r   r   <module>r      s       !? !?H@% @"E ""U " "E "4"E "6" "./y /0	 0&u &,'$"5 "r   