a
    ëÝEb†  ã                   @   s2   d Z ddlZddlZddlmZ G dd„ dƒZdS )zDuration module.é    N)Ú_apic                   @   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e eej¡Ze eej¡Ze eej¡Ze eej¡Ze eej¡Ze eej¡Zdd„ Zdd„ Zdd„ ZeZdd„ Zdd„ Z dd„ Z!dS )ÚDurationzClass Duration in development.ÚETÚUTCc                 C   s    t j| j|d� || _|| _dS )a3  
        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.
        )ÚframeN)r   Zcheck_in_listÚallowedÚ_frameÚ_seconds)Úselfr   Úseconds© r   úe/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/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   |   |d¡ || j|jƒS )zT
        Check that *self* and *rhs* share frames; compare them using *op*.
        Úcompare)ÚcheckSameFramer	   )r
   ÚopÚrhsr   r   r   Ú_cmp0   s    zDuration._cmpc                 C   sF   ddl m  m} t||jƒr&||  S |  |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_unitsÚtestingZ	jpl_unitsÚ
isinstanceZEpochr   r   r   r	   )r
   r   ÚUr   r   r   Ú__add__>   s
    zDuration.__add__c                 C   s    |   |d¡ t| j| j|j ƒS )a3  
        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__T   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	   Úfloatr    r   r   r   Ú__mul__d   s    
zDuration.__mul__c                 C   s   d| j | jf S )úPrint the Duration.z%g %s)r	   r   r   r   r   r   Ú__str__r   s    zDuration.__str__c                 C   s   d| j | jf S )r$   zDuration('%s', %g))r   r	   r   r   r   r   Ú__repr__v   s    zDuration.__repr__c                 C   s.   | j |j kr*td|› d| j › d|j › �ƒ‚dS )aK  
        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 z' Durations with different frames.
LHS: z
RHS: N)r   Ú
ValueError)r
   r   Úfuncr   r   r   r   z   s    ÿþÿzDuration.checkSameFrameN)"Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   Ú	functoolsÚpartialmethodÚoperatorÚeqÚ__eq__ÚneÚ__ne__ÚltÚ__lt__ÚleÚ__le__ÚgtÚ__gt__ÚgeÚ__ge__r   r!   r#   Ú__rmul__r%   r&   r   r   r   r   r   r   	   s,   r   )r,   r-   r/   Z
matplotlibr   r   r   r   r   r   Ú<module>   s   