Ë
    ¨ehÑ  ã                   ó¬  — 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j0                  e<   xej0                  ej4                  <   xej0                  e<   ej0                  ej8                  <   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ÚcbookÚtickerÚunitsc                   óL   — e Zd Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zy)ÚStrCategoryConverterc                 óh  — |€t        d«      ‚t        j                  |«       t        j                  t        j
                  | t        ¬«      «      }|j                  |«        t        j                  |j                  j                  t        g¬«      |«      }t        j                  | «      s|S |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
        z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        úQ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/matplotlib/category.pyÚconvertzStrCategoryConverter.convert   s�   € ð* ˆ<Üðó ð  ô 	×+Ñ+¨DÔ1ä—‘œrŸx™x¨´VÔ<Ó=ˆà�‰�FÔØCŒB�L‰L˜Ÿ™×2Ñ2¼E¸7ÔCÀFÓKˆÜ×1Ñ1°%Ô8ˆqÐB¸aÀ¹dÐBó    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_unitsX   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_unito   s3   € ä�t˜ZÔ(ÜØ! $ ð (Gð GóHð Hð )r!   N)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr    r(   r-   r   © r!   r   r	   r	      sU   „ ØñCó ðCðB ñ<ó ð<ð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__y   ó   € ð $ˆ�r!   c                 óH   — t        | j                  j                  «       «      S ©N)Úlistr9   r   )r;   s    r   Ú__call__zStrCategoryLocator.__call__‚   s   € ä�D—K‘K×&Ñ&Ó(Ó)Ð)r!   c                 ó   —  | «       S r@   r4   )r;   ÚvminÚvmaxs      r   Útick_valueszStrCategoryLocator.tick_values†   s	   € á‹vˆr!   N)r0   r1   r2   Ú__doc__r=   rB   rF   r4   r!   r   r%   r%   w   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r7   r8   r:   s     r   r=   zStrCategoryFormatter.__init__�   r>   r!   Nc                 ó,   — | j                  |g«      d   S )Nr   )Úformat_ticks)r;   ÚxÚposs      r   rB   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Ú )r9   ÚitemsÚ_textÚgetÚround)r;   r   ÚkÚvÚ	r_mappingÚvals         r   rK   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   rQ   zStrCategoryFormatter._textŸ   s?   € ô �eœUÔ#Ø—L‘L¨'�LÓ2ˆEð ˆô ˜E¤3Ô'Ü˜“JˆEØˆr!   r@   )	r0   r1   r2   rG   r=   rB   rK   r3   rQ   r4   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   )r;   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)rW   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_isinstancer]   r[   ri   r   Únextrc   ÚsizeÚ_logÚinfo)r;   r,   ÚconvertiblerW   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@   )r0   r1   r2   r=   r3   ri   r   r4   r!   r   r+   r+   ©   s!   „ óð ñó ðó@r!   r+   )rG   Úcollectionsr   Údateutil.parserre   ra   ÚloggingÚnumpyr   Ú
matplotlibr   r   r   r   Ú	getLoggerr0   ro   ÚConversionInterfacer	   ÚLocatorr%   Ú	Formatterr&   r+   Úregistryr]   Ústr_r[   Úbytes_r4   r!   r   ú<module>r~      sÉ   ðñ
õ $Û Û Û ã ç 1Ó 1ð €w×Ñ˜Ó"€ôZH˜5×4Ñ4ô ZHôz˜Ÿ™ô ô(˜6×+Ñ+ô ÷<:@ñ :@ñD !5Ó 6ð7€‡�ˆsÑ ð 7Ø	‡N�N�2—7‘7Ñð7à	‡N�N�5ÑØ	‡N�N�2—9‘9Òr!   