Skip to content

Commit 267a49c

Browse files
committed
Add type annotations for fmpz, fmpq, nmod and their mpoly counterparts
1 parent 13eb466 commit 267a49c

File tree

8 files changed

+582
-76
lines changed

8 files changed

+582
-76
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#
2+
#
3+
#
4+
from typing import Generic, TypeVar, Iterator, Iterable, Any, Final, Self, Mapping
5+
import enum
6+
7+
8+
FLINT_VERSION: Final[str]
9+
FLINT_RELEASE: Final[int]
10+
11+
12+
Telem = TypeVar('Telem', bound=flint_scalar)
13+
Telem_coerce = TypeVar('Telem_coerce')
14+
Tmpoly = TypeVar('Tmpoly', bound=flint_mpoly)
15+
Tctx = TypeVar('Tctx', bound=flint_mpoly_context)
16+
17+
Sctx = TypeVar('Sctx', bound=flint_mpoly_context)
18+
19+
20+
class flint_elem:
21+
pass
22+
23+
24+
class flint_scalar(flint_elem):
25+
def is_zero(self) -> bool: ...
26+
27+
28+
class flint_poly(flint_elem, Generic[Telem]):
29+
def __iter__(self) -> Iterator[Telem]: ...
30+
def __getitem__(self, index: int) -> Telem: ...
31+
def coeffs(self) -> list[Telem]: ...
32+
def str(self, ascending: bool = False, var: str = "x", *args: Any, **kwargs: Any): ...
33+
def roots(self) -> list[tuple[Telem, int]]: ...
34+
# Should be list[arb]:
35+
def real_roots(self) -> list[Any]: ...
36+
# Should be list[acb]:
37+
def complex_roots(self) -> list[Any]: ...
38+
39+
40+
class Ordering(enum.Enum):
41+
lex = "lex"
42+
deglex = "deglex"
43+
degrevlex = "degrevlex"
44+
45+
46+
class flint_mpoly(flint_elem, Generic[Tctx, Telem, Telem_coerce]):
47+
def __init__(self,
48+
val: Self | Telem | Telem_coerce | int | dict[tuple[int, ...], Telem | Telem_coerce | int] | str = 0,
49+
ctx: Tctx | None = None
50+
) -> None: ...
51+
52+
def str(self) -> str: ...
53+
def repr(self) -> str: ...
54+
55+
def context(self) -> Tctx: ...
56+
57+
def degrees(self) -> tuple[int, ...]: ...
58+
def total_degree(self) -> int: ...
59+
60+
def leading_coefficient(self) -> Telem: ...
61+
def to_dict(self) -> dict[tuple[int, ...], Telem]: ...
62+
def terms(self) -> Iterable[tuple[tuple[int, ...], Telem]]: ...
63+
64+
def is_one(self) -> bool: ...
65+
def is_zero(self) -> bool: ...
66+
def is_constant(self) -> bool: ...
67+
68+
def __len__(self) -> int: ...
69+
def coefficient(self, i: int) -> Telem: ...
70+
def monomial(self, i: int) -> tuple[int, ...]: ...
71+
72+
def monoms(self) -> list[tuple[int, ...]]: ...
73+
def coeffs(self) -> list[Telem]: ...
74+
def __getitem__(self, index: tuple[int, ...]) -> Telem: ...
75+
def __setitem__(self, index: tuple[int, ...], coeff: Telem | Telem_coerce | int) -> None: ...
76+
77+
def subs(self, mapping: dict[str | int, Telem | Telem_coerce | int]) -> Self: ...
78+
def compose(self, *args: Self, ctx: Tctx | None = None) -> Self: ...
79+
80+
def __call__(self, *args: Telem | Telem_coerce) -> Telem: ...
81+
82+
def __pos__(self) -> Self: ...
83+
def __neg__(self) -> Self: ...
84+
def __add__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
85+
def __radd__(self, other: Telem | Telem_coerce | int) -> Self: ...
86+
def __sub__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
87+
def __rsub__(self, other: Telem | Telem_coerce | int) -> Self: ...
88+
def __mul__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
89+
def __rmul__(self, other: Telem | Telem_coerce | int) -> Self: ...
90+
def __truediv__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
91+
def __rtruediv__(self, other: Telem | Telem_coerce | int) -> Self: ...
92+
def __floordiv__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
93+
def __rfloordiv__(self, other: Telem | Telem_coerce | int) -> Self: ...
94+
def __mod__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
95+
def __rmod__(self, other: Telem | Telem_coerce | int) -> Self: ...
96+
def __divmod__(self, other: Self | Telem | Telem_coerce | int) -> tuple[Self, Self]: ...
97+
def __rdivmod__(self, other: Telem | Telem_coerce | int) -> tuple[Self, Self]: ...
98+
def __pow__(self, other: Telem | Telem_coerce | int) -> Self: ...
99+
def __rpow__(self, other: Telem | Telem_coerce | int) -> Self: ...
100+
def __iter__(self) -> Iterable[tuple[int, ...]]: ...
101+
def __contains__(self, index: tuple[int, ...]) -> bool: ...
102+
103+
def unused_gens(self) -> tuple[str, ...]: ...
104+
105+
def project_to_context(
106+
self,
107+
other_ctx: Tctx,
108+
mapping: dict[str | int, str | int] | None = None
109+
) -> Self: ...
110+
111+
112+
class flint_mpoly_context(flint_elem, Generic[Tmpoly, Telem, Telem_coerce]):
113+
114+
def nvars(self) -> int: ...
115+
def ordering(self) -> Ordering: ...
116+
117+
def gen(self, i: int) -> Tmpoly: ...
118+
def from_dict(self, d: Mapping[tuple[int, ...], Telem_coerce]) -> Tmpoly: ...
119+
def constant(self, z: Telem_coerce) -> Tmpoly: ...
120+
121+
def name(self, i: int) -> str: ...
122+
def names(self) -> tuple[str]: ...
123+
def gens(self) -> tuple[Tmpoly, ...]: ...
124+
def variable_to_index(self, var: str) -> int: ...
125+
def term(self, coeff: Telem_coerce | None = None, exp_vec: Iterable[int] | None = None) -> Tmpoly: ...
126+
def drop_gens(self, gens: Iterable[str | int]) -> Self: ...
127+
def append_gens(self, gens: Iterable[str | int]) -> Self: ...
128+
def infer_generator_mapping(self, ctx: flint_mpoly_context) -> dict[int, int]: ...
129+
130+
@classmethod
131+
def from_context(cls,
132+
ctx: Sctx,
133+
names: str | Iterable[str | tuple[str, int]] | tuple[str, int] | None = None,
134+
ordering: Ordering | str = Ordering.lex,
135+
) -> Sctx:
136+
...

0 commit comments

Comments
 (0)