
    h                         S r SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	   " S S\
5      rS	 r " S
 S5      r " S S5      r " S S\5      r " S S\5      r\" 5       r\" 5       \\'   g)aQ  
The classes here provide support for using custom classes with
Matplotlib, e.g., those that do not expose the array interface but know
how to convert themselves to arrays.  It also supports classes with
units and units conversion.  Use cases include converters for custom
objects, e.g., a list of datetime objects, as well as for objects that
are unit aware.  We don't assume any particular units implementation;
rather a units implementation must register with the Registry converter
dictionary and provide a `ConversionInterface`.  For example,
here is a complete implementation which supports plotting with native
datetime objects::

    import matplotlib.units as units
    import matplotlib.dates as dates
    import matplotlib.ticker as ticker
    import datetime

    class DateConverter(units.ConversionInterface):

        @staticmethod
        def convert(value, unit, axis):
            "Convert a datetime value to a scalar or array."
            return dates.date2num(value)

        @staticmethod
        def axisinfo(unit, axis):
            "Return major and minor tick locators and formatters."
            if unit != 'date':
                return None
            majloc = dates.AutoDateLocator()
            majfmt = dates.AutoDateFormatter(majloc)
            return units.AxisInfo(majloc=majloc, majfmt=majfmt, label='date')

        @staticmethod
        def default_units(x, axis):
            "Return the default unit for x or None."
            return 'date'

    # Finally we register our object type with the Matplotlib units registry.
    units.registry[datetime.date] = DateConverter()
    )Decimal)NumberN)ma)cbookc                       \ rS rSrSrg)ConversionError4    N)__name__
__module____qualname____firstlineno____static_attributes__r
       B/var/www/html/env/lib/python3.13/site-packages/matplotlib/units.pyr   r   4   s    r   r   c                 &   [         R                  " U 5      (       aK  U  HD  nU[        R                  L a  M  [	        U[
        5      =(       a    [	        U[        5      (       + s  $    g[	        U [
        5      =(       a    [	        U [        5      (       + $ )zi
Return whether *x* is of a type that Matplotlib natively supports or an
array of objects of such types.
N)npiterabler   masked
isinstancer   r   )xthisxs     r   _is_natively_supportedr   8   sd     
{{1~~E		!eV,OZw5O1OO 
 !V$CZ7-C)CCr   c                   (    \ rS rSrSr   SS jrSrg)AxisInfoH   z
Information to support default axis labeling, tick labeling, and limits.

An instance of this class must be returned by
`ConversionInterface.axisinfo`.
Nc                 L    Xl         X l        X0l        X@l        XPl        X`l        g)a  
Parameters
----------
majloc, minloc : Locator, optional
    Tick locators for the major and minor ticks.
majfmt, minfmt : Formatter, optional
    Tick formatters for the major and minor ticks.
label : str, optional
    The default axis label.
default_limits : optional
    The default min and max limits of the axis if no data has
    been plotted.

Notes
-----
If any of the above are ``None``, the axis will simply use the
default value.
N)majlocminlocmajfmtminfmtlabeldefault_limits)selfr   r   r    r!   r"   r#   s          r   __init__AxisInfo.__init__O   s#    * 
,r   )r#   r"   r    r   r!   r   )NNNNNN)r   r   r   r   __doc__r%   r   r
   r   r   r   r   H   s     ,015 $-r   r   c                   H    \ rS rSrSr\S 5       r\S 5       r\S 5       rSr	g)ConversionInterfacel   z
The minimal interface for a converter to take custom data types (or
sequences) and convert them to values Matplotlib can use.
c                     g)z<Return an `.AxisInfo` for the axis with the specified units.Nr
   )unitaxiss     r   axisinfoConversionInterface.axisinfor        r   c                     g)z?Return the default unit for *x* or ``None`` for the given axis.Nr
   )r   r-   s     r   default_units!ConversionInterface.default_unitsw   r0   r   c                     U $ )z
Convert *obj* using *unit* for the specified *axis*.

If *obj* is a sequence, return the converted sequence.  The output must
be a sequence of scalars that can be used by the numpy array layer.
r
   )objr,   r-   s      r   convertConversionInterface.convert|   s	     
r   r
   N)
r   r   r   r   r'   staticmethodr.   r2   r6   r   r
   r   r   r)   r)   l   sC    
      r   r)   c                   (    \ rS rSrSr\S 5       rSrg)DecimalConverter   z,Converter for decimal.Decimal data to float.c                     [        U [        5      (       a  [        U 5      $ [        U [        R                  5      (       a  [        R
                  " U [        S9$ [        R
                  " U [        S9$ )z
Convert Decimals to floats.

The *unit* and *axis* arguments are not used.

Parameters
----------
value : decimal.Decimal or iterable
    Decimal or list of Decimal need to be converted
dtype)r   r   floatr   MaskedArrayasarrayr   )valuer,   r-   s      r   r6   DecimalConverter.convert   sN     eW%%<r~~..::e511::e511r   r
   N)r   r   r   r   r'   r8   r6   r   r
   r   r   r:   r:      s    62 2r   r:   c                       \ rS rSrSrS rSrg)Registry   z)Register types with conversion interface.c                 X   [         R                  " U5      n[        U[        R                  5      (       am  [        R
                  R                  U5      R                  5       nUR                  (       d/  U R                  [        R                  " S/UR                  S95      $ [        U5      R                   H  n X   s  $     [         R                  " U5      n[        U5      [        U5      La  U R                  U5      $  g! [         a     MZ  f = f! [         ["        4 a     gf = f)z6Get the converter interface instance for *x*, or None.r   r=   N)r   _unpack_to_numpyr   r   ndarrayr   getdataravelsizeget_converterarrayr>   type__mro__KeyError_safe_first_finite	TypeErrorStopIteration)r$   r   clsfirsts       r   rM   Registry.get_converter   s     ""1%a$$ a &&(A66))"((A3agg*FGG7??Cy  #
	1,,Q/E E{$q')))%00 *   =) 	 	s$   <DD 
DDD)(D)r
   N)r   r   r   r   r'   rM   r   r
   r   r   rE   rE      s
    3r   rE   )r'   decimalr   numbersr   numpyr   r   
matplotlibr   rS   r   r   r   r)   r:   dictrE   registryr
   r   r   <module>r^      ss   (T     	i 	D !- !-H 62* 24t B :$& r   