3
$ßL]æ  ã               @   s    d Z ddlZG dd„ deƒZdS )zDuration module.é    Nc               @   sÈ   e Zd ZdZddg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$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0S )1ÚDurationz#Class Duration in development.
    ÚETÚUTCc             C   s4   || j kr$d|t| j ƒf }t|ƒ‚|| _|| _dS )a*  Create a new Duration object.

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

        = INPUT VARIABLES
        - frame     The frame of the duration.  Must be 'ET' or 'UTC'
        - seconds  The number of seconds in the Duration.
        z9Input frame '%s' is not one of the supported frames of %sN)ÚallowedÚstrÚ
ValueErrorÚ_frameÚ_seconds)ÚselfÚframeÚsecondsÚmsg© r   úM/tmp/pip-install-edjban26/matplotlib/matplotlib/testing/jpl_units/Duration.pyÚ__init__   s    

zDuration.__init__c             C   s   | j S )z$Return the frame the duration is in.)r   )r
   r   r   r   r      s    zDuration.framec             C   s   t | jt| jƒƒS )z*Return the absolute value of the duration.)r   r   Úabsr	   )r
   r   r   r   Ú__abs__!   s    zDuration.__abs__c             C   s   t | j| j ƒS )z+Return the negative value of this Duration.)r   r   r	   )r
   r   r   r   Ú__neg__%   s    zDuration.__neg__c             C   s   | j S )z-Return the number of seconds in the Duration.)r	   )r
   r   r   r   r   )   s    zDuration.secondsc             C   s
   | j dkS )Nr   )r	   )r
   r   r   r   Ú__bool__-   s    zDuration.__bool__c             C   s   | j |tjƒS )N)Ú_cmpÚoperatorÚeq)r
   Úrhsr   r   r   Ú__eq__0   s    zDuration.__eq__c             C   s   | j |tjƒS )N)r   r   Úne)r
   r   r   r   r   Ú__ne__3   s    zDuration.__ne__c             C   s   | j |tjƒS )N)r   r   Últ)r
   r   r   r   r   Ú__lt__6   s    zDuration.__lt__c             C   s   | j |tjƒS )N)r   r   Úle)r
   r   r   r   r   Ú__le__9   s    zDuration.__le__c             C   s   | j |tjƒS )N)r   r   Úgt)r
   r   r   r   r   Ú__gt__<   s    zDuration.__gt__c             C   s   | j |tjƒS )N)r   r   Úge)r
   r   r   r   r   Ú__ge__?   s    zDuration.__ge__c             C   s   | j |dƒ || j|jƒS )zÙCompare two Durations.

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

        = RETURN VALUE
        - Returns op(self, rhs)
        Úcompare)ÚcheckSameFramer	   )r
   r   Úopr   r   r   r   B   s    
zDuration._cmpc             C   s@   ddl jj}t||jƒr ||  S | j|dƒ t| j| j|j ƒS )a  Add two Durations.

        = ERROR CONDITIONS
        - If the input rhs is not in the same frame, an error is thrown.

        = INPUT VARIABLES
        - rhs     The Duration to add.

        = RETURN VALUE
        - Returns the sum of ourselves and the input Duration.
        r   NÚadd)	Zmatplotlib.testing.jpl_unitsZtestingZ	jpl_unitsÚ
isinstanceZEpochr%   r   r   r	   )r
   r   ÚUr   r   r   Ú__add__O   s
    zDuration.__add__c             C   s    | j |dƒ t| j| j|j ƒS )a*  Subtract two Durations.

        = ERROR CONDITIONS
        - If the input rhs is not in the same frame, an error is thrown.

        = INPUT VARIABLES
        - rhs     The Duration to subtract.

        = RETURN VALUE
        - Returns the difference of ourselves and the input Duration.
        Úsub)r%   r   r   r	   )r
   r   r   r   r   Ú__sub__d   s    zDuration.__sub__c             C   s   t | j| jt|ƒ ƒS )z«Scale a UnitDbl by a value.

        = INPUT VARIABLES
        - rhs     The scalar to multiply by.

        = RETURN VALUE
        - Returns the scaled Duration.
        )r   r   r	   Úfloat)r
   r   r   r   r   Ú__mul__s   s    	zDuration.__mul__c             C   s   t | j| jt|ƒ ƒS )z¬Scale a Duration by a value.

        = INPUT VARIABLES
        - lhs     The scalar to multiply by.

        = RETURN VALUE
        - Returns the scaled Duration.
        )r   r   r	   r-   )r
   Úlhsr   r   r   Ú__rmul__~   s    	zDuration.__rmul__c             C   s   t | j| j| ƒS )z«Divide a Duration by a value.

        = INPUT VARIABLES
        - rhs     The scalar to divide by.

        = RETURN VALUE
        - Returns the scaled Duration.
        )r   r   r	   )r
   r   r   r   r   Ú__div__‰   s    	zDuration.__div__c             C   s   t | j|| j ƒS )z«Divide a Duration by a value.

        = INPUT VARIABLES
        - rhs     The scalar to divide by.

        = RETURN VALUE
        - Returns the scaled Duration.
        )r   r   r	   )r
   r   r   r   r   Ú__rdiv__”   s    	zDuration.__rdiv__c             C   s   d| j | jf S )zPrint the Duration.z%g %s)r	   r   )r
   r   r   r   Ú__str__Ÿ   s    zDuration.__str__c             C   s   d| j | jf S )zPrint the Duration.zDuration('%s', %g))r   r	   )r
   r   r   r   Ú__repr__£   s    zDuration.__repr__c             C   s*   | j |j kr&d|| j |j f }t|ƒ‚dS )aB  Check to see if frames are the same.

        = ERROR CONDITIONS
        - If the frame of the rhs Duration is not the same as our frame,
          an error is thrown.

        = INPUT VARIABLES
        - rhs     The Duration to check for the same frame
        - func    The name of the function doing the check.
        z;Cannot %s Duration's with different frames.
LHS: %s
RHS: %sN)r   r   )r
   r   Úfuncr   r   r   r   r%   §   s    zDuration.checkSameFrameN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r!   r#   r   r*   r,   r.   r0   r1   r2   r3   r4   r%   r   r   r   r   r      s0   r   )r9   r   Úobjectr   r   r   r   r   Ú<module>   s   