3
$ßL]Õ  ã               @   s2   d Z ddlZddljZdgZG dd„ dejƒZdS )z2StrConverter module containing class StrConverter.é    NÚStrConverterc               @   s4   e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZdS )	r   a¢  : A matplotlib converter class.  Provides matplotlib conversion
          functionality for string data values.

    Valid units for string are:
    - 'indexed' : Values are indexed as they are specified for plotting.
    - 'sorted'  : Values are sorted alphanumerically.
    - 'inverted' : Values are inverted so that the first value is on top.
    - 'sorted-inverted' :  A combination of 'sorted' and 'inverted'
    c             C   s   dS )a™  : Returns information on how to handle an axis that has string data.

        = INPUT VARIABLES
        - axis     The axis using this converter.
        - unit     The units to use for a axis with string data.

        = RETURN VALUE
        - Returns a matplotlib AxisInfo data structure that contains
          minor/major formatters, major/minor locators, and default
          label information.
        N© )ÚunitÚaxisr   r   úQ/tmp/pip-install-edjban26/matplotlib/matplotlib/testing/jpl_units/StrConverter.pyÚaxisinfo   s    zStrConverter.axisinfoc             C   s¸  t jj| ƒr| S | g krg S |j}||jƒ kr4d}nd}|jƒ  |jƒ }|jƒ }dd„ |D ƒ}|sjg }g }tj	| ƒsz| g} g }x&| D ]}||kr„||kr„|j
|ƒ q„W x"|D ]}|rÀ|j
|ƒ q¬|g}q¬W dg| dg }ttt|ƒƒƒ}d|d< |d d |d< |j|ƒ |j|ƒ |jƒ }	|	j|d |d ƒ |�rN|j|d |d ƒ n|j|d |d ƒ g }
x@| D ]8}d	}|d
7 }||k�sŽt|ƒ‚|
j
||j|ƒ ƒ �qlW |jjdƒ |
S )a™  : Convert value using unit to a float.  If value is a sequence, return
        the converted sequence.

        = INPUT VARIABLES
        - axis     The axis using this converter.
        - value    The value or list of values that need to be converted.
        - unit     The units to use for a axis with Epoch data.

        = RETURN VALUE
        - Returns the value parameter converted to floats.
        TFc             S   s   g | ]}|j ƒ r|j ƒ ‘qS r   )Zget_text)Ú.0Úlr   r   r   ú
<listcomp>D   s    z(StrConverter.convert.<locals>.<listcomp>Ú g      à?r   é   z7This is due to a logic error in the StrConverter class.z6 Please report this error and its message in bugzilla.éÿÿÿÿr   r   r   r   r   )ÚunitsÚConversionInterfaceZ
is_numlikeZaxesZ	get_xaxisZget_major_ticksZget_ticklocsZget_ticklabelsÚnpÚiterableÚappendÚlistÚrangeÚlenZ	set_ticksZset_ticklabelsZget_major_locatorZ
set_boundsZset_xlimZset_ylimÚAssertionErrorÚindexZviewLimÚignore)Úvaluer   r   ZaxZisXAxisZticksÚlabelsZ	newValuesÚvÚlocÚresultÚerrmsgr   r   r   Úconvert%   sX    






zStrConverter.convertc             C   s   dS )aE  : Return the default unit for value, or None.

        = INPUT VARIABLES
        - axis     The axis using this converter.
        - value    The value or list of values that need units.

        = RETURN VALUE
        - Returns the default units to use for value.
        Return the default unit for value, or None.
        Zindexedr   )r   r   r   r   r   Údefault_units€   s    zStrConverter.default_unitsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústaticmethodr   r   r    r   r   r   r   r   
   s   	[)r$   Znumpyr   Zmatplotlib.unitsr   Ú__all__r   r   r   r   r   r   Ú<module>   s   
