
[[\(                 @   s   d  Z  d d l m Z m Z d d d d d g Z Gd d   d d	 e Z Gd
 d   d e  Z e j e  Gd d   d e  Z	 e	 j e
  Gd d   d e	  Z Gd d   d e  Z e j e  d S)z~Abstract Base Classes (ABCs) for numbers, according to PEP 3141.

TODO: Fill out more detailed documentation on the operators.    )ABCMetaabstractmethodNumberComplexRealRationalIntegralc               @   s"   e  Z d  Z d Z f  Z d Z d S)r   zAll numbers inherit from this class.

    If you just want to check if an argument x is a number, without
    caring what kind, use isinstance(x, Number).
    N)__name__
__module____qualname____doc__	__slots____hash__ r   r   /usr/lib/python3.4/numbers.pyr      s   	metaclassc               @   sx  e  Z d  Z d Z f  Z e d d    Z d d   Z e e d d     Z	 e e d d	     Z
 e d
 d    Z e d d    Z e d d    Z e d d    Z d d   Z d d   Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d  d!    Z e d" d#    Z e d$ d%    Z e d& d'    Z d( d)   Z d* S)+r   aa  Complex defines the operations that work on the builtin complex type.

    In short, those are: a conversion to complex, .real, .imag, +, -,
    *, /, abs(), .conjugate, ==, and !=.

    If it is given heterogenous arguments, and doesn't have special
    knowledge about them, it should fall back to the builtin complex
    type as described below.
    c             C   s   d S)z<Return a builtin complex instance. Called for complex(self).Nr   )selfr   r   r   __complex__-   s    zComplex.__complex__c             C   s
   |  d k S)z)True if self != 0. Called for bool(self).r   r   )r   r   r   r   __bool__1   s    zComplex.__bool__c             C   s
   t   d S)zXRetrieve the real component of this number.

        This should subclass Real.
        N)NotImplementedError)r   r   r   r   real5   s    zComplex.realc             C   s
   t   d S)z]Retrieve the imaginary component of this number.

        This should subclass Real.
        N)r   )r   r   r   r   imag>   s    zComplex.imagc             C   s
   t   d S)zself + otherN)r   )r   otherr   r   r   __add__G   s    zComplex.__add__c             C   s
   t   d S)zother + selfN)r   )r   r   r   r   r   __radd__L   s    zComplex.__radd__c             C   s
   t   d S)z-selfN)r   )r   r   r   r   __neg__Q   s    zComplex.__neg__c             C   s
   t   d S)z+selfN)r   )r   r   r   r   __pos__V   s    zComplex.__pos__c             C   s	   |  | S)zself - otherr   )r   r   r   r   r   __sub__[   s    zComplex.__sub__c             C   s	   |  | S)zother - selfr   )r   r   r   r   r   __rsub___   s    zComplex.__rsub__c             C   s
   t   d S)zself * otherN)r   )r   r   r   r   r   __mul__c   s    zComplex.__mul__c             C   s
   t   d S)zother * selfN)r   )r   r   r   r   r   __rmul__h   s    zComplex.__rmul__c             C   s
   t   d S)z5self / other: Should promote to float when necessary.N)r   )r   r   r   r   r   __truediv__m   s    zComplex.__truediv__c             C   s
   t   d S)zother / selfN)r   )r   r   r   r   r   __rtruediv__r   s    zComplex.__rtruediv__c             C   s
   t   d S)zBself**exponent; should promote to float or complex when necessary.N)r   )r   exponentr   r   r   __pow__w   s    zComplex.__pow__c             C   s
   t   d S)zbase ** selfN)r   )r   baser   r   r   __rpow__|   s    zComplex.__rpow__c             C   s
   t   d S)z7Returns the Real distance from 0. Called for abs(self).N)r   )r   r   r   r   __abs__   s    zComplex.__abs__c             C   s
   t   d S)z$(x+y*i).conjugate() returns (x-y*i).N)r   )r   r   r   r   	conjugate   s    zComplex.conjugatec             C   s
   t   d S)zself == otherN)r   )r   r   r   r   r   __eq__   s    zComplex.__eq__c             C   s   |  | k S)zself != otherr   )r   r   r   r   r   __ne__   s    zComplex.__ne__N)r	   r
   r   r   r   r   r   r   propertyr   r   r   r   r   r   r   r   r   r    r!   r"   r$   r&   r'   r(   r)   r*   r   r   r   r   r       s0   	c               @   s9  e  Z d  Z d Z f  Z e d d    Z e d d    Z e d d    Z e d d	    Z	 e d
 d d   Z
 d d   Z d d   Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z d d   Z e d d     Z e d! d"    Z d# d$   Z d
 S)%r   zTo Complex, Real adds the operations that work on real numbers.

    In short, those are: a conversion to float, trunc(), divmod,
    %, <, <=, >, and >=.

    Real also provides defaults for the derived operations.
    c             C   s
   t   d S)zTAny Real can be converted to a native float object.

        Called for float(self).N)r   )r   r   r   r   	__float__   s    zReal.__float__c             C   s
   t   d S)aG  trunc(self): Truncates self to an Integral.

        Returns an Integral i such that:
          * i>0 iff self>0;
          * abs(i) <= abs(self);
          * for any Integral j satisfying the first two conditions,
            abs(i) >= abs(j) [i.e. i has "maximal" abs among those].
        i.e. "truncate towards 0".
        N)r   )r   r   r   r   	__trunc__   s    zReal.__trunc__c             C   s
   t   d S)z$Finds the greatest Integral <= self.N)r   )r   r   r   r   	__floor__   s    zReal.__floor__c             C   s
   t   d S)z!Finds the least Integral >= self.N)r   )r   r   r   r   __ceil__   s    zReal.__ceil__Nc             C   s
   t   d S)zRounds self to ndigits decimal places, defaulting to 0.

        If ndigits is omitted or None, returns an Integral, otherwise
        returns a Real. Rounds half toward even.
        N)r   )r   Zndigitsr   r   r   	__round__   s    zReal.__round__c             C   s   |  | |  | f S)zdivmod(self, other): The pair (self // other, self % other).

        Sometimes this can be computed faster than the pair of
        operations.
        r   )r   r   r   r   r   
__divmod__   s    zReal.__divmod__c             C   s   | |  | |  f S)zdivmod(other, self): The pair (self // other, self % other).

        Sometimes this can be computed faster than the pair of
        operations.
        r   )r   r   r   r   r   __rdivmod__   s    zReal.__rdivmod__c             C   s
   t   d S)z)self // other: The floor() of self/other.N)r   )r   r   r   r   r   __floordiv__   s    zReal.__floordiv__c             C   s
   t   d S)z)other // self: The floor() of other/self.N)r   )r   r   r   r   r   __rfloordiv__   s    zReal.__rfloordiv__c             C   s
   t   d S)zself % otherN)r   )r   r   r   r   r   __mod__   s    zReal.__mod__c             C   s
   t   d S)zother % selfN)r   )r   r   r   r   r   __rmod__   s    zReal.__rmod__c             C   s
   t   d S)zRself < other

        < on Reals defines a total ordering, except perhaps for NaN.N)r   )r   r   r   r   r   __lt__   s    zReal.__lt__c             C   s
   t   d S)zself <= otherN)r   )r   r   r   r   r   __le__   s    zReal.__le__c             C   s   t  t |    S)z(complex(self) == complex(float(self), 0))complexfloat)r   r   r   r   r      s    zReal.__complex__c             C   s   |  
S)z&Real numbers are their real component.r   )r   r   r   r   r      s    z	Real.realc             C   s   d S)z)Real numbers have no imaginary component.r   r   )r   r   r   r   r     s    z	Real.imagc             C   s   |  
S)zConjugate is a no-op for Reals.r   )r   r   r   r   r(   	  s    zReal.conjugate)r	   r
   r   r   r   r   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r   r+   r   r   r(   r   r   r   r   r      s(   c               @   sX   e  Z d  Z d Z f  Z e e d d     Z e e d d     Z d d   Z	 d S)	r   z6.numerator and .denominator should be in lowest terms.c             C   s
   t   d  S)N)r   )r   r   r   r   	numerator  s    zRational.numeratorc             C   s
   t   d  S)N)r   )r   r   r   r   denominator  s    zRational.denominatorc             C   s   |  j  |  j S)a  float(self) = self.numerator / self.denominator

        It's important that this conversion use the integer's "true"
        division rather than casting one side to float before dividing
        so that ratios of huge integers convert without overflowing.

        )r;   r<   )r   r   r   r   r,      s    zRational.__float__N)
r	   r
   r   r   r   r+   r   r;   r<   r,   r   r   r   r   r     s   c               @   sE  e  Z d  Z d Z f  Z e d d    Z d d   Z e d d d   Z e d	 d
    Z	 e d d    Z
 e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z d d    Z e d! d"    Z e d# d$    Z d S)%r   z@Integral adds a conversion to int and the bit-string operations.c             C   s
   t   d S)z	int(self)N)r   )r   r   r   r   __int__0  s    zIntegral.__int__c             C   s
   t  |   S)z6Called whenever an index is needed, such as in slicing)int)r   r   r   r   	__index__5  s    zIntegral.__index__Nc             C   s
   t   d S)a4  self ** exponent % modulus, but maybe faster.

        Accept the modulus argument if you want to support the
        3-argument version of pow(). Raise a TypeError if exponent < 0
        or any argument isn't Integral. Otherwise, just implement the
        2-argument version described in Complex.
        N)r   )r   r#   modulusr   r   r   r$   9  s    	zIntegral.__pow__c             C   s
   t   d S)zself << otherN)r   )r   r   r   r   r   
__lshift__D  s    zIntegral.__lshift__c             C   s
   t   d S)zother << selfN)r   )r   r   r   r   r   __rlshift__I  s    zIntegral.__rlshift__c             C   s
   t   d S)zself >> otherN)r   )r   r   r   r   r   
__rshift__N  s    zIntegral.__rshift__c             C   s
   t   d S)zother >> selfN)r   )r   r   r   r   r   __rrshift__S  s    zIntegral.__rrshift__c             C   s
   t   d S)zself & otherN)r   )r   r   r   r   r   __and__X  s    zIntegral.__and__c             C   s
   t   d S)zother & selfN)r   )r   r   r   r   r   __rand__]  s    zIntegral.__rand__c             C   s
   t   d S)zself ^ otherN)r   )r   r   r   r   r   __xor__b  s    zIntegral.__xor__c             C   s
   t   d S)zother ^ selfN)r   )r   r   r   r   r   __rxor__g  s    zIntegral.__rxor__c             C   s
   t   d S)zself | otherN)r   )r   r   r   r   r   __or__l  s    zIntegral.__or__c             C   s
   t   d S)zother | selfN)r   )r   r   r   r   r   __ror__q  s    zIntegral.__ror__c             C   s
   t   d S)z~selfN)r   )r   r   r   r   
__invert__v  s    zIntegral.__invert__c             C   s   t  t |    S)zfloat(self) == float(int(self)))r:   r>   )r   r   r   r   r,   |  s    zIntegral.__float__c             C   s   |  
S)z"Integers are their own numerators.r   )r   r   r   r   r;     s    zIntegral.numeratorc             C   s   d S)z!Integers have a denominator of 1.   r   )r   r   r   r   r<     s    zIntegral.denominator)r	   r
   r   r   r   r   r=   r?   r$   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   r,   r+   r;   r<   r   r   r   r   r   +  s(   
N)r   abcr   r   __all__r   r   registerr9   r   r:   r   r   r>   r   r   r   r   <module>   s   uu_