1import numbers 2import sys 3from types import TracebackType 4from typing import ( 5 Any, Container, Dict, List, NamedTuple, Optional, overload, Sequence, Text, Tuple, Type, TypeVar, Union, 6) 7 8_Decimal = Union[Decimal, int] 9_DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]] 10if sys.version_info >= (3,): 11 _ComparableNum = Union[Decimal, float, numbers.Rational] 12else: 13 _ComparableNum = Union[Decimal, float] 14_DecimalT = TypeVar('_DecimalT', bound=Decimal) 15 16class DecimalTuple(NamedTuple): 17 sign: int 18 digits: Tuple[int, ...] 19 exponent: int 20 21ROUND_DOWN: str 22ROUND_HALF_UP: str 23ROUND_HALF_EVEN: str 24ROUND_CEILING: str 25ROUND_FLOOR: str 26ROUND_UP: str 27ROUND_HALF_DOWN: str 28ROUND_05UP: str 29 30if sys.version_info >= (3,): 31 HAVE_THREADS: bool 32 MAX_EMAX: int 33 MAX_PREC: int 34 MIN_EMIN: int 35 MIN_ETINY: int 36 37class DecimalException(ArithmeticError): 38 if sys.version_info < (3,): 39 def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... 40 41class Clamped(DecimalException): ... 42 43class InvalidOperation(DecimalException): ... 44 45class ConversionSyntax(InvalidOperation): ... 46 47class DivisionByZero(DecimalException, ZeroDivisionError): ... 48 49class DivisionImpossible(InvalidOperation): ... 50 51class DivisionUndefined(InvalidOperation, ZeroDivisionError): ... 52 53class Inexact(DecimalException): ... 54 55class InvalidContext(InvalidOperation): ... 56 57class Rounded(DecimalException): ... 58 59class Subnormal(DecimalException): ... 60 61class Overflow(Inexact, Rounded): ... 62 63class Underflow(Inexact, Rounded, Subnormal): ... 64 65if sys.version_info >= (3,): 66 class FloatOperation(DecimalException, TypeError): ... 67 68def setcontext(__context: Context) -> None: ... 69def getcontext() -> Context: ... 70def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ... 71 72class Decimal(object): 73 def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ... 74 @classmethod 75 def from_float(cls, __f: float) -> Decimal: ... 76 if sys.version_info >= (3,): 77 def __bool__(self) -> bool: ... 78 else: 79 def __nonzero__(self) -> bool: ... 80 def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 81 def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 82 def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ... 83 84 def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 85 def __hash__(self) -> int: ... 86 def as_tuple(self) -> DecimalTuple: ... 87 if sys.version_info >= (3, 6): 88 def as_integer_ratio(self) -> Tuple[int, int]: ... 89 90 def to_eng_string(self, context: Optional[Context] = ...) -> str: ... 91 92 if sys.version_info >= (3,): 93 def __abs__(self) -> Decimal: ... 94 def __add__(self, other: _Decimal) -> Decimal: ... 95 def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... 96 def __eq__(self, other: object) -> bool: ... 97 def __floordiv__(self, other: _Decimal) -> Decimal: ... 98 def __ge__(self, other: _ComparableNum) -> bool: ... 99 def __gt__(self, other: _ComparableNum) -> bool: ... 100 def __le__(self, other: _ComparableNum) -> bool: ... 101 def __lt__(self, other: _ComparableNum) -> bool: ... 102 def __mod__(self, other: _Decimal) -> Decimal: ... 103 def __mul__(self, other: _Decimal) -> Decimal: ... 104 def __neg__(self) -> Decimal: ... 105 def __pos__(self) -> Decimal: ... 106 def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ... 107 def __radd__(self, other: _Decimal) -> Decimal: ... 108 def __rdivmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... 109 def __rfloordiv__(self, other: _Decimal) -> Decimal: ... 110 def __rmod__(self, other: _Decimal) -> Decimal: ... 111 def __rmul__(self, other: _Decimal) -> Decimal: ... 112 def __rsub__(self, other: _Decimal) -> Decimal: ... 113 def __rtruediv__(self, other: _Decimal) -> Decimal: ... 114 def __str__(self) -> str: ... 115 def __sub__(self, other: _Decimal) -> Decimal: ... 116 def __truediv__(self, other: _Decimal) -> Decimal: ... 117 else: 118 def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ... 119 def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 120 def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... 121 def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ... 122 def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 123 def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... 124 def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... 125 def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... 126 def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... 127 def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 128 def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 129 def __neg__(self, context: Optional[Context] = ...) -> Decimal: ... 130 def __pos__(self, context: Optional[Context] = ...) -> Decimal: ... 131 def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ... 132 def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 133 def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... 134 def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 135 def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 136 def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 137 def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 138 def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 139 def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ... 140 def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 141 def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 142 143 def remainder_near(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 144 145 def __float__(self) -> float: ... 146 def __int__(self) -> int: ... 147 def __trunc__(self) -> int: ... 148 @property 149 def real(self) -> Decimal: ... 150 @property 151 def imag(self) -> Decimal: ... 152 def conjugate(self) -> Decimal: ... 153 def __complex__(self) -> complex: ... 154 if sys.version_info >= (3,): 155 @overload 156 def __round__(self) -> int: ... 157 @overload 158 def __round__(self, ndigits: int) -> Decimal: ... 159 def __floor__(self) -> int: ... 160 def __ceil__(self) -> int: ... 161 else: 162 def __long__(self) -> long: ... 163 def fma(self, other: _Decimal, third: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 164 165 def __rpow__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 166 def normalize(self, context: Optional[Context] = ...) -> Decimal: ... 167 if sys.version_info >= (3,): 168 def quantize(self, exp: _Decimal, rounding: Optional[str] = ..., 169 context: Optional[Context] = ...) -> Decimal: ... 170 def same_quantum(self, other: _Decimal, context: Optional[Context] = ...) -> bool: ... 171 else: 172 def quantize(self, exp: _Decimal, rounding: Optional[str] = ..., 173 context: Optional[Context] = ..., watchexp: bool = ...) -> Decimal: ... 174 def same_quantum(self, other: _Decimal) -> bool: ... 175 def to_integral_exact(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... 176 def to_integral_value(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... 177 def to_integral(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... 178 def sqrt(self, context: Optional[Context] = ...) -> Decimal: ... 179 def max(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 180 def min(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 181 def adjusted(self) -> int: ... 182 if sys.version_info >= (3,): 183 def canonical(self) -> Decimal: ... 184 else: 185 def canonical(self, context: Optional[Context] = ...) -> Decimal: ... 186 def compare_signal(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 187 if sys.version_info >= (3,): 188 def compare_total(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 189 def compare_total_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 190 else: 191 def compare_total(self, other: _Decimal) -> Decimal: ... 192 def compare_total_mag(self, other: _Decimal) -> Decimal: ... 193 def copy_abs(self) -> Decimal: ... 194 def copy_negate(self) -> Decimal: ... 195 if sys.version_info >= (3,): 196 def copy_sign(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 197 else: 198 def copy_sign(self, other: _Decimal) -> Decimal: ... 199 def exp(self, context: Optional[Context] = ...) -> Decimal: ... 200 def is_canonical(self) -> bool: ... 201 def is_finite(self) -> bool: ... 202 def is_infinite(self) -> bool: ... 203 def is_nan(self) -> bool: ... 204 def is_normal(self, context: Optional[Context] = ...) -> bool: ... 205 def is_qnan(self) -> bool: ... 206 def is_signed(self) -> bool: ... 207 def is_snan(self) -> bool: ... 208 def is_subnormal(self, context: Optional[Context] = ...) -> bool: ... 209 def is_zero(self) -> bool: ... 210 def ln(self, context: Optional[Context] = ...) -> Decimal: ... 211 def log10(self, context: Optional[Context] = ...) -> Decimal: ... 212 def logb(self, context: Optional[Context] = ...) -> Decimal: ... 213 def logical_and(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 214 def logical_invert(self, context: Optional[Context] = ...) -> Decimal: ... 215 def logical_or(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 216 def logical_xor(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 217 def max_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 218 def min_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 219 def next_minus(self, context: Optional[Context] = ...) -> Decimal: ... 220 def next_plus(self, context: Optional[Context] = ...) -> Decimal: ... 221 def next_toward(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 222 def number_class(self, context: Optional[Context] = ...) -> str: ... 223 def radix(self) -> Decimal: ... 224 def rotate(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 225 def scaleb(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 226 def shift(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... 227 def __reduce__(self) -> Tuple[Type[Decimal], Tuple[str]]: ... 228 def __copy__(self) -> Decimal: ... 229 def __deepcopy__(self, memo: Any) -> Decimal: ... 230 def __format__(self, specifier: str, context: Optional[Context] = ...) -> str: ... 231 232class _ContextManager(object): 233 new_context: Context 234 saved_context: Context 235 def __init__(self, new_context: Context) -> None: ... 236 def __enter__(self) -> Context: ... 237 def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... 238 239_TrapType = Type[DecimalException] 240 241class Context(object): 242 prec: int 243 rounding: str 244 Emin: int 245 Emax: int 246 capitals: int 247 if sys.version_info >= (3,): 248 clamp: int 249 else: 250 _clamp: int 251 traps: Dict[_TrapType, bool] 252 flags: Dict[_TrapType, bool] 253 if sys.version_info >= (3,): 254 def __init__(self, prec: Optional[int] = ..., rounding: Optional[str] = ..., 255 Emin: Optional[int] = ..., Emax: Optional[int] = ..., 256 capitals: Optional[int] = ..., clamp: Optional[int] = ..., 257 flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., 258 traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., 259 _ignored_flags: Optional[List[_TrapType]] = ...) -> None: ... 260 else: 261 def __init__(self, prec: Optional[int] = ..., rounding: Optional[str] = ..., 262 traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., 263 flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., 264 Emin: Optional[int] = ..., Emax: Optional[int] = ..., 265 capitals: Optional[int] = ..., _clamp: Optional[int] = ..., 266 _ignored_flags: Optional[List[_TrapType]] = ...) -> None: ... 267 if sys.version_info >= (3,): 268 # __setattr__() only allows to set a specific set of attributes, 269 # already defined above. 270 def __delattr__(self, name: str) -> None: ... 271 def __reduce__(self) -> Tuple[Type[Context], Tuple[Any, ...]]: ... 272 def clear_flags(self) -> None: ... 273 if sys.version_info >= (3,): 274 def clear_traps(self) -> None: ... 275 def copy(self) -> Context: ... 276 def __copy__(self) -> Context: ... 277 __hash__: Any = ... 278 def Etiny(self) -> int: ... 279 def Etop(self) -> int: ... 280 def create_decimal(self, __num: _DecimalNew = ...) -> Decimal: ... 281 def create_decimal_from_float(self, __f: float) -> Decimal: ... 282 def abs(self, __x: _Decimal) -> Decimal: ... 283 def add(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 284 def canonical(self, __x: Decimal) -> Decimal: ... 285 def compare(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 286 def compare_signal(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 287 def compare_total(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 288 def compare_total_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 289 def copy_abs(self, __x: _Decimal) -> Decimal: ... 290 def copy_decimal(self, __x: _Decimal) -> Decimal: ... 291 def copy_negate(self, __x: _Decimal) -> Decimal: ... 292 def copy_sign(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 293 def divide(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 294 def divide_int(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 295 def divmod(self, __x: _Decimal, __y: _Decimal) -> Tuple[Decimal, Decimal]: ... 296 def exp(self, __x: _Decimal) -> Decimal: ... 297 def fma(self, __x: _Decimal, __y: _Decimal, __z: _Decimal) -> Decimal: ... 298 def is_canonical(self, __x: _Decimal) -> bool: ... 299 def is_finite(self, __x: _Decimal) -> bool: ... 300 def is_infinite(self, __x: _Decimal) -> bool: ... 301 def is_nan(self, __x: _Decimal) -> bool: ... 302 def is_normal(self, __x: _Decimal) -> bool: ... 303 def is_qnan(self, __x: _Decimal) -> bool: ... 304 def is_signed(self, __x: _Decimal) -> bool: ... 305 def is_snan(self, __x: _Decimal) -> bool: ... 306 def is_subnormal(self, __x: _Decimal) -> bool: ... 307 def is_zero(self, __x: _Decimal) -> bool: ... 308 def ln(self, __x: _Decimal) -> Decimal: ... 309 def log10(self, __x: _Decimal) -> Decimal: ... 310 def logb(self, __x: _Decimal) -> Decimal: ... 311 def logical_and(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 312 def logical_invert(self, __x: _Decimal) -> Decimal: ... 313 def logical_or(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 314 def logical_xor(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 315 def max(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 316 def max_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 317 def min(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 318 def min_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 319 def minus(self, __x: _Decimal) -> Decimal: ... 320 def multiply(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 321 def next_minus(self, __x: _Decimal) -> Decimal: ... 322 def next_plus(self, __x: _Decimal) -> Decimal: ... 323 def next_toward(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 324 def normalize(self, __x: _Decimal) -> Decimal: ... 325 def number_class(self, __x: _Decimal) -> str: ... 326 def plus(self, __x: _Decimal) -> Decimal: ... 327 def power(self, a: _Decimal, b: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ... 328 def quantize(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 329 def radix(self) -> Decimal: ... 330 def remainder(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 331 def remainder_near(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 332 def rotate(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 333 def same_quantum(self, __x: _Decimal, __y: _Decimal) -> bool: ... 334 def scaleb(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 335 def shift(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 336 def sqrt(self, __x: _Decimal) -> Decimal: ... 337 def subtract(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... 338 def to_eng_string(self, __x: _Decimal) -> str: ... 339 def to_sci_string(self, __x: _Decimal) -> str: ... 340 def to_integral_exact(self, __x: _Decimal) -> Decimal: ... 341 def to_integral_value(self, __x: _Decimal) -> Decimal: ... 342 def to_integral(self, __x: _Decimal) -> Decimal: ... 343 344DefaultContext: Context 345BasicContext: Context 346ExtendedContext: Context 347