-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathfractions.pyi
151 lines (147 loc) · 5.15 KB
/
fractions.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import sys
from _typeshed import Self
from decimal import Decimal
from numbers import Integral, Rational, Real
from typing import Any, overload
from typing_extensions import Literal, TypeAlias
_ComparableNum: TypeAlias = int | float | Decimal | Real
if sys.version_info >= (3, 9):
__all__ = ["Fraction"]
else:
__all__ = ["Fraction", "gcd"]
@overload
def gcd(a: int, b: int) -> int: ...
@overload
def gcd(a: Integral, b: int) -> Integral: ...
@overload
def gcd(a: int, b: Integral) -> Integral: ...
@overload
def gcd(a: Integral, b: Integral) -> Integral: ...
class Fraction(Rational):
@overload
def __new__(
cls: type[Self], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ...
) -> Self: ...
@overload
def __new__(cls: type[Self], __value: float | Decimal | str, *, _normalize: bool = ...) -> Self: ...
@classmethod
def from_float(cls: type[Self], f: float) -> Self: ...
@classmethod
def from_decimal(cls: type[Self], dec: Decimal) -> Self: ...
def limit_denominator(self, max_denominator: int = ...) -> Fraction: ...
if sys.version_info >= (3, 8):
def as_integer_ratio(self) -> tuple[int, int]: ...
@property
def numerator(self) -> int: ...
@property
def denominator(self) -> int: ...
@overload
def __add__(self, b: int | Fraction) -> Fraction: ...
@overload
def __add__(self, b: float) -> float: ...
@overload
def __add__(self, b: complex) -> complex: ...
@overload
def __radd__(self, a: int | Fraction) -> Fraction: ...
@overload
def __radd__(self, a: float) -> float: ...
@overload
def __radd__(self, a: complex) -> complex: ...
@overload
def __sub__(self, b: int | Fraction) -> Fraction: ...
@overload
def __sub__(self, b: float) -> float: ...
@overload
def __sub__(self, b: complex) -> complex: ...
@overload
def __rsub__(self, a: int | Fraction) -> Fraction: ...
@overload
def __rsub__(self, a: float) -> float: ...
@overload
def __rsub__(self, a: complex) -> complex: ...
@overload
def __mul__(self, b: int | Fraction) -> Fraction: ...
@overload
def __mul__(self, b: float) -> float: ...
@overload
def __mul__(self, b: complex) -> complex: ...
@overload
def __rmul__(self, a: int | Fraction) -> Fraction: ...
@overload
def __rmul__(self, a: float) -> float: ...
@overload
def __rmul__(self, a: complex) -> complex: ...
@overload
def __truediv__(self, b: int | Fraction) -> Fraction: ...
@overload
def __truediv__(self, b: float) -> float: ...
@overload
def __truediv__(self, b: complex) -> complex: ...
@overload
def __rtruediv__(self, a: int | Fraction) -> Fraction: ...
@overload
def __rtruediv__(self, a: float) -> float: ...
@overload
def __rtruediv__(self, a: complex) -> complex: ...
@overload
def __floordiv__(self, b: int | Fraction) -> int: ...
@overload
def __floordiv__(self, b: float) -> float: ...
@overload
def __rfloordiv__(self, a: int | Fraction) -> int: ...
@overload
def __rfloordiv__(self, a: float) -> float: ...
@overload
def __mod__(self, b: int | Fraction) -> Fraction: ...
@overload
def __mod__(self, b: float) -> float: ...
@overload
def __rmod__(self, a: int | Fraction) -> Fraction: ...
@overload
def __rmod__(self, a: float) -> float: ...
@overload
def __divmod__(self, b: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __divmod__(self, b: float) -> tuple[float, Fraction]: ...
@overload
def __rdivmod__(self, a: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __rdivmod__(self, a: float) -> tuple[float, Fraction]: ...
@overload
def __pow__(self, b: int) -> Fraction: ...
@overload
def __pow__(self, b: float | Fraction) -> float: ...
@overload
def __pow__(self, b: complex) -> complex: ...
@overload
def __rpow__(self, a: int | float | Fraction) -> float: ...
@overload
def __rpow__(self, a: complex) -> complex: ...
def __pos__(self) -> Fraction: ...
def __neg__(self) -> Fraction: ...
def __abs__(self) -> Fraction: ...
def __trunc__(self) -> int: ...
def __floor__(self) -> int: ...
def __ceil__(self) -> int: ...
@overload
def __round__(self, ndigits: None = ...) -> int: ...
@overload
def __round__(self, ndigits: int) -> Fraction: ...
def __hash__(self) -> int: ...
def __eq__(self, b: object) -> bool: ...
def __lt__(self, b: _ComparableNum) -> bool: ...
def __gt__(self, b: _ComparableNum) -> bool: ...
def __le__(self, b: _ComparableNum) -> bool: ...
def __ge__(self, b: _ComparableNum) -> bool: ...
def __bool__(self) -> bool: ...
def __copy__(self: Self) -> Self: ...
def __deepcopy__(self: Self, memo: Any) -> Self: ...
if sys.version_info >= (3, 11):
def __int__(self) -> int: ...
# Not actually defined within fractions.py, but provides more useful
# overrides
@property
def real(self) -> Fraction: ...
@property
def imag(self) -> Literal[0]: ...
def conjugate(self) -> Fraction: ...