|
1 |
| -from decimal import * |
| 1 | +import numbers |
| 2 | +import sys |
| 3 | +from _typeshed import Self |
| 4 | +from types import TracebackType |
| 5 | +from typing import Any, Container, NamedTuple, Sequence, Union, overload |
| 6 | +from typing_extensions import TypeAlias |
2 | 7 |
|
| 8 | +_Decimal: TypeAlias = Decimal | int |
| 9 | +_DecimalNew: TypeAlias = Union[Decimal, float, str, tuple[int, Sequence[int], int]] |
| 10 | +_ComparableNum: TypeAlias = Decimal | float | numbers.Rational |
| 11 | + |
| 12 | +__version__: str |
3 | 13 | __libmpdec_version__: str
|
| 14 | + |
| 15 | +class DecimalTuple(NamedTuple): |
| 16 | + sign: int |
| 17 | + digits: tuple[int, ...] |
| 18 | + exponent: int |
| 19 | + |
| 20 | +ROUND_DOWN: str |
| 21 | +ROUND_HALF_UP: str |
| 22 | +ROUND_HALF_EVEN: str |
| 23 | +ROUND_CEILING: str |
| 24 | +ROUND_FLOOR: str |
| 25 | +ROUND_UP: str |
| 26 | +ROUND_HALF_DOWN: str |
| 27 | +ROUND_05UP: str |
| 28 | + |
| 29 | +if sys.version_info >= (3, 7): |
| 30 | + HAVE_CONTEXTVAR: bool |
| 31 | +HAVE_THREADS: bool |
| 32 | +MAX_EMAX: int |
| 33 | +MAX_PREC: int |
| 34 | +MIN_EMIN: int |
| 35 | +MIN_ETINY: int |
| 36 | + |
| 37 | +class DecimalException(ArithmeticError): ... |
| 38 | +class Clamped(DecimalException): ... |
| 39 | +class InvalidOperation(DecimalException): ... |
| 40 | +class ConversionSyntax(InvalidOperation): ... |
| 41 | +class DivisionByZero(DecimalException, ZeroDivisionError): ... |
| 42 | +class DivisionImpossible(InvalidOperation): ... |
| 43 | +class DivisionUndefined(InvalidOperation, ZeroDivisionError): ... |
| 44 | +class Inexact(DecimalException): ... |
| 45 | +class InvalidContext(InvalidOperation): ... |
| 46 | +class Rounded(DecimalException): ... |
| 47 | +class Subnormal(DecimalException): ... |
| 48 | +class Overflow(Inexact, Rounded): ... |
| 49 | +class Underflow(Inexact, Rounded, Subnormal): ... |
| 50 | +class FloatOperation(DecimalException, TypeError): ... |
| 51 | + |
| 52 | +def setcontext(__context: Context) -> None: ... |
| 53 | +def getcontext() -> Context: ... |
| 54 | +def localcontext(ctx: Context | None = ...) -> _ContextManager: ... |
| 55 | + |
| 56 | +class Decimal: |
| 57 | + def __new__(cls: type[Self], value: _DecimalNew = ..., context: Context | None = ...) -> Self: ... |
| 58 | + @classmethod |
| 59 | + def from_float(cls: type[Self], __f: float) -> Self: ... |
| 60 | + def __bool__(self) -> bool: ... |
| 61 | + def compare(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 62 | + def __hash__(self) -> int: ... |
| 63 | + def as_tuple(self) -> DecimalTuple: ... |
| 64 | + def as_integer_ratio(self) -> tuple[int, int]: ... |
| 65 | + def to_eng_string(self, context: Context | None = ...) -> str: ... |
| 66 | + def __abs__(self) -> Decimal: ... |
| 67 | + def __add__(self, __other: _Decimal) -> Decimal: ... |
| 68 | + def __divmod__(self, __other: _Decimal) -> tuple[Decimal, Decimal]: ... |
| 69 | + def __eq__(self, __other: object) -> bool: ... |
| 70 | + def __floordiv__(self, __other: _Decimal) -> Decimal: ... |
| 71 | + def __ge__(self, __other: _ComparableNum) -> bool: ... |
| 72 | + def __gt__(self, __other: _ComparableNum) -> bool: ... |
| 73 | + def __le__(self, __other: _ComparableNum) -> bool: ... |
| 74 | + def __lt__(self, __other: _ComparableNum) -> bool: ... |
| 75 | + def __mod__(self, __other: _Decimal) -> Decimal: ... |
| 76 | + def __mul__(self, __other: _Decimal) -> Decimal: ... |
| 77 | + def __neg__(self) -> Decimal: ... |
| 78 | + def __pos__(self) -> Decimal: ... |
| 79 | + def __pow__(self, __other: _Decimal, __modulo: _Decimal | None = ...) -> Decimal: ... |
| 80 | + def __radd__(self, __other: _Decimal) -> Decimal: ... |
| 81 | + def __rdivmod__(self, __other: _Decimal) -> tuple[Decimal, Decimal]: ... |
| 82 | + def __rfloordiv__(self, __other: _Decimal) -> Decimal: ... |
| 83 | + def __rmod__(self, __other: _Decimal) -> Decimal: ... |
| 84 | + def __rmul__(self, __other: _Decimal) -> Decimal: ... |
| 85 | + def __rsub__(self, __other: _Decimal) -> Decimal: ... |
| 86 | + def __rtruediv__(self, __other: _Decimal) -> Decimal: ... |
| 87 | + def __sub__(self, __other: _Decimal) -> Decimal: ... |
| 88 | + def __truediv__(self, __other: _Decimal) -> Decimal: ... |
| 89 | + def remainder_near(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 90 | + def __float__(self) -> float: ... |
| 91 | + def __int__(self) -> int: ... |
| 92 | + def __trunc__(self) -> int: ... |
| 93 | + @property |
| 94 | + def real(self) -> Decimal: ... |
| 95 | + @property |
| 96 | + def imag(self) -> Decimal: ... |
| 97 | + def conjugate(self) -> Decimal: ... |
| 98 | + def __complex__(self) -> complex: ... |
| 99 | + @overload |
| 100 | + def __round__(self) -> int: ... |
| 101 | + @overload |
| 102 | + def __round__(self, __ndigits: int) -> Decimal: ... |
| 103 | + def __floor__(self) -> int: ... |
| 104 | + def __ceil__(self) -> int: ... |
| 105 | + def fma(self, other: _Decimal, third: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 106 | + def __rpow__(self, __other: _Decimal, __context: Context | None = ...) -> Decimal: ... |
| 107 | + def normalize(self, context: Context | None = ...) -> Decimal: ... |
| 108 | + def quantize(self, exp: _Decimal, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... |
| 109 | + def same_quantum(self, other: _Decimal, context: Context | None = ...) -> bool: ... |
| 110 | + def to_integral_exact(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... |
| 111 | + def to_integral_value(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... |
| 112 | + def to_integral(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... |
| 113 | + def sqrt(self, context: Context | None = ...) -> Decimal: ... |
| 114 | + def max(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 115 | + def min(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 116 | + def adjusted(self) -> int: ... |
| 117 | + def canonical(self) -> Decimal: ... |
| 118 | + def compare_signal(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 119 | + def compare_total(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 120 | + def compare_total_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 121 | + def copy_abs(self) -> Decimal: ... |
| 122 | + def copy_negate(self) -> Decimal: ... |
| 123 | + def copy_sign(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 124 | + def exp(self, context: Context | None = ...) -> Decimal: ... |
| 125 | + def is_canonical(self) -> bool: ... |
| 126 | + def is_finite(self) -> bool: ... |
| 127 | + def is_infinite(self) -> bool: ... |
| 128 | + def is_nan(self) -> bool: ... |
| 129 | + def is_normal(self, context: Context | None = ...) -> bool: ... |
| 130 | + def is_qnan(self) -> bool: ... |
| 131 | + def is_signed(self) -> bool: ... |
| 132 | + def is_snan(self) -> bool: ... |
| 133 | + def is_subnormal(self, context: Context | None = ...) -> bool: ... |
| 134 | + def is_zero(self) -> bool: ... |
| 135 | + def ln(self, context: Context | None = ...) -> Decimal: ... |
| 136 | + def log10(self, context: Context | None = ...) -> Decimal: ... |
| 137 | + def logb(self, context: Context | None = ...) -> Decimal: ... |
| 138 | + def logical_and(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 139 | + def logical_invert(self, context: Context | None = ...) -> Decimal: ... |
| 140 | + def logical_or(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 141 | + def logical_xor(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 142 | + def max_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 143 | + def min_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 144 | + def next_minus(self, context: Context | None = ...) -> Decimal: ... |
| 145 | + def next_plus(self, context: Context | None = ...) -> Decimal: ... |
| 146 | + def next_toward(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 147 | + def number_class(self, context: Context | None = ...) -> str: ... |
| 148 | + def radix(self) -> Decimal: ... |
| 149 | + def rotate(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 150 | + def scaleb(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 151 | + def shift(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... |
| 152 | + def __reduce__(self: Self) -> tuple[type[Self], tuple[str]]: ... |
| 153 | + def __copy__(self: Self) -> Self: ... |
| 154 | + def __deepcopy__(self: Self, __memo: Any) -> Self: ... |
| 155 | + def __format__(self, __specifier: str, __context: Context | None = ...) -> str: ... |
| 156 | + |
| 157 | +class _ContextManager: |
| 158 | + new_context: Context |
| 159 | + saved_context: Context |
| 160 | + def __init__(self, new_context: Context) -> None: ... |
| 161 | + def __enter__(self) -> Context: ... |
| 162 | + def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... |
| 163 | + |
| 164 | +_TrapType: TypeAlias = type[DecimalException] |
| 165 | + |
| 166 | +class Context: |
| 167 | + prec: int |
| 168 | + rounding: str |
| 169 | + Emin: int |
| 170 | + Emax: int |
| 171 | + capitals: int |
| 172 | + clamp: int |
| 173 | + traps: dict[_TrapType, bool] |
| 174 | + flags: dict[_TrapType, bool] |
| 175 | + def __init__( |
| 176 | + self, |
| 177 | + prec: int | None = ..., |
| 178 | + rounding: str | None = ..., |
| 179 | + Emin: int | None = ..., |
| 180 | + Emax: int | None = ..., |
| 181 | + capitals: int | None = ..., |
| 182 | + clamp: int | None = ..., |
| 183 | + flags: None | dict[_TrapType, bool] | Container[_TrapType] = ..., |
| 184 | + traps: None | dict[_TrapType, bool] | Container[_TrapType] = ..., |
| 185 | + _ignored_flags: list[_TrapType] | None = ..., |
| 186 | + ) -> None: ... |
| 187 | + # __setattr__() only allows to set a specific set of attributes, |
| 188 | + # already defined above. |
| 189 | + def __delattr__(self, __name: str) -> None: ... |
| 190 | + def __reduce__(self: Self) -> tuple[type[Self], tuple[Any, ...]]: ... |
| 191 | + def clear_flags(self) -> None: ... |
| 192 | + def clear_traps(self) -> None: ... |
| 193 | + def copy(self) -> Context: ... |
| 194 | + def __copy__(self) -> Context: ... |
| 195 | + __hash__: Any |
| 196 | + def Etiny(self) -> int: ... |
| 197 | + def Etop(self) -> int: ... |
| 198 | + def create_decimal(self, __num: _DecimalNew = ...) -> Decimal: ... |
| 199 | + def create_decimal_from_float(self, __f: float) -> Decimal: ... |
| 200 | + def abs(self, __x: _Decimal) -> Decimal: ... |
| 201 | + def add(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 202 | + def canonical(self, __x: Decimal) -> Decimal: ... |
| 203 | + def compare(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 204 | + def compare_signal(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 205 | + def compare_total(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 206 | + def compare_total_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 207 | + def copy_abs(self, __x: _Decimal) -> Decimal: ... |
| 208 | + def copy_decimal(self, __x: _Decimal) -> Decimal: ... |
| 209 | + def copy_negate(self, __x: _Decimal) -> Decimal: ... |
| 210 | + def copy_sign(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 211 | + def divide(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 212 | + def divide_int(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 213 | + def divmod(self, __x: _Decimal, __y: _Decimal) -> tuple[Decimal, Decimal]: ... |
| 214 | + def exp(self, __x: _Decimal) -> Decimal: ... |
| 215 | + def fma(self, __x: _Decimal, __y: _Decimal, __z: _Decimal) -> Decimal: ... |
| 216 | + def is_canonical(self, __x: _Decimal) -> bool: ... |
| 217 | + def is_finite(self, __x: _Decimal) -> bool: ... |
| 218 | + def is_infinite(self, __x: _Decimal) -> bool: ... |
| 219 | + def is_nan(self, __x: _Decimal) -> bool: ... |
| 220 | + def is_normal(self, __x: _Decimal) -> bool: ... |
| 221 | + def is_qnan(self, __x: _Decimal) -> bool: ... |
| 222 | + def is_signed(self, __x: _Decimal) -> bool: ... |
| 223 | + def is_snan(self, __x: _Decimal) -> bool: ... |
| 224 | + def is_subnormal(self, __x: _Decimal) -> bool: ... |
| 225 | + def is_zero(self, __x: _Decimal) -> bool: ... |
| 226 | + def ln(self, __x: _Decimal) -> Decimal: ... |
| 227 | + def log10(self, __x: _Decimal) -> Decimal: ... |
| 228 | + def logb(self, __x: _Decimal) -> Decimal: ... |
| 229 | + def logical_and(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 230 | + def logical_invert(self, __x: _Decimal) -> Decimal: ... |
| 231 | + def logical_or(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 232 | + def logical_xor(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 233 | + def max(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 234 | + def max_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 235 | + def min(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 236 | + def min_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 237 | + def minus(self, __x: _Decimal) -> Decimal: ... |
| 238 | + def multiply(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 239 | + def next_minus(self, __x: _Decimal) -> Decimal: ... |
| 240 | + def next_plus(self, __x: _Decimal) -> Decimal: ... |
| 241 | + def next_toward(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 242 | + def normalize(self, __x: _Decimal) -> Decimal: ... |
| 243 | + def number_class(self, __x: _Decimal) -> str: ... |
| 244 | + def plus(self, __x: _Decimal) -> Decimal: ... |
| 245 | + def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = ...) -> Decimal: ... |
| 246 | + def quantize(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 247 | + def radix(self) -> Decimal: ... |
| 248 | + def remainder(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 249 | + def remainder_near(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 250 | + def rotate(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 251 | + def same_quantum(self, __x: _Decimal, __y: _Decimal) -> bool: ... |
| 252 | + def scaleb(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 253 | + def shift(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 254 | + def sqrt(self, __x: _Decimal) -> Decimal: ... |
| 255 | + def subtract(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... |
| 256 | + def to_eng_string(self, __x: _Decimal) -> str: ... |
| 257 | + def to_sci_string(self, __x: _Decimal) -> str: ... |
| 258 | + def to_integral_exact(self, __x: _Decimal) -> Decimal: ... |
| 259 | + def to_integral_value(self, __x: _Decimal) -> Decimal: ... |
| 260 | + def to_integral(self, __x: _Decimal) -> Decimal: ... |
| 261 | + |
| 262 | +DefaultContext: Context |
| 263 | +BasicContext: Context |
| 264 | +ExtendedContext: Context |
0 commit comments