Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions src/flint/flint_base/flint_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,22 @@ class flint_poly(flint_elem, Generic[Telem]):
def length(self) -> int: ...
def degree(self) -> int: ...
def coeffs(self) -> list[Telem]: ...
@overload
def __call__(self, other: Telem | int, /) -> Telem: ...
@overload
def __call__(self, other: Self, /) -> Self: ...
def __pos__(self) -> Self: ...
def __neg__(self) -> Self: ...
def __add__(self, other: Telem | int | Self, /) -> Self: ...
def __add__(self, other: Telem | int, /) -> Self: ...
def __radd__(self, other: Telem | int, /) -> Self: ...
def __sub__(self, other: Telem | int | Self, /) -> Self: ...
def __sub__(self, other: Telem | int, /) -> Self: ...
def __rsub__(self, other: Telem | int, /) -> Self: ...
def __mul__(self, other: Telem | int | Self, /) -> Self: ...
def __mul__(self, other: Telem | int, /) -> Self: ...
def __rmul__(self, other: Telem | int, /) -> Self: ...
def __truediv__(self, other: Telem | int | Self, /) -> Self: ...
def __truediv__(self, other: Telem | int, /) -> Self: ...
def __rtruediv__(self, other: Telem | int, /) -> Self: ...
def __floordiv__(self, other: Telem | int | Self, /) -> Self: ...
def __floordiv__(self, other: Telem | int, /) -> Self: ...
def __rfloordiv__(self, other: Telem | int, /) -> Self: ...
def __mod__(self, other: Telem | int | Self, /) -> Self: ...
def __mod__(self, other: Telem | int, /) -> Self: ...
def __rmod__(self, other: Telem | int, /) -> Self: ...
def __divmod__(self, other: Telem | int | Self, /) -> tuple[Self, Self]: ...
def __divmod__(self, other: Telem | int, /) -> tuple[Self, Self]: ...
def __rdivmod__(self, other: Telem | int, /) -> tuple[Self, Self]: ...
def __pow__(self, other: int, /) -> Self: ...
def is_zero(self) -> bool: ...
Expand Down Expand Up @@ -130,41 +127,38 @@ class flint_mpoly(flint_elem, Generic[Tctx, Telem, Telem_coerce]):
def coeffs(self) -> list[Telem]: ...
def __pos__(self) -> Self: ...
def __neg__(self) -> Self: ...
def __add__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
def __add__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __radd__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __sub__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
def __sub__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __rsub__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __mul__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
def __mul__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __rmul__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __truediv__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
def __truediv__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __rtruediv__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __floordiv__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
def __floordiv__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __rfloordiv__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __mod__(self, other: Self | Telem | Telem_coerce | int) -> Self: ...
def __mod__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __rmod__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __divmod__(
self, other: Self | Telem | Telem_coerce | int
self, other: Telem | Telem_coerce | int
) -> tuple[Self, Self]: ...
def __rdivmod__(self, other: Telem | Telem_coerce | int) -> tuple[Self, Self]: ...
def __pow__(self, other: Telem | Telem_coerce | int) -> Self: ...
def __rpow__(self, other: Telem | Telem_coerce | int) -> Self: ...
def iadd(self, other: Telem | Telem_coerce | int) -> None: ...
def isub(self, other: Telem | Telem_coerce | int) -> None: ...
def imul(self, other: Telem | Telem_coerce | int) -> None: ...
def gcd(self, other: Self) -> Self: ...
def term_content(self) -> Self: ...
def factor(self) -> tuple[Telem, Sequence[tuple[Self, int]]]: ...
def factor_squarefree(self) -> tuple[Telem, Sequence[tuple[Self, int]]]: ...
def sqrt(self) -> Self: ...
def resultant(self, other: Self, var: _str | int) -> Self: ...
def discriminant(self, var: _str | int) -> Self: ...
def deflation_index(self) -> tuple[list[int], list[int]]: ...
def deflation(self) -> tuple[Self, list[int]]: ...
def deflation_monom(self) -> tuple[Self, list[int], Self]: ...
def inflate(self, N: list[int]) -> Self: ...
def deflate(self, N: list[int]) -> Self: ...
def subs(self, mapping: dict[_str | int, Telem | Telem_coerce | int]) -> Self: ...
def compose(self, *args: Self, ctx: Tctx | None = None) -> Self: ...
def __call__(self, *args: Telem | Telem_coerce) -> Telem: ...
def derivative(self, var: _str | int) -> Self: ...
def unused_gens(self) -> tuple[_str, ...]: ...
Expand Down Expand Up @@ -193,14 +187,14 @@ class flint_mpoly_context(flint_elem, Generic[Tmpoly, Telem, Telem_coerce]):
@classmethod
def from_context(
cls,
ctx: Sctx,
ctx: flint_mpoly_context,
names: str | Iterable[str | tuple[str, int]] | tuple[str, int] | None = None,
ordering: Ordering | str = Ordering.lex,
) -> Sctx: ...
) -> Self: ...

class flint_mod_mpoly_context(flint_mpoly_context[Tmpoly, Telem, Telem_coerce]):
@abstractmethod
def modulus(self) -> int: ...
def modulus(self): ...

class flint_series(flint_elem, Generic[Telem]):
"""Base class for power series."""
Expand Down
16 changes: 9 additions & 7 deletions src/flint/test/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def raises(f, exception) -> bool:
Tscalar = TypeVar('Tscalar', bound=flint_base.flint_scalar)
Tscalar_co = TypeVar('Tscalar_co', bound=flint_base.flint_scalar, covariant=True)
Tmpoly = TypeVar('Tmpoly', bound=flint_base.flint_mpoly)
Tmpoly_p = TypeVar('Tmpoly_p', bound=typ.mpoly_p)
Tmpolyctx_co = TypeVar('Tmpolyctx_co', bound=flint_base.flint_mpoly_context, covariant=True)
Tmpolyctx_p_co = TypeVar('Tmpolyctx_p_co', bound=typ.mpoly_context_p, covariant=True)


_default_ctx_string = """\
Expand Down Expand Up @@ -2620,7 +2622,7 @@ def _all_polys() -> list[tuple[Any, Any, bool, flint.fmpz]]:


Tpoly = TypeVar("Tpoly", bound=typ.epoly_p)
Tc = TypeVar("Tc", bound=flint_base.flint_scalar)
Tc = TypeVar("Tc", bound=typ.scalar_p)
TS = Callable[[Tc | int], Tc]
TP = Callable[[Tpoly | Sequence[Tc | int] | Tc | int], Tpoly]
_PolyTestCase = tuple[TP[Tpoly,Tc], TS[Tc], bool, flint.fmpz]
Expand Down Expand Up @@ -3093,17 +3095,17 @@ def _all_mpolys(): # -> _all_mpolys_type:
)


class _GetMPolyCtx(Protocol[Tmpolyctx_co]):
class _GetMPolyCtx(Protocol[Tmpolyctx_p_co]):
def __call__(self,
names: Iterable[str | tuple[str, int]] | tuple[str, int],
ordering: str | flint.Ordering = "lex"
) -> Tmpolyctx_co:
) -> Tmpolyctx_p_co:
...


_MPolyTestCase = tuple[
type[Tmpoly],
_GetMPolyCtx['flint_base.flint_mpoly_context[Tmpoly, Tscalar, int]'],
type[Tmpoly_p],
_GetMPolyCtx[typ.mpoly_context_p[Tmpoly_p, Tscalar]],
Callable[[int], Tscalar],
bool,
flint.fmpz
Expand Down Expand Up @@ -3176,7 +3178,7 @@ def wrapper():


@all_mpolys
def test_mpolys_constructor(args: _MPolyTestCase[Tmpoly, Tscalar]) -> None:
def test_mpolys_constructor(args: _MPolyTestCase[Tmpoly_p, Tscalar]) -> None:
P, get_context, S, _, _ = args

ctx = get_context(("x", 2))
Expand Down Expand Up @@ -3301,7 +3303,7 @@ def quick_poly():


@all_mpolys
def test_mpolys_properties(args: _MPolyTestCase[Tmpoly, Tscalar]) -> None:
def test_mpolys_properties(args: _MPolyTestCase[Tmpoly_p, Tscalar]) -> None:

P, get_context, S, is_field, characteristic = args

Expand Down
33 changes: 25 additions & 8 deletions src/flint/types/fmpq_mpoly.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable, Mapping
from typing import Iterable, Mapping, Any
from ..flint_base.flint_base import flint_mpoly, flint_mpoly_context, Ordering
from .fmpz import fmpz
from .fmpq import fmpq
Expand All @@ -20,15 +20,32 @@ class fmpq_mpoly_ctx(flint_mpoly_context[fmpq_mpoly, fmpq, ifmpq]):

def nvars(self) -> int: ...
def ordering(self) -> Ordering: ...

def gen(self, i: int) -> fmpq_mpoly: ...
def from_dict(self, d: Mapping[tuple[int, ...], ifmpq]) -> fmpq_mpoly: ...
def constant(self, z: ifmpq) -> fmpq_mpoly: ...

def gen(self, i: int, /) -> fmpq_mpoly: ...
def from_dict(self, d: Mapping[tuple[int, ...], ifmpq], /) -> fmpq_mpoly: ...
def constant(self, q: ifmpq, /) -> fmpq_mpoly: ...
def name(self, i: int, /) -> str: ...
def names(self) -> tuple[str]: ...
def gens(self) -> tuple[fmpq_mpoly, ...]: ...
def variable_to_index(self, var: str, /) -> int: ...
def term(
self, coeff: ifmpq | None = None, exp_vec: Iterable[int] | None = None
) -> fmpq_mpoly: ...
def drop_gens(self, gens: Iterable[str | int], /) -> fmpq_mpoly_ctx: ...
def append_gens(self, gens: Iterable[str | int], /) -> fmpq_mpoly_ctx: ...
def infer_generator_mapping(
self, ctx: flint_mpoly_context, /
) -> dict[int, int]: ...
@classmethod
def from_context(
cls,
ctx: flint_mpoly_context[Any, Any, Any],
names: str | Iterable[str | tuple[str, int]] | tuple[str, int] | None = None,
ordering: Ordering | str = Ordering.lex,
) -> fmpq_mpoly_ctx: ...

class fmpq_mpoly(flint_mpoly[fmpq_mpoly_ctx, fmpq, ifmpq]):
def __init__(self,
val: fmpq_mpoly | fmpz_mpoly | ifmpq | dict[tuple[int, ...], ifmpq] | _str = 0,
val: fmpq_mpoly | fmpz_mpoly | ifmpq | Mapping[tuple[int, ...], ifmpq] | _str = 0,
ctx: fmpq_mpoly_ctx | None = None
) -> None: ...

Expand All @@ -53,7 +70,7 @@ class fmpq_mpoly(flint_mpoly[fmpq_mpoly_ctx, fmpq, ifmpq]):
def __getitem__(self, index: tuple[int, ...]) -> fmpq: ...
def __setitem__(self, index: tuple[int, ...], coeff: ifmpq) -> None: ...

def subs(self, mapping: dict[_str | int, ifmpq]) -> fmpq_mpoly: ...
def subs(self, mapping: Mapping[_str | int, ifmpq]) -> fmpq_mpoly: ...
def compose(self, *args: fmpq_mpoly, ctx: fmpq_mpoly_ctx | None = None) -> fmpq_mpoly: ...

def __call__(self, *args: ifmpq) -> fmpq: ...
Expand Down
43 changes: 35 additions & 8 deletions src/flint/types/fmpz_mod_mpoly.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from typing import Iterable, Mapping
from ..flint_base.flint_base import flint_mpoly, flint_mod_mpoly_context, Ordering
from typing import Iterable, Mapping, Any
from ..flint_base.flint_base import (
flint_mpoly,
flint_mpoly_context,
flint_mod_mpoly_context,
Ordering,
)
from .fmpz import fmpz
from .fmpz_mod import fmpz_mod
from .fmpz_mpoly import fmpz_mpoly
Expand All @@ -17,21 +22,43 @@ class fmpz_mod_mpoly_ctx(flint_mod_mpoly_context[fmpz_mod_mpoly, fmpz_mod, ifmpz
names: _str | Iterable[_str | tuple[_str, int]] | tuple[_str, int],
ordering: Ordering | _str = Ordering.lex,
*,
modulus: ifmpz,
modulus: int,
) -> fmpz_mod_mpoly_ctx:
...

def modulus(self) -> fmpz: ...

def nvars(self) -> int: ...
def ordering(self) -> Ordering: ...
def modulus(self) -> int: ...
def gen(self, i: int, /) -> fmpz_mod_mpoly: ...
def constant(self, z: ifmpz_mod) -> fmpz_mod_mpoly: ...

def gen(self, i: int) -> fmpz_mod_mpoly: ...
def from_dict(self, d: Mapping[tuple[int, ...], ifmpz_mod]) -> fmpz_mod_mpoly: ...
def constant(self, z: ifmpz_mod) -> fmpz_mod_mpoly: ...

def name(self, i: int, /) -> str: ...
def names(self) -> tuple[str]: ...
def gens(self) -> tuple[fmpz_mod_mpoly, ...]: ...
def variable_to_index(self, var: str, /) -> int: ...
def term(
self, coeff: ifmpz_mod | None = None, exp_vec: Iterable[int] | None = None
) -> fmpz_mod_mpoly: ...
def drop_gens(self, gens: Iterable[str | int], /) -> fmpz_mod_mpoly_ctx: ...
def append_gens(self, gens: Iterable[str | int], /) -> fmpz_mod_mpoly_ctx: ...
def infer_generator_mapping(
self, ctx: flint_mpoly_context, /
) -> dict[int, int]: ...
@classmethod
def from_context(
cls,
ctx: flint_mpoly_context[Any, Any, Any],
names: str | Iterable[str | tuple[str, int]] | tuple[str, int] | None = None,
ordering: Ordering | str = Ordering.lex,
) -> fmpz_mod_mpoly_ctx: ...


class fmpz_mod_mpoly(flint_mpoly[fmpz_mod_mpoly_ctx, fmpz_mod, ifmpz_mod]):
def __init__(self,
val: fmpz_mod_mpoly | fmpz_mpoly | ifmpz_mod | dict[tuple[int, ...], ifmpz_mod] | _str = 0,
val: fmpz_mod_mpoly | fmpz_mpoly | ifmpz_mod | Mapping[tuple[int, ...], ifmpz_mod] | _str = 0,
ctx: fmpz_mod_mpoly_ctx | None = None
) -> None: ...

Expand All @@ -56,7 +83,7 @@ class fmpz_mod_mpoly(flint_mpoly[fmpz_mod_mpoly_ctx, fmpz_mod, ifmpz_mod]):
def __getitem__(self, index: tuple[int, ...]) -> fmpz_mod: ...
def __setitem__(self, index: tuple[int, ...], coeff: ifmpz_mod) -> None: ...

def subs(self, mapping: dict[_str | int, ifmpz_mod]) -> fmpz_mod_mpoly: ...
def subs(self, mapping: Mapping[_str | int, ifmpz_mod]) -> fmpz_mod_mpoly: ...
def compose(self, *args: fmpz_mod_mpoly, ctx: fmpz_mod_mpoly_ctx | None = None) -> fmpz_mod_mpoly: ...

def __call__(self, *args: ifmpz_mod) -> fmpz_mod: ...
Expand Down
33 changes: 25 additions & 8 deletions src/flint/types/fmpz_mpoly.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable, Iterator, Mapping
from typing import Iterable, Iterator, Mapping, Any

from ..flint_base.flint_base import flint_mpoly, flint_mpoly_context, Ordering
from .fmpz import fmpz
Expand All @@ -18,16 +18,33 @@ class fmpz_mpoly_ctx(flint_mpoly_context[fmpz_mpoly, fmpz, ifmpz]):

def nvars(self) -> int: ...
def ordering(self) -> Ordering: ...

def gen(self, i: int) -> fmpz_mpoly: ...
def from_dict(self, d: Mapping[tuple[int, ...], ifmpz]) -> fmpz_mpoly: ...
def constant(self, z: ifmpz) -> fmpz_mpoly: ...

def gen(self, i: int, /) -> fmpz_mpoly: ...
def from_dict(self, d: Mapping[tuple[int, ...], ifmpz], /) -> fmpz_mpoly: ...
def constant(self, z: ifmpz, /) -> fmpz_mpoly: ...
def name(self, i: int, /) -> str: ...
def names(self) -> tuple[str]: ...
def gens(self) -> tuple[fmpz_mpoly, ...]: ...
def variable_to_index(self, var: str, /) -> int: ...
def term(
self, coeff: ifmpz | None = None, exp_vec: Iterable[int] | None = None
) -> fmpz_mpoly: ...
def drop_gens(self, gens: Iterable[str | int], /) -> fmpz_mpoly_ctx: ...
def append_gens(self, gens: Iterable[str | int], /) -> fmpz_mpoly_ctx: ...
def infer_generator_mapping(
self, ctx: flint_mpoly_context, /
) -> dict[int, int]: ...
@classmethod
def from_context(
cls,
ctx: flint_mpoly_context[Any, Any, Any],
names: str | Iterable[str | tuple[str, int]] | tuple[str, int] | None = None,
ordering: Ordering | str = Ordering.lex,
) -> fmpz_mpoly_ctx: ...

class fmpz_mpoly(flint_mpoly[fmpz_mpoly_ctx, fmpz, ifmpz]):

def __init__(self,
val: fmpz_mpoly | ifmpz | dict[tuple[int, ...], ifmpz] | _str = 0,
val: fmpz_mpoly | ifmpz | Mapping[tuple[int, ...], ifmpz] | _str = 0,
ctx: fmpz_mpoly_ctx | None = None
) -> None: ...

Expand All @@ -52,7 +69,7 @@ class fmpz_mpoly(flint_mpoly[fmpz_mpoly_ctx, fmpz, ifmpz]):
def __getitem__(self, index: tuple[int, ...]) -> fmpz: ...
def __setitem__(self, index: tuple[int, ...], coeff: ifmpz) -> None: ...

def subs(self, mapping: dict[_str | int, ifmpz]) -> fmpz_mpoly: ...
def subs(self, mapping: Mapping[_str | int, ifmpz]) -> fmpz_mpoly: ...
def compose(self, *args: fmpz_mpoly, ctx: fmpz_mpoly_ctx | None = None) -> fmpz_mpoly: ...

def __call__(self, *args: ifmpz) -> fmpz: ...
Expand Down
Loading
Loading