§
    õŽ’j¼  ã                   ón  — 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	m
Z
mZmZmZ  ej        e¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d	„ d
ej        ¦  «        Z G d„ d¦  «        Z e¦   «         xej        e<   xej        ej        <   xej        e<   ej        ej        <   dS )a·  
Plotting of string "category" data: ``plot(['d', 'f', 'a'], [1, 2, 3])`` will
plot three points with x-axis values of 'd', 'f', 'a'.

See :doc:`/gallery/lines_bars_and_markers/categorical_variables` for an
example.

The module uses Matplotlib's `matplotlib.units` mechanism to convert from
strings to integers and provides a tick locator, a tick formatter, and the
`.UnitData` class that creates and stores the string-to-integer mapping.
é    )ÚOrderedDictN)Ú_apiÚcbookÚtickerÚunitsc                   óf   — e Zd Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         ZdS )ÚStrCategoryConverterc                 óv  — |€t          d¦  «        ‚t                               |¦  «         t          j        t          j        | t          ¬¦  «        ¦  «        }|                     |¦  «          t          j        |j	        j
        t          g¬¦  «        |¦  «        }t          j        | ¦  «        s|n|d         S )a  
        Convert strings in *value* to floats using mapping information stored
        in the *unit* object.

        Parameters
        ----------
        value : str or iterable
            Value or list of values to be converted.
        unit : `.UnitData`
            An object mapping strings to integers.
        axis : `~matplotlib.axis.Axis`
            The axis on which the converted value is plotted.

            .. note:: *axis* is unused.

        Returns
        -------
        float or `~numpy.ndarray` of float
        NzMissing category information for StrCategoryConverter; this might be caused by unintendedly mixing categorical and numeric data©Údtype)Úotypesr   )Ú
ValueErrorr	   Ú_validate_unitÚnpÚ
atleast_1dÚarrayÚobjectÚupdateÚ	vectorizeÚ_mappingÚ__getitem__Úfloatr   Úis_scalar_or_string)ÚvalueÚunitÚaxisÚvaluesÚss        úAC:\Projects\DSCons\.venv\Lib\site-packages\matplotlib\category.pyÚconvertzStrCategoryConverter.convert   s©   € ð* ˆ<Ýðñ ô  ð  õ 	×+Ò+¨DÑ1Ô1Ð1å”�rœx¨µVÐ<Ñ<Ô<Ñ=Ô=ˆà�Š�FÑÔÐØC�BŒL˜œÔ2½E¸7ÐCÑCÔCÀFÑKÔKˆÝÔ1°%Ñ8Ô8ÐBˆqˆq¸aÀ¼dÐBó    c                 ó²   — t                                | ¦  «         t          | j        ¦  «        }t	          | j        ¦  «        }t          j        ||¬¦  «        S )a´  
        Set the default axis ticks and labels.

        Parameters
        ----------
        unit : `.UnitData`
            object string unit information for value
        axis : `~matplotlib.axis.Axis`
            axis for which information is being set

            .. note:: *axis* is not used

        Returns
        -------
        `~matplotlib.units.AxisInfo`
            Information to support default tick labeling

        )ÚmajlocÚmajfmt)r	   r   ÚStrCategoryLocatorr   ÚStrCategoryFormatterr   ÚAxisInfo)r   r   r#   r$   s       r   ÚaxisinfozStrCategoryConverter.axisinfo=   sM   € õ( 	×+Ò+¨DÑ1Ô1Ð1õ $ D¤MÑ2Ô2ˆÝ% d¤mÑ4Ô4ˆÝŒ~ V°FÐ;Ñ;Ô;Ð;r!   c                 ó˜   — |j         €#|                     t          | ¦  «        ¦  «         n|j                              | ¦  «         |j         S )aO  
        Set and update the `~matplotlib.axis.Axis` units.

        Parameters
        ----------
        data : str or iterable of str
        axis : `~matplotlib.axis.Axis`
            axis on which the data is plotted

        Returns
        -------
        `.UnitData`
            object storing string to integer mapping
        )r   Ú	set_unitsÚUnitDatar   )Údatar   s     r   Údefault_unitsz"StrCategoryConverter.default_unitsX   sE   € ð" Œ:ÐØ�NŠN�8 D™>œ>Ñ*Ô*Ð*Ð*àŒJ×Ò˜dÑ#Ô#Ð#ØŒzÐr!   c                 óL   — t          | d¦  «        st          d| › d�¦  «        ‚d S )Nr   zProvided unit "zU" is not valid for a categorical converter, as it does not have a _mapping attribute.)Úhasattrr   )r   s    r   r   z#StrCategoryConverter._validate_unito   sP   € å�t˜ZÑ(Ô(ð 	HÝðG $ð Gð Gð GñHô Hð Hð	Hð 	Hr!   N)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr    r(   r-   r   © r!   r   r	   r	      s‡   € € € € € ØðCð Cñ „\ðCðB ð<ð <ñ „\ð<ð4 ðð ñ „\ðð, ðHð Hñ „\ðHð Hð Hr!   r	   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )r%   z1Tick at every integer mapping of the string data.c                 ó   — || _         dS ©zŠ
        Parameters
        ----------
        units_mapping : dict
            Mapping of category names (str) to indices (int).
        N©Ú_units©ÚselfÚunits_mappings     r   Ú__init__zStrCategoryLocator.__init__y   ó   € ð $ˆŒˆˆr!   c                 óN   — t          | j                             ¦   «         ¦  «        S ©N)Úlistr9   r   )r;   s    r   Ú__call__zStrCategoryLocator.__call__‚   s   € å�D”K×&Ò&Ñ(Ô(Ñ)Ô)Ð)r!   c                 ó   —  | ¦   «         S r@   r4   )r;   ÚvminÚvmaxs      r   Útick_valueszStrCategoryLocator.tick_values†   s   € àˆt‰vŒvˆr!   N)r0   r1   r2   Ú__doc__r=   rB   rF   r4   r!   r   r%   r%   w   sG   € € € € € Ø;Ð;ð$ð $ð $ð*ð *ð *ðð ð ð ð r!   r%   c                   ó<   — e Zd ZdZd„ Zdd„Zd„ Zed„ ¦   «         ZdS )r&   z0String representation of the data at every tick.c                 ó   — || _         dS r7   r8   r:   s     r   r=   zStrCategoryFormatter.__init__�   r>   r!   Nc                 ó:   — |                       |g¦  «        d         S )Nr   )Úformat_ticks)r;   ÚxÚposs      r   rB   zStrCategoryFormatter.__call__–   s   € à× Ò  ! Ñ%Ô% aÔ(Ð(r!   c                 ól   ‡ ‡— ˆ fd„‰ j                              ¦   «         D ¦   «         Šˆfd„|D ¦   «         S )Nc                 óB   •— i | ]\  }}|‰                      |¦  «        “ŒS r4   )Ú_text)Ú.0ÚkÚvr;   s      €r   ú
<dictcomp>z5StrCategoryFormatter.format_ticks.<locals>.<dictcomp>œ   s)   ø€ ÐFÐFÐF©$¨!¨Q�Q˜Ÿ
š
 1™œÐFÐFÐFr!   c                 óV   •— g | ]%}‰                      t          |¦  «        d ¦  «        ‘Œ&S )Ú )ÚgetÚround)rQ   ÚvalÚ	r_mappings     €r   ú
<listcomp>z5StrCategoryFormatter.format_ticks.<locals>.<listcomp>�   s-   ø€ Ð@Ð@Ð@°#�	—’�e C™jœj¨"Ñ-Ô-Ð@Ð@Ð@r!   )r9   Úitems)r;   r   rZ   s   ` @r   rK   z!StrCategoryFormatter.format_ticksš   sE   øø€ àFÐFÐFÐF°$´+×2CÒ2CÑ2EÔ2EÐFÑFÔFˆ	Ø@Ð@Ð@Ð@¸Ð@Ñ@Ô@Ð@r!   c                 ó¦   — t          | t          ¦  «        r|                      d¬¦  «        } n$t          | t          ¦  «        st          | ¦  «        } | S )z0Convert text values into utf-8 or ascii strings.zutf-8)Úencoding)Ú
isinstanceÚbytesÚdecodeÚstr©r   s    r   rP   zStrCategoryFormatter._textŸ   sM   € õ �e�UÑ#Ô#ð 	Ø—L’L¨'�LÑ2Ô2ˆEˆEÝ˜E¥3Ñ'Ô'ð 	Ý˜‘J”JˆEØˆr!   r@   )	r0   r1   r2   rG   r=   rB   rK   r3   rP   r4   r!   r   r&   r&   ‹   sj   € € € € € Ø:Ð:ð$ð $ð $ð)ð )ð )ð )ðAð Að Að
 ðð ñ „\ðð ð r!   r&   c                   ó2   — e Zd Zdd„Zed„ ¦   «         Zd„ ZdS )r+   Nc                 óŽ   — t          ¦   «         | _        t          j        ¦   «         | _        |�|                      |¦  «         dS dS )z¸
        Create mapping between unique categorical values and integer ids.

        Parameters
        ----------
        data : iterable
            sequence of string values
        N)r   r   Ú	itertoolsÚcountÚ_counterr   )r;   r,   s     r   r=   zUnitData.__init__ª   sD   € õ $™œˆŒÝ!œÑ)Ô)ˆŒØÐØ�KŠK˜ÑÔÐÐÐð Ðr!   c                 ó¼   — 	 t          | ¦  «         nJ# t          $ r= 	 t          j                             | ¦  «         n# t          t
          f$ r Y Y dS w xY wY nw xY wdS )zY
        Helper method to check whether a string can be parsed as float or date.
        FT)r   r   ÚdateutilÚparserÚparseÚ	TypeError)rY   s    r   Ú_str_is_convertiblezUnitData._str_is_convertible¸   s…   € ð
	Ý�#‰JŒJˆJˆJøÝð 	ð 	ð 	ðÝ”×%Ò% cÑ*Ô*Ð*Ð*øÝ¥	Ð*ð ð ð à�u�u�uðøøøð +Ð*ð	øøøð ˆts/   ‚ ’
A�=¼A½AÁAÁAÁAÁAc                 óœ  — t          j        t          j        |t          ¬¦  «        ¦  «        }d}t	          j        |¦  «        D ]`}t          j        t          t          f|¬¦  «         |r|  
                    |¦  «        }|| j        vrt          | j        ¦  «        | j        |<   Œa|j        r|rt                               d¦  «         dS dS dS )zõ
        Map new values to integer identifiers.

        Parameters
        ----------
        data : iterable of str or bytes

        Raises
        ------
        TypeError
            If elements in *data* are neither str nor bytes.
        r   Trc   z½Using categorical units to plot a list of strings that are all parsable as floats or dates. If these strings should be plotted as numbers, cast to the appropriate data type before plotting.N)r   r   r   r   r   Úfromkeysr   Úcheck_isinstancerb   r`   rn   r   Únextrh   ÚsizeÚ_logÚinfo)r;   r,   ÚconvertiblerY   s       r   r   zUnitData.updateÇ   sï   € õ Œ}�RœX dµ&Ð9Ñ9Ô9Ñ:Ô:ˆàˆÝÔ'¨Ñ-Ô-ð 	9ð 	9ˆCåÔ!¥3­ ,°cÐ:Ñ:Ô:Ð:Øð <à"×6Ò6°sÑ;Ô;�Ø˜$œ-Ð'Ð'Ý%)¨$¬-Ñ%8Ô%8�”˜cÑ"øØŒ9ð 	@˜ð 	@Ý�IŠIð ?ñ @ô @ð @ð @ð @ð	@ð 	@ð 	@ð 	@r!   r@   )r0   r1   r2   r=   r3   rn   r   r4   r!   r   r+   r+   ©   sW   € € € € € ðð ð ð ð ðð ñ „\ðð@ð @ð @ð @ð @r!   r+   )rG   Úcollectionsr   Údateutil.parserrj   rf   ÚloggingÚnumpyr   Ú
matplotlibr   r   r   r   Ú	getLoggerr0   rt   ÚConversionInterfacer	   ÚLocatorr%   Ú	Formatterr&   r+   Úregistryrb   Ústr_r`   Úbytes_r4   r!   r   ú<module>rƒ      sž  ðð
ð 
ð $Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ø Ð Ð Ð Ø €€€à Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1ð €wÔ˜Ñ"Ô"€ðZHð ZHð ZHð ZHð ZH˜5Ô4ñ ZHô ZHð ZHðzð ð ð ð ˜œñ ô ð ð(ð ð ð ð ˜6Ô+ñ ô ð ð<:@ð :@ð :@ð :@ð :@ñ :@ô :@ð :@ðD !5Ð 4Ñ 6Ô 6ð7€„ˆsÑ ð 7Ø	„N�2”7Ñð7à	„N�5ÑØ	„N�2”9ÑÐÐr!   