Skip to content

Commit 9a853c4

Browse files
Merge pull request #287 from oscarbenjamin/pr_explicit_imports
Start adding type annotations
2 parents da6f712 + cff0dcf commit 9a853c4

File tree

10 files changed

+984
-191
lines changed

10 files changed

+984
-191
lines changed

src/flint/__init__.py

Lines changed: 84 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
from .pyflint import *
1+
from .pyflint import ctx
22

3-
from .types.fmpz import *
4-
from .types.fmpz_poly import *
5-
from .types.fmpz_mat import *
6-
from .types.fmpz_series import *
3+
from .types.fmpz import fmpz
4+
from .types.fmpz_poly import fmpz_poly
5+
from .types.fmpz_mat import fmpz_mat
6+
from .types.fmpz_series import fmpz_series
77
from .types.fmpz_vec import fmpz_vec
88

9-
from .types.fmpq import *
10-
from .types.fmpq_poly import *
11-
from .types.fmpq_mat import *
12-
from .types.fmpq_series import *
9+
from .types.fmpq import fmpq
10+
from .types.fmpq_poly import fmpq_poly
11+
from .types.fmpq_mat import fmpq_mat
12+
from .types.fmpq_series import fmpq_series
1313
from .types.fmpq_vec import fmpq_vec
1414

15-
from .types.nmod import *
16-
from .types.nmod_poly import *
15+
from .types.nmod import nmod
16+
from .types.nmod_poly import nmod_poly
1717
from .types.nmod_mpoly import nmod_mpoly_ctx, nmod_mpoly, nmod_mpoly_vec
18-
from .types.nmod_mat import *
19-
from .types.nmod_series import *
18+
from .types.nmod_mat import nmod_mat
19+
from .types.nmod_series import nmod_series
2020

2121
from .types.fmpz_mpoly import fmpz_mpoly_ctx, fmpz_mpoly, fmpz_mpoly_vec
22-
from .types.fmpz_mod import *
23-
from .types.fmpz_mod_poly import *
22+
from .types.fmpz_mod import fmpz_mod, fmpz_mod_ctx
23+
from .types.fmpz_mod_poly import fmpz_mod_poly, fmpz_mod_poly_ctx
2424
from .types.fmpz_mod_mpoly import fmpz_mod_mpoly_ctx, fmpz_mod_mpoly, fmpz_mod_mpoly_vec
2525
from .types.fmpz_mod_mat import fmpz_mod_mat
2626

2727
from .types.fmpq_mpoly import fmpq_mpoly_ctx, fmpq_mpoly, fmpq_mpoly_vec
2828

29-
from .types.fq_default import *
30-
from .types.fq_default_poly import *
29+
from .types.fq_default import fq_default, fq_default_ctx
30+
from .types.fq_default_poly import fq_default_poly, fq_default_poly_ctx
3131

32-
from .types.arf import *
33-
from .types.arb import *
34-
from .types.arb_poly import *
35-
from .types.arb_mat import *
36-
from .types.arb_series import *
37-
from .types.acb import *
38-
from .types.acb_poly import *
39-
from .types.acb_mat import *
40-
from .types.acb_series import *
32+
from .types.arf import arf
33+
from .types.arb import arb
34+
from .types.arb_poly import arb_poly
35+
from .types.arb_mat import arb_mat
36+
from .types.arb_series import arb_series
37+
from .types.acb import acb
38+
from .types.acb_poly import acb_poly
39+
from .types.acb_mat import acb_mat
40+
from .types.acb_series import acb_series
4141

42-
from .types.dirichlet import *
42+
from .types.dirichlet import dirichlet_char, dirichlet_group
4343
from .functions.showgood import good, showgood
4444

4545
from .flint_base.flint_base import (
@@ -48,4 +48,60 @@
4848
Ordering,
4949
)
5050

51-
__version__ = '0.7.1'
51+
__version__ = "0.7.1"
52+
53+
__all__ = [
54+
"ctx",
55+
"fmpz",
56+
"fmpz_poly",
57+
"fmpz_mat",
58+
"fmpz_series",
59+
"fmpz_vec",
60+
"fmpq",
61+
"fmpq_poly",
62+
"fmpq_mat",
63+
"fmpq_series",
64+
"fmpq_vec",
65+
"nmod",
66+
"nmod_poly",
67+
"nmod_mpoly_ctx",
68+
"nmod_mpoly",
69+
"nmod_mpoly_vec",
70+
"nmod_mat",
71+
"nmod_series",
72+
"fmpz_mpoly_ctx",
73+
"fmpz_mpoly",
74+
"fmpz_mpoly_vec",
75+
"fmpz_mod",
76+
"fmpz_mod_ctx",
77+
"fmpz_mod_poly",
78+
"fmpz_mod_poly_ctx",
79+
"fmpz_mod_mpoly_ctx",
80+
"fmpz_mod_mpoly",
81+
"fmpz_mod_mpoly_vec",
82+
"fmpz_mod_mat",
83+
"fmpq_mpoly_ctx",
84+
"fmpq_mpoly",
85+
"fmpq_mpoly_vec",
86+
"fq_default",
87+
"fq_default_ctx",
88+
"fq_default_poly",
89+
"fq_default_poly_ctx",
90+
"arf",
91+
"arb",
92+
"arb_poly",
93+
"arb_mat",
94+
"arb_series",
95+
"acb",
96+
"acb_poly",
97+
"acb_mat",
98+
"acb_series",
99+
"dirichlet_char",
100+
"dirichlet_group",
101+
"good",
102+
"showgood",
103+
"Ordering",
104+
"__FLINT_VERSION__",
105+
"__FLINT_RELEASE__",
106+
"__version__",
107+
]
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)