1 # Stubs for decimal (Python 2)
\r
4 Any, Dict, NamedTuple, Optional, Sequence, Tuple, Union,
\r
5 SupportsAbs, SupportsFloat, SupportsInt,
\r
8 _Decimal = Union[Decimal, int]
\r
9 _ComparableNum = Union[Decimal, int, float]
\r
11 DecimalTuple = NamedTuple('DecimalTuple',
\r
13 ('digits', Sequence[int]), # TODO: Use Tuple[int, ...]
\r
16 ROUND_DOWN = ... # type: str
\r
17 ROUND_HALF_UP = ... # type: str
\r
18 ROUND_HALF_EVEN = ... # type: str
\r
19 ROUND_CEILING = ... # type: str
\r
20 ROUND_FLOOR = ... # type: str
\r
21 ROUND_UP = ... # type: str
\r
22 ROUND_HALF_DOWN = ... # type: str
\r
23 ROUND_05UP = ... # type: str
\r
25 class DecimalException(ArithmeticError):
\r
26 def handle(self, context, *args): ...
\r
28 class Clamped(DecimalException): ...
\r
30 class InvalidOperation(DecimalException): ...
\r
32 class ConversionSyntax(InvalidOperation): ...
\r
34 class DivisionByZero(DecimalException, ZeroDivisionError): ...
\r
36 class DivisionImpossible(InvalidOperation): ...
\r
38 class DivisionUndefined(InvalidOperation, ZeroDivisionError): ...
\r
40 class Inexact(DecimalException): ...
\r
42 class InvalidContext(InvalidOperation): ...
\r
44 class Rounded(DecimalException): ...
\r
46 class Subnormal(DecimalException): ...
\r
48 class Overflow(Inexact, Rounded): ...
\r
50 class Underflow(Inexact, Rounded, Subnormal): ...
\r
52 def setcontext(context: Context): ...
\r
53 def getcontext() -> Context: ...
\r
54 def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ...
\r
56 class Decimal(SupportsAbs[Decimal], SupportsFloat, SupportsInt):
\r
57 def __init__(cls, value: Union[_Decimal, float, str, unicode,
\r
58 Tuple[int, Sequence[int], int]] = ...,
\r
59 context: Context = ...) -> None: ...
\r
61 def from_float(cls, f: float) -> Decimal: ...
\r
62 def __nonzero__(self) -> bool: ...
\r
63 def __eq__(self, other: object) -> bool: ...
\r
64 def __ne__(self, other: object) -> bool: ...
\r
65 def __lt__(self, other: _ComparableNum) -> bool: ...
\r
66 def __le__(self, other: _ComparableNum) -> bool: ...
\r
67 def __gt__(self, other: _ComparableNum) -> bool: ...
\r
68 def __ge__(self, other: _ComparableNum) -> bool: ...
\r
69 def compare(self, other: _Decimal) -> Decimal: ...
\r
70 def __hash__(self) -> int: ...
\r
71 def as_tuple(self) -> DecimalTuple: ...
\r
72 def to_eng_string(self, context: Context = ...) -> str: ...
\r
73 def __neg__(self) -> Decimal: ...
\r
74 def __pos__(self) -> Decimal: ...
\r
75 def __abs__(self, round: bool = ...) -> Decimal: ...
\r
76 def __add__(self, other: _Decimal) -> Decimal: ...
\r
77 def __radd__(self, other: int) -> Decimal: ...
\r
78 def __sub__(self, other: _Decimal) -> Decimal: ...
\r
79 def __rsub__(self, other: int) -> Decimal: ...
\r
80 def __mul__(self, other: _Decimal) -> Decimal: ...
\r
81 def __rmul__(self, other: int) -> Decimal: ...
\r
82 def __truediv__(self, other: _Decimal) -> Decimal: ...
\r
83 def __rtruediv__(self, other: int) -> Decimal: ...
\r
84 def __div__(self, other: _Decimal) -> Decimal: ...
\r
85 def __rdiv__(self, other: int) -> Decimal: ...
\r
86 def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ...
\r
87 def __rdivmod__(self, other: int) -> Tuple[Decimal, Decimal]: ...
\r
88 def __mod__(self, other: _Decimal) -> Decimal: ...
\r
89 def __rmod__(self, other: int) -> Decimal: ...
\r
90 def remainder_near(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
91 def __floordiv__(self, other: _Decimal) -> Decimal: ...
\r
92 def __rfloordiv__(self, other: int) -> Decimal: ...
\r
93 def __float__(self) -> float: ...
\r
94 def __int__(self) -> int: ...
\r
95 def __trunc__(self) -> int: ...
\r
97 def imag(self) -> Decimal: ...
\r
99 def real(self) -> Decimal: ...
\r
100 def conjugate(self) -> Decimal: ...
\r
101 def __complex__(self) -> complex: ...
\r
102 def __long__(self) -> long: ...
\r
103 def fma(self, other: _Decimal, third: _Decimal, context: Context = ...) -> Decimal: ...
\r
104 def __pow__(self, other: _Decimal) -> Decimal: ...
\r
105 def __rpow__(self, other: int) -> Decimal: ...
\r
106 def normalize(self, context: Context = ...) -> Decimal: ...
\r
107 def quantize(self, exp: _Decimal, rounding: str = ...,
\r
108 context: Context = ...) -> Decimal: ...
\r
109 def same_quantum(self, other: Decimal) -> bool: ...
\r
110 def to_integral(self, rounding: str = ..., context: Context = ...) -> Decimal: ...
\r
111 def to_integral_exact(self, rounding: str = ..., context: Context = ...) -> Decimal: ...
\r
112 def to_integral_value(self, rounding: str = ..., context: Context = ...) -> Decimal: ...
\r
113 def sqrt(self, context: Context = ...) -> Decimal: ...
\r
114 def max(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
115 def min(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
116 def adjusted(self) -> int: ...
\r
117 def canonical(self, context: Context = ...) -> Decimal: ...
\r
118 def compare_signal(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
119 def compare_total(self, other: _Decimal) -> Decimal: ...
\r
120 def compare_total_mag(self, other: _Decimal) -> Decimal: ...
\r
121 def copy_abs(self) -> Decimal: ...
\r
122 def copy_negate(self) -> Decimal: ...
\r
123 def copy_sign(self, other: _Decimal) -> Decimal: ...
\r
124 def exp(self, context: Context = ...) -> Decimal: ...
\r
125 def is_canonical(self) -> bool: ...
\r
126 def is_finite(self) -> bool: ...
\r
127 def is_infinite(self) -> bool: ...
\r
128 def is_nan(self) -> bool: ...
\r
129 def is_normal(self, context: Context = ...) -> bool: ...
\r
130 def is_qnan(self) -> bool: ...
\r
131 def is_signed(self) -> bool: ...
\r
132 def is_snan(self) -> bool: ...
\r
133 def is_subnormal(self, context: Context = ...) -> bool: ...
\r
134 def is_zero(self) -> bool: ...
\r
135 def ln(self, context: Context = ...) -> Decimal: ...
\r
136 def log10(self, context: Context = ...) -> Decimal: ...
\r
137 def logb(self, context: Context = ...) -> Decimal: ...
\r
138 def logical_and(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
139 def logical_invert(self, context: Context = ...) -> Decimal: ...
\r
140 def logical_or(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
141 def logical_xor(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
142 def max_mag(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
143 def min_mag(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
144 def next_minus(self, context: Context = ...) -> Decimal: ...
\r
145 def next_plus(self, context: Context = ...) -> Decimal: ...
\r
146 def next_toward(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
147 def number_class(self, context: Context = ...) -> str: ...
\r
148 def radix(self) -> Decimal: ...
\r
149 def rotate(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
150 def scaleb(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
151 def shift(self, other: _Decimal, context: Context = ...) -> Decimal: ...
\r
152 def __reduce__(self): ...
\r
153 def __copy__(self): ...
\r
154 def __deepcopy__(self, memo): ...
\r
155 def __format__(self, specifier, context=None, _localeconv=None) -> str: ...
\r
157 class _ContextManager:
\r
158 new_context = ... # type: Context
\r
159 saved_context = ... # type: Context
\r
160 def __init__(self, new_context: Context) -> None: ...
\r
161 def __enter__(self): ...
\r
162 def __exit__(self, t, v, tb): ...
\r
165 prec = ... # type: int
\r
166 rounding = ... # type: str
\r
167 Emin = ... # type: int
\r
168 Emax = ... # type: int
\r
169 capitals = ... # type: int
\r
170 traps = ... # type: Dict[type, bool]
\r
171 flags = ... # type: Any
\r
172 def __init__(self, prec=None, rounding=None, traps=None, flags=None, Emin=None, Emax=None, capitals=None, _clamp=0, _ignored_flags=None): ...
\r
173 def clear_flags(self): ...
\r
174 def copy(self): ...
\r
175 __copy__ = ... # type: Any
\r
176 __hash__ = ... # type: Any
\r
177 def Etiny(self): ...
\r
178 def Etop(self): ...
\r
179 def create_decimal(self, num=...): ...
\r
180 def create_decimal_from_float(self, f): ...
\r
181 def abs(self, a): ...
\r
182 def add(self, a, b): ...
\r
183 def canonical(self, a): ...
\r
184 def compare(self, a, b): ...
\r
185 def compare_signal(self, a, b): ...
\r
186 def compare_total(self, a, b): ...
\r
187 def compare_total_mag(self, a, b): ...
\r
188 def copy_abs(self, a): ...
\r
189 def copy_decimal(self, a): ...
\r
190 def copy_negate(self, a): ...
\r
191 def copy_sign(self, a, b): ...
\r
192 def divide(self, a, b): ...
\r
193 def divide_int(self, a, b): ...
\r
194 def divmod(self, a, b): ...
\r
195 def exp(self, a): ...
\r
196 def fma(self, a, b, c): ...
\r
197 def is_canonical(self, a): ...
\r
198 def is_finite(self, a): ...
\r
199 def is_infinite(self, a): ...
\r
200 def is_nan(self, a): ...
\r
201 def is_normal(self, a): ...
\r
202 def is_qnan(self, a): ...
\r
203 def is_signed(self, a): ...
\r
204 def is_snan(self, a): ...
\r
205 def is_subnormal(self, a): ...
\r
206 def is_zero(self, a): ...
\r
207 def ln(self, a): ...
\r
208 def log10(self, a): ...
\r
209 def logb(self, a): ...
\r
210 def logical_and(self, a, b): ...
\r
211 def logical_invert(self, a): ...
\r
212 def logical_or(self, a, b): ...
\r
213 def logical_xor(self, a, b): ...
\r
214 def max(self, a, b): ...
\r
215 def max_mag(self, a, b): ...
\r
216 def min(self, a, b): ...
\r
217 def min_mag(self, a, b): ...
\r
218 def minus(self, a): ...
\r
219 def multiply(self, a, b): ...
\r
220 def next_minus(self, a): ...
\r
221 def next_plus(self, a): ...
\r
222 def next_toward(self, a, b): ...
\r
223 def normalize(self, a): ...
\r
224 def number_class(self, a): ...
\r
225 def plus(self, a): ...
\r
226 def power(self, a, b, modulo=None): ...
\r
227 def quantize(self, a, b): ...
\r
228 def radix(self): ...
\r
229 def remainder(self, a, b): ...
\r
230 def remainder_near(self, a, b): ...
\r
231 def rotate(self, a, b): ...
\r
232 def same_quantum(self, a, b): ...
\r
233 def scaleb(self, a, b): ...
\r
234 def shift(self, a, b): ...
\r
235 def sqrt(self, a): ...
\r
236 def subtract(self, a, b): ...
\r
237 def to_eng_string(self, a): ...
\r
238 def to_sci_string(self, a): ...
\r
239 def to_integral_exact(self, a): ...
\r
240 def to_integral_value(self, a): ...
\r
241 def to_integral(self, a): ...
\r
243 DefaultContext = ... # type: Context
\r
244 BasicContext = ... # type: Context
\r
245 ExtendedContext = ... # type: Context
\r