Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/numbers.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@ s�dZddlmZddlmZmZmZdddddgZdefd	��YZ	de	fd
��YZ
e
je�de
fd��YZ
e
je�de
fd��YZdefd
��YZeje�eje�dS(s~Abstract Base Classes (ABCs) for numbers, according to PEP 3141.

TODO: Fill out more detailed documentation on the operators.i�(tdivision(tABCMetatabstractmethodtabstractpropertytNumbertComplextRealtRationaltIntegralcB s eZdZeZdZdZRS(s�All 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(t__name__t
__module__t__doc__Rt
__metaclass__t	__slots__tNonet__hash__(((s/sys/lib/python2.7/numbers.pyR
scB sFeZdZdZed��Zd�Zed��Zed��Z	ed��Z
ed��Zed��Zed��Z
d	�Zd
�Zed��Zed��Zed
��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zd�ZRS(saComplex 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.
    cC sdS(s<Return a builtin complex instance. Called for complex(self).N((tself((s/sys/lib/python2.7/numbers.pyt__complex__/scC s
|dkS(s)True if self != 0. Called for bool(self).i((R((s/sys/lib/python2.7/numbers.pyt__nonzero__4scC s
t�dS(sXRetrieve the real component of this number.

        This should subclass Real.
        N(tNotImplementedError(R((s/sys/lib/python2.7/numbers.pytreal8scC s
t�dS(s]Retrieve the imaginary component of this number.

        This should subclass Real.
        N(R(R((s/sys/lib/python2.7/numbers.pytimag@scC s
t�dS(sself + otherN(R(Rtother((s/sys/lib/python2.7/numbers.pyt__add__HscC s
t�dS(sother + selfN(R(RR((s/sys/lib/python2.7/numbers.pyt__radd__MscC s
t�dS(s-selfN(R(R((s/sys/lib/python2.7/numbers.pyt__neg__RscC s
t�dS(s+selfN(R(R((s/sys/lib/python2.7/numbers.pyt__pos__WscC s	||S(sself - other((RR((s/sys/lib/python2.7/numbers.pyt__sub__\scC s	||S(sother - self((RR((s/sys/lib/python2.7/numbers.pyt__rsub__`scC s
t�dS(sself * otherN(R(RR((s/sys/lib/python2.7/numbers.pyt__mul__dscC s
t�dS(sother * selfN(R(RR((s/sys/lib/python2.7/numbers.pyt__rmul__iscC s
t�dS(sPself / other without __future__ division

        May promote to float.
        N(R(RR((s/sys/lib/python2.7/numbers.pyt__div__nscC s
t�dS(s(other / self without __future__ divisionN(R(RR((s/sys/lib/python2.7/numbers.pyt__rdiv__vscC s
t�dS(s`self / other with __future__ division.

        Should promote to float when necessary.
        N(R(RR((s/sys/lib/python2.7/numbers.pyt__truediv__{scC s
t�dS(s%other / self with __future__ divisionN(R(RR((s/sys/lib/python2.7/numbers.pyt__rtruediv__�scC s
t�dS(sBself**exponent; should promote to float or complex when necessary.N(R(Rtexponent((s/sys/lib/python2.7/numbers.pyt__pow__�scC s
t�dS(sbase ** selfN(R(Rtbase((s/sys/lib/python2.7/numbers.pyt__rpow__�scC s
t�dS(s7Returns the Real distance from 0. Called for abs(self).N(R(R((s/sys/lib/python2.7/numbers.pyt__abs__�scC s
t�dS(s$(x+y*i).conjugate() returns (x-y*i).N(R(R((s/sys/lib/python2.7/numbers.pyt	conjugate�scC s
t�dS(s
self == otherN(R(RR((s/sys/lib/python2.7/numbers.pyt__eq__�scC s||kS(s
self != other((RR((s/sys/lib/python2.7/numbers.pyt__ne__�s((R	R
RR
RRRRRRRRRRRRRRRR R!R"R$R&R'R(R)R*(((s/sys/lib/python2.7/numbers.pyR"s0				cB s�eZdZdZed��Zed��Zd�Zd�Zed��Z	ed��Z
ed��Zed��Zed	��Z
ed
��Zd�Zed��Zed
��Zd�ZRS(s�To 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.
    cC s
t�dS(sTAny Real can be converted to a native float object.

        Called for float(self).N(R(R((s/sys/lib/python2.7/numbers.pyt	__float__�scC s
t�dS(sGtrunc(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((s/sys/lib/python2.7/numbers.pyt	__trunc__�scC s||||fS(s�divmod(self, other): The pair (self // other, self % other).

        Sometimes this can be computed faster than the pair of
        operations.
        ((RR((s/sys/lib/python2.7/numbers.pyt
__divmod__�scC s||||fS(s�divmod(other, self): The pair (self // other, self % other).

        Sometimes this can be computed faster than the pair of
        operations.
        ((RR((s/sys/lib/python2.7/numbers.pyt__rdivmod__�scC s
t�dS(s)self // other: The floor() of self/other.N(R(RR((s/sys/lib/python2.7/numbers.pyt__floordiv__�scC s
t�dS(s)other // self: The floor() of other/self.N(R(RR((s/sys/lib/python2.7/numbers.pyt
__rfloordiv__�scC s
t�dS(sself % otherN(R(RR((s/sys/lib/python2.7/numbers.pyt__mod__�scC s
t�dS(sother % selfN(R(RR((s/sys/lib/python2.7/numbers.pyt__rmod__�scC s
t�dS(sRself < other

        < on Reals defines a total ordering, except perhaps for NaN.N(R(RR((s/sys/lib/python2.7/numbers.pyt__lt__�scC s
t�dS(s
self <= otherN(R(RR((s/sys/lib/python2.7/numbers.pyt__le__�scC stt|��S(s(complex(self) == complex(float(self), 0)(tcomplextfloat(R((s/sys/lib/python2.7/numbers.pyR�scC s|
S(s&Real numbers are their real component.((R((s/sys/lib/python2.7/numbers.pyR�scC sdS(s)Real numbers have no imaginary component.i((R((s/sys/lib/python2.7/numbers.pyRscC s|
S(sConjugate is a no-op for Reals.((R((s/sys/lib/python2.7/numbers.pyR(s((R	R
RR
RR+R,R-R.R/R0R1R2R3R4RtpropertyRRR((((s/sys/lib/python2.7/numbers.pyR�s 
			cB s;eZdZdZed��Zed��Zd�ZRS(s6.numerator and .denominator should be in lowest terms.cC s
t�dS(N(R(R((s/sys/lib/python2.7/numbers.pyt	numeratorscC s
t�dS(N(R(R((s/sys/lib/python2.7/numbers.pytdenominatorscC s|j|jS(sfloat(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.

        (R8R9(R((s/sys/lib/python2.7/numbers.pyR+s((R	R
RR
RR8R9R+(((s/sys/lib/python2.7/numbers.pyRs
cB s
eZdZdZed��Zd�Zedd��Zed��Z	ed��Z
ed��Zed��Zed��Z
ed	��Zed
��Zed��Zed��Zed
��Zed��Zd�Zed��Zed��ZRS(sAIntegral adds a conversion to long and the bit-string operations.cC s
t�dS(s
long(self)N(R(R((s/sys/lib/python2.7/numbers.pyt__long__,scC s
t|�S(s6Called whenever an index is needed, such as in slicing(tlong(R((s/sys/lib/python2.7/numbers.pyt	__index__1scC s
t�dS(s4self ** 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(RR#tmodulus((s/sys/lib/python2.7/numbers.pyR$5s	cC s
t�dS(s
self << otherN(R(RR((s/sys/lib/python2.7/numbers.pyt
__lshift__@scC s
t�dS(s
other << selfN(R(RR((s/sys/lib/python2.7/numbers.pyt__rlshift__EscC s
t�dS(s
self >> otherN(R(RR((s/sys/lib/python2.7/numbers.pyt
__rshift__JscC s
t�dS(s
other >> selfN(R(RR((s/sys/lib/python2.7/numbers.pyt__rrshift__OscC s
t�dS(sself & otherN(R(RR((s/sys/lib/python2.7/numbers.pyt__and__TscC s
t�dS(sother & selfN(R(RR((s/sys/lib/python2.7/numbers.pyt__rand__YscC s
t�dS(sself ^ otherN(R(RR((s/sys/lib/python2.7/numbers.pyt__xor__^scC s
t�dS(sother ^ selfN(R(RR((s/sys/lib/python2.7/numbers.pyt__rxor__cscC s
t�dS(sself | otherN(R(RR((s/sys/lib/python2.7/numbers.pyt__or__hscC s
t�dS(sother | selfN(R(RR((s/sys/lib/python2.7/numbers.pyt__ror__mscC s
t�dS(s~selfN(R(R((s/sys/lib/python2.7/numbers.pyt
__invert__rscC stt|��S(s float(self) == float(long(self))(R6R;(R((s/sys/lib/python2.7/numbers.pyR+xscC s|
S(s"Integers are their own numerators.((R((s/sys/lib/python2.7/numbers.pyR8|scC sdS(s!Integers have a denominator of 1.i((R((s/sys/lib/python2.7/numbers.pyR9�s(N(R	R
RR
RR:R<RR$R>R?R@RARBRCRDRERFRGRHR+R7R8R9(((s/sys/lib/python2.7/numbers.pyR's(	
	N(Rt
__future__RtabcRRRt__all__tobjectRRtregisterR5RR6RRtintR;(((s/sys/lib/python2.7/numbers.pyt<module>s�b
_


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].