Ë
    µ2Úi”  ã                   óÆ  — 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  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«       ej.                  e<    e«       ej.                  ej2                  <    e«       ej.                  e<    e«       ej.                  ej6                  <   y)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ÚtickerÚunitsc                   óL   — e Zd Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zy)ÚStrCategoryConverterc                 ó0  — |€t        d«      ‚t        j                  |«       t        j                  t        j
                  | t        ¬«      «      }|j                  |«        t        j                  |j                  j                  t        g¬«      |«      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
        zMissing category information for StrCategoryConverter; this might be caused by unintendedly mixing categorical and numeric data©Údtype)Úotypes)Ú
ValueErrorr   Ú_validate_unitÚnpÚ
atleast_1dÚarrayÚobjectÚupdateÚ	vectorizeÚ_mappingÚ__getitem__Úfloat)ÚvalueÚunitÚaxisÚvaluess       úJ/var/www/html/acx/venv/lib/python3.12/site-packages/matplotlib/category.pyÚconvertzStrCategoryConverter.convert   st   € ð* ˆ<Üðó ð  ô 	×+Ñ+¨DÔ1ä—‘œrŸx™x¨´VÔ<Ó=ˆà�‰�FÔØFŒr�|‰|˜DŸM™M×5Ñ5¼u¸gÔFÀvÓNÐNó    c                 ó®   — t         j                  | «       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<   sA   € ô( 	×+Ñ+¨DÔ1ô $ D§M¡MÓ2ˆÜ% d§m¡mÓ4ˆÜ�~‰~ V°FÔ;Ð;r   c                 ó´   — |j                   €&|j                  t        | «      «       |j                   S |j                   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_unitsW   sH   € ð" �:‰:ÐØ�N‰Nœ8 D›>Ô*ð �z‰zÐð �J‰J×Ñ˜dÔ#Ø�z‰zÐr   c                 ó:   — t        | d«      st        d| › d�«      ‚y )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_unitn   s3   € ä�t˜ZÔ(ÜØ! $ ð (Gð GóHð Hð )r   N)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   r%   r*   r   © r   r   r   r      sU   „ ØñOó ðOð@ ñ<ó ð<ð4 ñó ðð, ñHó ñHr   r   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)r"   z1Tick at every integer mapping of the string data.c                 ó   — || _         y©zŠ
        Parameters
        ----------
        units_mapping : dict
            Mapping of category names (str) to indices (int).
        N©Ú_units©ÚselfÚunits_mappings     r   Ú__init__zStrCategoryLocator.__init__x   ó   € ð $ˆ�r   c                 óH   — t        | j                  j                  «       «      S ©N)Úlistr6   r   )r8   s    r   Ú__call__zStrCategoryLocator.__call__�   s   € ä�D—K‘K×&Ñ&Ó(Ó)Ð)r   c                 ó   —  | «       S r=   r1   )r8   ÚvminÚvmaxs      r   Útick_valueszStrCategoryLocator.tick_values…   s	   € á‹vˆr   N)r-   r.   r/   Ú__doc__r:   r?   rC   r1   r   r   r"   r"   v   s   „ Ù;ò$ò*ór   r"   c                   ó4   — e Zd ZdZd„ Zdd„Zd„ Zed„ «       Zy)r#   z0String representation of the data at every tick.c                 ó   — || _         yr4   r5   r7   s     r   r:   zStrCategoryFormatter.__init__Œ   r;   r   Nc                 ó,   — | j                  |g«      d   S )Nr   )Úformat_ticks)r8   ÚxÚposs      r   r?   zStrCategoryFormatter.__call__•   s   € à× Ñ  ! Ó% aÑ(Ð(r   c                 óâ   — | j                   j                  «       D ��ci c]  \  }}|| j                  |«      “Œ }}}|D �cg c]  }|j                  t	        |«      d«      ‘Œ c}S c c}}w c c}w )NÚ )r6   ÚitemsÚ_textÚgetÚround)r8   r   ÚkÚvÚ	r_mappingÚvals         r   rH   z!StrCategoryFormatter.format_ticks™   s\   € à26·+±+×2CÑ2CÓ2E×F©$¨!¨Q�Q˜Ÿ
™
 1›Ñ%ÐFˆ	ÑFØ9?Ö@°#�	—‘œe C›j¨"Õ-Ò@Ð@ùó GùÚ@s   žA&Á"A,c                 ó„   — t        | t        «      r| j                  d¬«      } | S 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   rN   zStrCategoryFormatter._textž   s?   € ô �eœUÔ#Ø—L‘L¨'�LÓ2ˆEð ˆô ˜E¤3Ô'Ü˜“JˆEØˆr   r=   )	r-   r.   r/   rD   r:   r?   rH   r0   rN   r1   r   r   r#   r#   Š   s)   „ Ù:ò$ó)òAð
 ñó ñr   r#   c                   ó*   — e Zd Zdd„Zed„ «       Zd„ Zy)r(   Nc                 ó|   — t        «       | _        t        j                  «       | _        |�| j                  |«       yy)z¸
        Create mapping between unique categorical values and integer ids.

        Parameters
        ----------
        data : iterable
            sequence of string values
        N)r   r   Ú	itertoolsÚcountÚ_counterr   )r8   r)   s     r   r:   zUnitData.__init__©   s2   € ô $›ˆŒÜ!Ÿ™Ó)ˆŒØÐØ�K‰K˜Õð r   c                 ó¦   — 	 t        | «       y# t        $ r9 	 t        j                  j	                  | «       Y y# t        t
        f$ r Y Y yw xY ww xY w)zY
        Helper method to check whether a string can be parsed as float or date.
        FT)r   r   ÚdateutilÚparserÚparseÚ	TypeError)rT   s    r   Ú_str_is_convertiblezUnitData._str_is_convertible·   sY   € ð
	Ü�#ŒJð øô ò 	ðÜ—‘×%Ñ% cÕ*ð øô ¤	Ð*ò âðúð	ús$   ‚ Ž	A˜9¹AÁAÁAÁAc                 ó¬  — t        j                  t        j                  |t        ¬«      «      }d}t	        j
                  |«      D ]g  }t        j                  t        t        f|¬«       |r| j                  |«      }|| j                  vsŒFt        | j                  «      | j                  |<   Œi |j                  r|rt        j!                  d«       yyy)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
   Tr[   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_isinstancerZ   rX   rf   r   Únextr`   ÚsizeÚ_logÚinfo)r8   r)   ÚconvertiblerT   s       r   r   zUnitData.updateÆ   sª   € ô �}‰}œRŸX™X d´&Ô9Ó:ˆàˆÜ×'Ñ'¨Ó-ò 	9ˆCä×!Ñ!¤3¬ ,°cÕ:Ùà"×6Ñ6°sÓ;�Ø˜$Ÿ-™-Ò'Ü%)¨$¯-©-Ó%8�—‘˜cÒ"ð	9ð �9Š9™Ü�I‰Ið ?õ @ð %ˆ9r   r=   )r-   r.   r/   r:   r0   rf   r   r1   r   r   r(   r(   ¨   s!   „ óð ñó ðó@r   r(   )rD   Úcollectionsr   Údateutil.parserrb   r^   ÚloggingÚnumpyr   Ú
matplotlibr   r   r   Ú	getLoggerr-   rl   ÚConversionInterfacer   ÚLocatorr"   Ú	Formatterr#   r(   ÚregistryrZ   Ústr_rX   Úbytes_r1   r   r   ú<module>r{      sÉ   ðñ
õ $Û Û Û ã ç *Ñ *ð €w×Ñ˜Ó"€ôYH˜5×4Ñ4ô YHôx˜Ÿ™ô ô(˜6×+Ñ+ô ÷<:@ñ :@ñ| +Ó,€‡�ˆsÑ Ù.Ó0€‡�ˆr�w‰wÑ Ù,Ó.€‡�ˆuÑ Ù0Ó2€‡�ˆr�y‰yÒ r   