o
    g                     @   s*   d Z ddlZddlmZ G dd dZdS )zUnitDbl module.    N)_apic                	   @   s   e Zd ZdZdddddddd	d
ZddddZdd Zdd Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zed:d6d7Zd8d9 Zd5S );UnitDblzClass UnitDbl in development.)gMbP?km)   r   )g8~߿?r   )r   rad)g:RFߑ?r   )r   sec)g      N@r   )i  r   )mr   miler   degr   minhourdistanceangletime)r   r   r   c                 C   s0   t j| j|d}t||d  | _|d | _dS )aI  
        Create a new UnitDbl object.

        Units are internally converted to km, rad, and sec.  The only
        valid inputs for units are [m, km, mile, rad, deg, sec, min, hour].

        The field UnitDbl.value will contain the converted value.  Use
        the convert() method to get a specific type of units back.

        = ERROR CONDITIONS
        - If the input units are not in the allowed list, an error is thrown.

        = INPUT VARIABLES
        - value     The numeric value of the UnitDbl.
        - units     The string name of the units the value is in.
        unitsr   r   N)r   check_getitemallowedfloat_value_units)selfvaluer   data r   b/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/UnitDbl.py__init__"   s   zUnitDbl.__init__c                 C   sR   | j |kr| jS tj| j|d}| j |d kr"td|  d| d| j|d  S )a  
        Convert the UnitDbl to a specific set of units.

        = ERROR CONDITIONS
        - If the input units are not in the allowed list, an error is thrown.

        = INPUT VARIABLES
        - units     The string name of the units to convert to.

        = RETURN VALUE
        - Returns the value of the UnitDbl in the requested units as a floating
          point number.
        r   r   z[Error trying to convert to different units.
    Invalid conversion requested.
    UnitDbl: z
    Units:   
r   )r   r   r   r   r   
ValueError)r   r   r   r   r   r   convert7   s   

zUnitDbl.convertc                 C   s   t t| j| jS )z*Return the absolute value of this UnitDbl.)r   absr   r   r   r   r   r   __abs__O   s   zUnitDbl.__abs__c                 C   s   t | j | jS )z*Return the negative value of this UnitDbl.r   r   r   r!   r   r   r   __neg__S      zUnitDbl.__neg__c                 C   s
   t | jS )z$Return the truth value of a UnitDbl.)boolr   r!   r   r   r   __bool__W   s   
zUnitDbl.__bool__c                 C      |  |tjS N)_cmpoperatoreqr   rhsr   r   r   __eq__[      zUnitDbl.__eq__c                 C   r(   r)   )r*   r+   ner-   r   r   r   __ne__^   r0   zUnitDbl.__ne__c                 C   r(   r)   )r*   r+   ltr-   r   r   r   __lt__a   r0   zUnitDbl.__lt__c                 C   r(   r)   )r*   r+   ler-   r   r   r   __le__d   r0   zUnitDbl.__le__c                 C   r(   r)   )r*   r+   gtr-   r   r   r   __gt__g   r0   zUnitDbl.__gt__c                 C   r(   r)   )r*   r+   ger-   r   r   r   __ge__j   r0   zUnitDbl.__ge__c                 C   s   |  |d || j|jS )a[  
        Compare two UnitDbl's.

        = ERROR CONDITIONS
        - If the input rhs units are not the same as our units,
          an error is thrown.

        = INPUT VARIABLES
        - rhs     The UnitDbl to compare against.
        - op      The function to do the comparison

        = RETURN VALUE
        - Returns op(self, rhs)
        compare)checkSameUnitsr   )r   r.   opr   r   r   r*   m   s   zUnitDbl._cmpc                 C   s    |  |d t| j|j | jS )a5  
        Add two UnitDbl's.

        = ERROR CONDITIONS
        - If the input rhs units are not the same as our units,
          an error is thrown.

        = INPUT VARIABLES
        - rhs     The UnitDbl to add.

        = RETURN VALUE
        - Returns the sum of ourselves and the input UnitDbl.
        addr<   r   r   r   r-   r   r   r   __add__      zUnitDbl.__add__c                 C   s    |  |d t| j|j | jS )aF  
        Subtract two UnitDbl's.

        = ERROR CONDITIONS
        - If the input rhs units are not the same as our units,
          an error is thrown.

        = INPUT VARIABLES
        - rhs     The UnitDbl to subtract.

        = RETURN VALUE
        - Returns the difference of ourselves and the input UnitDbl.
        subtractr?   r-   r   r   r   __sub__   rA   zUnitDbl.__sub__c                 C      t | j| | jS )z
        Scale a UnitDbl by a value.

        = INPUT VARIABLES
        - rhs     The scalar to multiply by.

        = RETURN VALUE
        - Returns the scaled UnitDbl.
        r#   r-   r   r   r   __mul__      
zUnitDbl.__mul__c                 C   rD   )z
        Scale a UnitDbl by a value.

        = INPUT VARIABLES
        - lhs     The scalar to multiply by.

        = RETURN VALUE
        - Returns the scaled UnitDbl.
        r#   )r   lhsr   r   r   __rmul__   rF   zUnitDbl.__rmul__c                 C      d| j | jf S )Print the UnitDbl.z%g *%sr   r   r!   r   r   r   __str__   r%   zUnitDbl.__str__c                 C   rI   )rJ   zUnitDbl(%g, '%s')rK   r!   r   r   r   __repr__   r%   zUnitDbl.__repr__c                 C   s   | j | j S )z Return the type of UnitDbl data.)_typesr   r!   r   r   r   type   s   zUnitDbl.typeNc                 C   sL   |du r
t d| j}g }d}	 | ||  }||kr	 |S || |d7 }q)a?  
        Generate a range of UnitDbl objects.

        Similar to the Python range() method.  Returns the range [
        start, stop) at the requested step.  Each element will be a
        UnitDbl object.

        = INPUT VARIABLES
        - start     The starting value of the range.
        - stop      The stop value of the range.
        - step      Optional step to use.  If set to None, then a UnitDbl of
                      value 1 w/ the units of the start is used.

        = RETURN VALUE
        - Returns a list containing the requested UnitDbl values.
        Nr   r   )r   r   append)startstopstepelemsidr   r   r   range   s   
zUnitDbl.rangec                 C   s.   | j |j krtd| d| j  d|j  dS )aI  
        Check to see if units are the same.

        = ERROR CONDITIONS
        - If the units of the rhs UnitDbl are not the same as our units,
          an error is thrown.

        = INPUT VARIABLES
        - rhs     The UnitDbl to check for the same units
        - func    The name of the function doing the check.
        zCannot z  units of different types.
LHS: z
RHS: N)r   r   )r   r.   funcr   r   r   r<      s   
zUnitDbl.checkSameUnitsr)   )__name__
__module____qualname____doc__r   rN   r   r   r"   r$   r'   r/   r2   r4   r6   r8   r:   r*   r@   rC   rE   rH   rL   rM   rO   staticmethodrW   r<   r   r   r   r   r      sJ    !r   )r\   r+   
matplotlibr   r   r   r   r   r   <module>   s    