
    P/Ph                     @    d Z ddlZddlZddlmZ  G d d          ZdS )zUnitDbl module.    N)_apic            	       L   e Zd ZdZdddddddd	d
ZddddZd Zd Zd Zd Z	d Z
d Z ej        eej                  Z ej        eej                  Z ej        eej                  Z ej        eej                  Z ej        eej                  Z ej        eej                  Zd Z ej        eej                  Z ej        eej                  Zd Z  ej        e ej!                  Z" ej        e ej!                  Z#d Z$d Z%d Z&e'dd            Z(d Z)dS )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                     t          j        | j        |          }t          ||d         z            | _        |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   datas       d/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/testing/jpl_units/UnitDbl.py__init__zUnitDbl.__init__#   sA    " !$,e<<<EDGO,,1g    c                     | j         |k    r| j        S t          j        | j        |          }| j         |d         k    rt          d|  d| d          | j        |d         z  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   s      r   convertzUnitDbl.convert8   s     ;%;!$,e<<<;$q'!! 7-17 7 .37 7 7 8 8 8 {T!W$$r   c                 P    t          t          | j                  | j                  S )z*Return the absolute value of this UnitDbl.)r   absr   r   r   s    r   __abs__zUnitDbl.__abs__P   s    s4;''555r   c                 8    t          | j         | j                  S )z*Return the negative value of this UnitDbl.r   r   r   r&   s    r   __neg__zUnitDbl.__neg__T   s    |T[111r   c                 *    t          | j                  S )z$Return the truth value of a UnitDbl.)boolr   r&   s    r   __bool__zUnitDbl.__bool__X   s    DK   r   c                 Z    |                      |d            || j        |j                  S )zACheck that *self* and *rhs* share units; compare them using *op*.compare)checkSameUnitsr   r   oprhss      r   _cmpzUnitDbl._cmp\   s.    C+++r$+sz***r   c                     |                      ||j                   t           || j        |j                  | j                  S )zACheck that *self* and *rhs* share units; combine them using *op*.)r0   __name__r   r   r   r1   s      r   _binop_unit_unitzUnitDbl._binop_unit_unith   s<    C---rr$+sz22DK@@@r   c                 J    t           || j        |          | j                  S )z'Combine *self* and *scalar* using *op*.r)   )r   r2   scalars      r   _binop_unit_scalarzUnitDbl._binop_unit_scalarp   s"    rr$+v..<<<r   c                 &    | j         dd| j         S )Print the UnitDbl.gz *r   r   r&   s    r   __str__zUnitDbl.__str__w   s    +0004;000r   c                 *    d| j         dd| j         dS )r<   zUnitDbl(r=   z, 'z')r>   r&   s    r   __repr__zUnitDbl.__repr__{   s"    ;$+;;;DK;;;;r   c                 &    | j         | j                 S )z Return the type of UnitDbl data.)_typesr   r&   s    r   typezUnitDbl.type   s    {4;''r   Nc                     |t          d| j                  }g }d}	 | ||z  z   }||k    rn|                    |           |dz  }*|S )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ds         r   rangezUnitDbl.range   sg    $ <1el++D	D ADyyLLOOOFA	 r   c                 j    | 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   r3   funcs      r   r0   zUnitDbl.checkSameUnits   s\     ;#*$$ 2t 2 2%)[2 2%(Z2 2 3 3 3 %$r   )N)*r6   
__module____qualname____doc__r   rC   r   r#   r'   r*   r-   r4   	functoolspartialmethodoperatoreq__eq__ne__ne__lt__lt__le__le__gt__gt__ge__ge__r7   add__add__sub__sub__r:   mul__mul____rmul__r?   rA   rD   staticmethodrM   r0    r   r   r   r   	   s       ''  -
 
G 
 
F  *% % %06 6 62 2 2! ! !+ + +
 %Y$T8;77F$Y$T8;77F$Y$T8;77F$Y$T8;77F$Y$T8;77F$Y$T8;77FA A A
 &i%&6EEG%i%&6EEG= = = &i%&8(,GGG&y&'98<HHH1 1 1< < <( ( (    \B3 3 3 3 3r   r   )rR   rS   rU   
matplotlibr   r   rj   r   r   <module>rl      sn                k3 k3 k3 k3 k3 k3 k3 k3 k3 k3r   