
    hS`                     H   S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	J
r
  SSKr\R                  R                  R                  SS9   " S S5      r " S	 S
5      r " S S\5      r\R                  R                  R                  SSSS9   " S S\\
R$                  5      rS rg)aN  
The Colorizer class which handles the data to color pipeline via a
normalization and a colormap.

.. admonition:: Provisional status of colorizer

    The ``colorizer`` module and classes in this file are considered
    provisional and may change at any time without a deprecation period.

.. seealso::

  :doc:`/gallery/color/colormap_reference` for a list of builtin colormaps.

  :ref:`colormap-manipulation` for examples of how to make colormaps.

  :ref:`colormaps` for an in-depth discussion of choosing colormaps.

  :ref:`colormapnorms` for more details about data normalization.

    N)ma)_apicolorscbookscaleartistzcolorizer : `~matplotlib.colorizer.Colorizer` or None, default: None
    The Colorizer object used to map color to data. If None, a Colorizer
    object is created from a *norm* and *cmap*.)colorizer_docc                   r   \ rS rSrSrSS jrS r\S 5       r\R                  S 5       rSS jr
\SS	 j5       rS
 rS rS r\S 5       r\R                  S 5       rSS jrS rS r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       rSrg)	Colorizer&   aq  
Data to color pipeline.

This pipeline is accessible via `.Colorizer.to_rgba` and executed via
the `.Colorizer.norm` and `.Colorizer.cmap` attributes.

Parameters
----------
cmap: colorbar.Colorbar or str or None, default: None
    The colormap used to color data.

norm: colors.Normalize or str or None, default: None
    The normalization used to normalize the data
Nc                     S U l         U R                  U5        S U l        S U l        X l        [
        R                  " S/S9U l        S U l        g )Nchangedsignals)	_cmap	_set_cmap_id_norm_normnormr   CallbackRegistry	callbackscolorbar)selfcmapr   s      F/var/www/html/env/lib/python3.13/site-packages/matplotlib/colorizer.py__init__Colorizer.__init__5   sC    
t
	//D    c                     Uc  Ub;  U R                  X#5        [        U[        R                  5      (       a  [	        S5      eU R                  U5        g)z
Helper for initial scaling.

Used by public functions that create a ScalarMappable and support
parameters *vmin*, *vmax* and *norm*. This makes sure that a *norm*
will take precedence over *vmin*, *vmax*.

Note that this method does not set the norm.
NzPassing a Normalize instance simultaneously with vmin/vmax is not supported.  Please pass vmin/vmax directly to the norm when creating it.)set_clim
isinstancer   	Normalize
ValueErrorautoscale_None)r   r   vminvmaxAs        r   _scale_normColorizer._scale_normA   sP     t/MM$%$ 0 011 => > 	Ar   c                     U R                   $ N)r   r   s    r   r   Colorizer.normW       zzr   c                    [         R                  " [        R                  [        S 4US9  Uc  [        R                  " 5       nO9[        U[        5      (       a$   [        R                  U   n[        U5      " 5       nXR                  L a  g U R                  S L nU(       d/  U R                  R                  R                  U R                  5        Xl        U R                  R                  R#                  SU R$                  5      U l        U(       d  U R%                  5         g g ! [         a-    [        SSR                  [        R                  5       35      S ef = f)Nr   z;Invalid norm str name; the following values are supported: , r   )r   check_isinstancer   r"   strr!   r   _scale_mappingKeyErrorr#   join_auto_norm_from_scaler   r   
disconnectr   r   connectr   )r   r   	scale_clsin_inits       r   r   r-   [   s   v//d;$G<##%Dc""!006	 )35D99))t#II**4==9
		++33I48LLBLLN %   ""&))E,@,@"A!BD s   D$ $7Ec                    [        U[        R                  5      (       a"  UR                  S:X  a  U R	                  XX45      $ [
        R                  " U5      nU(       a  U R                  U5      nU R                  XUS9nU$ )
  
Return a normalized RGBA array corresponding to *x*.

In the normal case, *x* is a 1D or 2D sequence of scalars, and
the corresponding `~numpy.ndarray` of RGBA values will be returned,
based on the norm and colormap set for this Colorizer.

There is one special case, for handling images that are already
RGB or RGBA, such as might have been read from an image file.
If *x* is an `~numpy.ndarray` with 3 dimensions,
and the last dimension is either 3 or 4, then it will be
treated as an RGB or RGBA array, and no mapping will be done.
The array can be `~numpy.uint8`, or it can be floats with
values in the 0-1 range; otherwise a ValueError will be raised.
Any NaNs or masked elements will be set to 0 alpha.
If the last dimension is 3, the *alpha* kwarg (defaulting to 1)
will be used to fill in the transparency.  If the last dimension
is 4, the *alpha* kwarg is ignored; it does not
replace the preexisting alpha.  A ValueError will be raised
if the third dimension is other than 3 or 4.

In either case, if *bytes* is *False* (default), the RGBA
array will be floats in the 0-1 range; if it is *True*,
the returned RGBA array will be `~numpy.uint8` in the 0 to 255 range.

If norm is False, no normalization of the input data is
performed, and it is assumed to be in the range (0-1).

   )alphabytes)	r!   npndarrayndim_pass_image_datar   asarrayr   r   )r   xr?   r@   r   rgbas         r   to_rgbaColorizer.to_rgbax   sh    > a$$1((5?? JJqM		!Ayyuy5r   c                    U R                   S   S:X  a  Uc  SnU R                  [        R                  :X  a  [        R                  " US-  5      nU R                   SS u  pE[        R                  " XES4U R                  S9nXSS2SS2SS24'   XSS2SS2S4'   O!U R                   S   S:X  a  U nO[        S5      eUR                  R                  S	:X  a  [        R                  " [        R                  " U 5      =n5      (       a?  U R                   S   S:X  a  UR                  5       nS
U[        R                  " USS9SS24'   U(       a3  UR                  5       S:  d  UR                  5       S
:  a  [        S5      eU(       a"  US-  R                  [        R                  5      nO`UR                  [        R                  :X  a*  U(       d"  UR                  [        R                  5      S-  nO[        SUR                  -  5      e[        R                  R                  U 5      (       a7  S
U[        R                  " [        R                  R!                  U 5      SS9S4'   U$ )zr
Helper function to pass ndarray of shape (...,3) or (..., 4)
through `to_rgba()`, see `to_rgba()` for docstring.
   r>   N         )shapedtypezThird dimension must be 3 or 4fr   )axisz:Floating point image RGB values must be in the 0..1 range.z9Image RGB array must be uint8 or floating point; found %s)rO   rP   rA   uint8emptyr#   kindanyisnancopymaxminastypefloat32r   	is_maskedgetmaskarray)rF   r?   r@   r   mnxxnanss           r   rD   Colorizer._pass_image_data   s    771:?}ww"(("-772A;DAq	9Bq!RaRxLq!QwKWWQZ1_B=>>88==Cvvbhhqk)d**771:?B./266$Q'*+AA  "> ? ?3h&&rxx0XX!YYrzz*S0 8:<((C D D 55??1;<Brvvbee((+!4a78	r   c                 V    Uc  [        S5      eU R                  R                  U5        g)J
Autoscale the scalar limits on the norm instance using the
current array
N%You must first set_array for mappable)	TypeErrorr   	autoscaler   r'   s     r   rh   Colorizer.autoscale   s)    
 9CDD 			Ar   c                 V    Uc  [        S5      eU R                  R                  U5        g)n
Autoscale the scalar limits on the norm instance using the
current array, changing only limits that are None
Nrf   )rg   r   r$   ri   s     r   r$   Colorizer.autoscale_None   s)    
 9CDD 			  #r   c                     SSK Jn  U R                  SL nUR                  U5      U l        U(       d  U R	                  5         gg)_
Set the colormap for luminance data.

Parameters
----------
cmap : `.Colormap` or str or None
r   )cmN)
matplotlibrp   r   _ensure_cmapr   )r   r   rp   r;   s       r   r   Colorizer._set_cmap   s6     	"**$__T*
LLN r   c                     U R                   $ r+   )r   r,   s    r   r   Colorizer.cmap   r.   r   c                 &    U R                  U5        g r+   )r   r   r   s     r   r   ru      s    tr   c                     Uc   Uu  pUb%  [        R                  " U5      U R                  l        Ub&  [        R                  " U5      U R                  l        gg! [         [        4 a     Ndf = f)z
Set the norm limits for image scaling.

Parameters
----------
vmin, vmax : float
     The limits.

     The limits may also be passed as a tuple (*vmin*, *vmax*) as a
     single positional argument.

     .. ACCEPTS: (vmin: float, vmax: float)
N)rg   r#   r   _sanitize_extremar   r%   r&   r   r%   r&   s      r   r    Colorizer.set_clim   sm      <!
 #55d;DIIN#55d;DIIN 	 z* s   A A.-A.c                 Z    U R                   R                  U R                   R                  4$ zF
Return the values (min, max) that are mapped to the colormap limits.
)r   r%   r&   r,   s    r   get_climColorizer.get_clim  s     yy~~tyy~~--r   c                 H    U R                   R                  S5        SU l        gzl
Call this whenever the mappable is changed to notify all the
callbackSM listeners to the 'changed' signal.
r   TNr   processstaler,   s    r   r   Colorizer.changed  s    
 	y)
r   c                 (    U R                  5       S   $ )Nr   r~   r,   s    r   r%   Colorizer.vmin!      }}q!!r   c                 "    U R                  US9  g )N)r%   r    )r   r%   s     r   r%   r   %      4 r   c                 (    U R                  5       S   $ NrL   r   r,   s    r   r&   Colorizer.vmax)  r   r   c                 "    U R                  US9  g )N)r&   r   )r   r&   s     r   r&   r   -  r   r   c                 .    U R                   R                  $ r+   r   clipr,   s    r   r   Colorizer.clip1  s    yy~~r   c                 $    XR                   l        g r+   r   )r   r   s     r   r   r   5  s    		r   )r   r   r   r   r   r   r   NNNFT)__name__
__module____qualname____firstlineno____doc__r   r(   propertyr   setterrH   staticmethodrD   rh   r$   r   r   r    r~   r   r%   r&   r   __static_attributes__ r   r   r   r   &   s&   
,   
[[ 8'R ( (T		$   
[[ <4. " " 
[[! ! " " 
[[! !   
[[ r   r   c                     ^  \ rS rSrSrS rSS jrS rSS jrU 4S jr	\
S 5       r\R                  S	 5       rS
 rS r\
S 5       r\R                  S 5       rS rS rS r\
S 5       r\R                  S 5       rS rSrU =r$ )_ColorizerInterfacei:  a*  
Base class that contains the interface to `Colorizer` objects from
a `ColorizingArtist` or `.cm.ScalarMappable`.

Note: This class only contain functions that interface the .colorizer
attribute. Other functions that as shared between `.ColorizingArtist`
and `.cm.ScalarMappable` are not included.
c                 P    U R                   R                  XX0R                  5        g r+   )
_colorizerr(   _A)r   r   r%   r&   s       r   r(   _ColorizerInterface._scale_normC  s    ##Dgg>r   c                 6    U R                   R                  XX4S9$ )r=   )r?   r@   r   )r   rH   )r   rF   r?   r@   r   s        r   rH   _ColorizerInterface.to_rgbaF  s    < &&qU&NNr   c                 6    U R                   R                  5       $ r}   )r   r~   r,   s    r   r~   _ColorizerInterface.get_climf  s     ''))r   c                 :    U R                   R                  X5        g)a  
Set the norm limits for image scaling.

Parameters
----------
vmin, vmax : float
     The limits.

     For scalar data, the limits may also be passed as a
     tuple (*vmin*, *vmax*) as a single positional argument.

     .. ACCEPTS: (vmin: float, vmax: float)
N)r   r    rz   s      r   r    _ColorizerInterface.set_climl  s      	  ,r   c                 B   >  [         TU ]  5       $ ! [         a     gf = fr   )super	get_alphaAttributeError)r   	__class__s    r   r   _ColorizerInterface.get_alpha~  s(    	7$&& 		s    
c                 .    U R                   R                  $ r+   r   r   r,   s    r   r   _ColorizerInterface.cmap      ###r   c                 $    XR                   l        g r+   r   rw   s     r   r   r         #r   c                 .    U R                   R                  $ )z Return the `.Colormap` instance.r   r,   s    r   get_cmap_ColorizerInterface.get_cmap  r   r   c                     Xl         g)ro   N)r   rw   s     r   set_cmap_ColorizerInterface.set_cmap  s	     	r   c                 .    U R                   R                  $ r+   r   r   r,   s    r   r   _ColorizerInterface.norm  r   r   c                 $    XR                   l        g r+   r   r   r   s     r   r   r     r   r   c                     Xl         g)a  
Set the normalization instance.

Parameters
----------
norm : `.Normalize` or str or None

Notes
-----
If there are any colorbars using the mappable for this norm, setting
the norm of the mappable will reset the norm, locator, and formatters
on the colorbar to default.
Nr0   r   s     r   set_norm_ColorizerInterface.set_norm  s	     	r   c                 N    U R                   R                  U R                  5        g)re   N)r   rh   r   r,   s    r   rh   _ColorizerInterface.autoscale  s    
 	!!$''*r   c                 N    U R                   R                  U R                  5        g)rl   N)r   r$   r   r,   s    r   r$   "_ColorizerInterface.autoscale_None  s    
 	&&tww/r   c                 .    U R                   R                  $ )z<
The last colorbar associated with this object. May be None
r   r   r,   s    r   r   _ColorizerInterface.colorbar  s    
 '''r   c                 $    XR                   l        g r+   r   )r   r   s     r   r   r     s    #+ r   c                    U R                   R                  n[        R                  R	                  U5      (       a  gU R                  U5      n[        R                  " U5      (       Ga  [        U R
                  [        R                  5      (       a  [        R                  " [        R                  " U R
                  R                  U-
  5      5      n[        SUS-
  5      n[        R                  " U R
                  R                  XTS-    5      R                  5       nOU R
                  R                  U R
                  R                   :X  a.  [        R                  " U R
                  R                  S-  5      nO]U R
                  R#                  [%        X2-  5      [        R&                  " SS/5      -   U-  5      n[        Xq-
  5      R                  5       n[(        R*                  " X5      nOSnSUSU S	3 S
3$ )Nz[]r   rL   rK   g?r>   [z-#.g])r   NrA   r   getmaskr   isfiniter!   r   BoundaryNormargminabs
boundariesrY   diffr%   r&   inverseintarrayr   _g_sig_digits)	r   datar`   normedcur_idx	neigh_idxdelta	neighborsg_sig_digitss	            r   _format_cursor_data_override0_ColorizerInterface._format_cursor_data_override  so    IIKK55==4;;v$))V%8%899))BFF499+?+?$+F$GH7Q;/	II((Q;?#%  499>>1tyy~~23 !II--_rxxA'771<>	I,-113 ..t;LL4L>*+1--r   r   r   r   r   )r   r   r   r   r   r(   rH   r~   r    r   r   r   r   r   r   r   r   rh   r$   r   r   r   __classcell__r   s   @r   r   r   :  s    ?O@*-$ $ $ 
[[$ $$ $ $ 
[[$ $ +0 ( ( __, ,!. !.r   r   c                   j   ^  \ rS rSrSrSSS.U 4S jjjrS rS rS r\	S	 5       r
\	S
 5       rSrU =r$ )_ScalarMappablei  z
A mixin class to map one or multiple sets of scalar data to RGBA.

The ScalarMappable applies data normalization before returning RGBA colors from
the given `~matplotlib.colors.Colormap`.
N	colorizerc                
  > [         TU ]  " S0 UD6  SU l        U R                  X1US9U l        SU l        U R                  R                  R                  SU R                  5      U l	        [        R                  " S/S9U l        g)a  
Parameters
----------
norm : `.Normalize` (or subclass thereof) or str or None
    The normalizing object which scales data, typically into the
    interval ``[0, 1]``.
    If a `str`, a `.Normalize` subclass is dynamically generated based
    on the scale with the corresponding name.
    If *None*, *norm* defaults to a *colors.Normalize* object which
    initializes its scaling based on the first data processed.
cmap : str or `~matplotlib.colors.Colormap`
    The colormap used to map normalized data values to RGBA colors.
N)r   r   r   r   r   r   )r   r   r   _get_colorizerr   r   r   r9   r   _id_colorizerr   r   )r   r   r   r   kwargsr   s        r   r   _ScalarMappable.__init__  sr     	"6"--	SW-X!__66>>y$,,W//Dr   c                 N   Uc  SU l         g[        R                  " USS9n[        R                  " UR
                  [        S5      (       d  [        SUR
                   S35      eXl         U R                  R                  5       (       d  U R                  R                  U5        gg)a  
Set the value array from array-like *A*.

Parameters
----------
A : array-like or None
    The values that are mapped to colors.

    The base class `.ScalarMappable` does not make any assumptions on
    the dimensionality and shape of the value array *A*.
NT)rX   	same_kindzImage data of dtype z cannot be converted to float)r   r   safe_masked_invalidrA   can_castrP   floatrg   r   scaledr   r$   ri   s     r   	set_array_ScalarMappable.set_array  s     9DG%%ad3{{177E;772177) <1 1 2 2 yy!!OO**1- "r   c                     U R                   $ )z
Return the array of values, that are mapped to colors.

The base class `.ScalarMappable` does not make any assumptions on
the dimensionality and shape of the array.
)r   r,   s    r   	get_array_ScalarMappable.get_array4  s     wwr   c                 J    U R                   R                  SU 5        SU l        gr   r   r,   s    r   r   _ScalarMappable.changed=  s    
 	y$/
r   c                     U bc  [        UR                  5        Vs/ s H  o"SLPM     sn5      (       a2  [        SSR                  S UR	                  5        5       5      -   5      eggs  snf )zJ
Raises a ValueError if any kwarg is not None while colorizer is not None
NzZThe `colorizer` keyword cannot be used simultaneously with any of the following keywords: r1   c              3   .   #    U  H  nS U S 3v   M     g7f)`Nr   ).0keys     r   	<genexpr>?_ScalarMappable._check_exclusionary_keywords.<locals>.<genexpr>N  s     ,Q=CqQZ=s   )rV   valuesr#   r6   keys)r   r   vals      r   _check_exclusionary_keywords,_ScalarMappable._check_exclusionary_keywordsE  sm    
  v}}?tO?@@  "I#'99,Q6;;=,Q#Q"R S S A !?s   A(c                 v    [        U[        5      (       a  [        R                  [        XS9  U$ [        X5      $ )Nr   )r!   r   r   r  )r   r   r   s      r   r   _ScalarMappable._get_colorizerP  s:    i++88 9  $$r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   s   @r   r   r     sU    *E$ E E,.2 S S % %r   r   zcmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
    The Colormap instance or registered colormap name used to map scalar data
    to colors.a  norm : str or `~matplotlib.colors.Normalize`, optional
    The normalization method used to scale scalar data to the [0, 1] range
    before mapping to colors using *cmap*. By default, a linear scaling is
    used, mapping the lowest value to 0 and the highest to 1.

    If given, this can be one of the following:

    - An instance of `.Normalize` or one of its subclasses
      (see :ref:`colormapnorms`).
    - A scale name, i.e. one of "linear", "log", "symlog", "logit", etc.  For a
      list of available scales, call `matplotlib.scale.get_scale_names()`.
      In that case, a suitable `.Normalize` subclass is dynamically generated
      and instantiated.a  vmin, vmax : float, optional
    When using scalar data and no explicit *norm*, *vmin* and *vmax* define
    the data range that the colormap covers. By default, the colormap covers
    the complete value range of the supplied data. It is an error to use
    *vmin*/*vmax* when a *norm* instance is given (but using a `str` *norm*
    name together with *vmin*/*vmax* is acceptable).)cmap_docnorm_docvmin_vmax_docc                   f   ^  \ rS rSrSrU 4S jr\S 5       r\R                  S 5       rS r	Sr
U =r$ )ColorizingArtistiw  z
Base class for artists that make map data to color using a `.colorizer.Colorizer`.

The `.colorizer.Colorizer` applies data normalization before
returning RGBA colors from a `~matplotlib.colors.Colormap`.

c                 \   > [         R                  " [        US9  [        TU ]  " SSU0UD6  g)z:
Parameters
----------
colorizer : `.colorizer.Colorizer`
r   r   Nr   )r   r2   r   r   r   )r   r   r   r   s      r   r   ColorizingArtist.__init__  s*     	i9=7977r   c                     U R                   $ r+   )r   r,   s    r   r   ColorizingArtist.colorizer  s    r   c                     [         R                  " [        US9  U R                  R                  R                  U R                  5        Xl        UR                  R                  SU R                  5      U l        g )Nr   r   )	r   r2   r   r   r   r8   r   r9   r   )r   cls     r   r   r    sR    i26!!,,T-?-?@\\11)T\\Jr   c                 6    U R                   " U40 UD6  Xl        g)zK
Raises a ValueError if any kwarg is not None while colorizer is not None.
N)r  r   )r   r   r   s      r   _set_colorizer_check_keywords.ColorizingArtist._set_colorizer_check_keywords  s     	)))>v>"r   )r   r   r   )r   r   r   r   r   r   r   r   r   r  r   r   r   s   @r   r  r  w  sG    8   K K# #r   r  c                     [         R                  " [        R                  " U SS95      " [         R                  5      " 5       n[        U5      $ ! [
         a2    [         R                  " U 5      " [         R                  5      " 5       n NFf = f)a  
Automatically generate a norm class from *scale_cls*.

This differs from `.colors.make_norm_from_scale` in the following points:

- This function is not a class decorator, but directly returns a norm class
  (as if decorating `.Normalize`).
- The scale is automatically constructed with ``nonpositive="mask"``, if it
  supports such a parameter, to work around the difference in defaults
  between standard scales (which use "clip") and norms (which use "mask").

Note that ``make_norm_from_scale`` caches the generated norm classes
(not the instances) and reuses them for later calls.  For example,
``type(_auto_norm_from_scale("log")) == LogNorm``.
mask)nonpositive)r   make_norm_from_scale	functoolspartialr"   rg   type)r:   r   s     r   r7   r7     sz    $ **iV<>   :   **95   s   AA 9B
B)r   r"  numpyrA   r   rq   r   r   r   r   r   mpl
_docstringinterpdregisterr   r   r   Artistr  r7   r   r   r   <module>r+     s   *    9 9      3   Q Qhr. r.jh%) h%V     8'   :!# !#Hr   