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