Skip to content

Commit e6977fd

Browse files
Merge pull request #370 from oscarbenjamin/pr_unused_gens
Fixed unused_gens for zero polynomial
2 parents e033505 + bab5ea5 commit e6977fd

8 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/flint/flint_base/flint_base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class flint_mpoly_context(flint_elem, Generic[Tmpoly, Telem, Telem_coerce]):
173173
def from_dict(self, d: Mapping[tuple[int, ...], Telem_coerce], /) -> Tmpoly: ...
174174
def constant(self, z: Telem_coerce, /) -> Tmpoly: ...
175175
def name(self, i: int, /) -> str: ...
176-
def names(self) -> tuple[str]: ...
176+
def names(self) -> tuple[str, ...]: ...
177177
def gens(self) -> tuple[Tmpoly, ...]: ...
178178
def variable_to_index(self, var: str, /) -> int: ...
179179
def term(

src/flint/flint_base/flint_base.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ cdef class flint_mpoly(flint_elem):
959959
('x0', 'x3')
960960
"""
961961
names = self.context().names()
962-
return tuple(names[i] for i, x in enumerate(self.degrees()) if not x)
962+
return tuple(names[i] for i, x in enumerate(self.degrees()) if x <= 0)
963963

964964
def project_to_context(self, other_ctx, mapping: dict[str | int, str | int] = None):
965965
"""

src/flint/test/test_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,6 +3267,8 @@ def quick_poly():
32673267
)
32683268
new_poly = quick_poly().project_to_context(ctx1)
32693269
assert ctx1.drop_gens(new_poly.unused_gens()) == ctx
3270+
assert quick_poly().unused_gens() == ()
3271+
assert (0*quick_poly()).unused_gens() == ('x0', 'x1')
32703272
assert new_poly.project_to_context(ctx) == quick_poly()
32713273

32723274
new_poly = quick_poly().project_to_context(ctx2)

src/flint/types/fmpq_mpoly.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class fmpq_mpoly_ctx(flint_mpoly_context[fmpq_mpoly, fmpq, ifmpq]):
2424
def from_dict(self, d: Mapping[tuple[int, ...], ifmpq], /) -> fmpq_mpoly: ...
2525
def constant(self, q: ifmpq, /) -> fmpq_mpoly: ...
2626
def name(self, i: int, /) -> str: ...
27-
def names(self) -> tuple[str]: ...
27+
def names(self) -> tuple[str, ...]: ...
2828
def gens(self) -> tuple[fmpq_mpoly, ...]: ...
2929
def variable_to_index(self, var: str, /) -> int: ...
3030
def term(

src/flint/types/fmpz_mod_mpoly.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class fmpz_mod_mpoly_ctx(flint_mod_mpoly_context[fmpz_mod_mpoly, fmpz_mod, ifmpz
3636
def constant(self, z: ifmpz_mod) -> fmpz_mod_mpoly: ...
3737

3838
def name(self, i: int, /) -> str: ...
39-
def names(self) -> tuple[str]: ...
39+
def names(self) -> tuple[str, ...]: ...
4040
def gens(self) -> tuple[fmpz_mod_mpoly, ...]: ...
4141
def variable_to_index(self, var: str, /) -> int: ...
4242
def term(

src/flint/types/fmpz_mpoly.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class fmpz_mpoly_ctx(flint_mpoly_context[fmpz_mpoly, fmpz, ifmpz]):
2222
def from_dict(self, d: Mapping[tuple[int, ...], ifmpz], /) -> fmpz_mpoly: ...
2323
def constant(self, z: ifmpz, /) -> fmpz_mpoly: ...
2424
def name(self, i: int, /) -> str: ...
25-
def names(self) -> tuple[str]: ...
25+
def names(self) -> tuple[str, ...]: ...
2626
def gens(self) -> tuple[fmpz_mpoly, ...]: ...
2727
def variable_to_index(self, var: str, /) -> int: ...
2828
def term(

src/flint/types/nmod_mpoly.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class nmod_mpoly_ctx(flint_mod_mpoly_context[nmod_mpoly, nmod, inmod]):
3737
def constant(self, z: inmod) -> nmod_mpoly: ...
3838

3939
def name(self, i: int, /) -> str: ...
40-
def names(self) -> tuple[str]: ...
40+
def names(self) -> tuple[str, ...]: ...
4141
def gens(self) -> tuple[nmod_mpoly, ...]: ...
4242
def variable_to_index(self, var: str, /) -> int: ...
4343
def term(

src/flint/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def gen(self, i: int, /) -> _Tmpoly_p: ...
243243
def from_dict(self, d: Mapping[tuple[int, ...], _Tscalar_contra | int], /) -> _Tmpoly_p: ...
244244
def constant(self, z: _Tscalar_contra | int, /) -> _Tmpoly_p: ...
245245
def name(self, i: int, /) -> str: ...
246-
def names(self) -> tuple[str]: ...
246+
def names(self) -> tuple[str, ...]: ...
247247
def gens(self) -> tuple[_Tmpoly_p, ...]: ...
248248
def variable_to_index(self, var: str, /) -> int: ...
249249
def term(

0 commit comments

Comments
 (0)