o
    gg                     @   s*   d 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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,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   check_in_listallowed_frame_seconds)selfr   seconds r   c/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/matplotlib/testing/jpl_units/Duration.py__init__   s   
zDuration.__init__c                 C      | j S )z$Return the frame the duration is in.)r	   r   r   r   r   r         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__$      zDuration.__neg__c                 C   r   )z-Return the number of seconds in the Duration.r
   r   r   r   r   r   (   r   zDuration.secondsc                 C   s
   | j dkS )Nr   r   r   r   r   r   __bool__,   s   
zDuration.__bool__c                 C      |  |tjS N)_cmpoperatoreqr   rhsr   r   r   __eq__/      zDuration.__eq__c                 C   r   r   )r   r   ner   r   r   r   __ne__2   r!   zDuration.__ne__c                 C   r   r   )r   r   ltr   r   r   r   __lt__5   r!   zDuration.__lt__c                 C   r   r   )r   r   ler   r   r   r   __le__8   r!   zDuration.__le__c                 C   r   r   )r   r   gtr   r   r   r   __gt__;   r!   zDuration.__gt__c                 C   r   r   )r   r   ger   r   r   r   __ge__>   r!   zDuration.__ge__c                 C   s   |  |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   A   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)	matplotlib.testing.jpl_unitstesting	jpl_units
isinstanceEpochr-   r   r	   r
   )r   r   Ur   r   r   __add__O   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   __sub__e   s   zDuration.__sub__c                 C      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__u      
zDuration.__mul__c                 C   r9   )z
        Scale a Duration by a value.

        = INPUT VARIABLES
        - lhs     The scalar to multiply by.

        = RETURN VALUE
        - Returns the scaled Duration.
        r:   )r   lhsr   r   r   __rmul__   r=   zDuration.__rmul__c                 C      d| j | jf S )Print the Duration.z%g %s)r
   r	   r   r   r   r   __str__   r   zDuration.__str__c                 C   r@   )rA   zDuration('%s', %g))r	   r
   r   r   r   r   __repr__   r   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-      s   zDuration.checkSameFrameN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r    r#   r%   r'   r)   r+   r   r6   r8   r<   r?   rB   rC   r-   r   r   r   r   r      s.    r   )rI   r   
matplotlibr   r   r   r   r   r   <module>   s    