Skip to content

Commit aa2901a

Browse files
author
Jake Moss
committed
Add append_gens method
1 parent 4ea2ba8 commit aa2901a

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/flint/flint_base/flint_base.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,17 @@ cdef class flint_mpoly_context(flint_elem):
486486

487487
return self.from_context(self, names=remaining_gens)
488488

489+
def append_gens(self, *gens: str):
490+
"""
491+
Get a context with the specified generators appended.
492+
493+
>>> from flint import fmpz_mpoly_ctx
494+
>>> ctx = fmpz_mpoly_ctx.get(('x', 'y', 'z'))
495+
>>> ctx.append_gens('a', 'b')
496+
fmpz_mpoly_ctx(5, '<Ordering.lex: 'lex'>', ('x', 'y', 'z', 'a', 'b'))
497+
"""
498+
return self.from_context(self, names=self.names() + gens)
499+
489500
def infer_generator_mapping(self, ctx: flint_mpoly_context):
490501
"""
491502
Infer a mapping of generator indexes from this contexts generators, to the

src/flint/test/test_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,8 @@ def quick_poly():
29102910
new_ctx = new_ctx.from_context(new_ctx, ordering=ctx.ordering())
29112911
assert new_ctx == ctx
29122912
assert new_poly.coerce_to_context(new_ctx) == quick_poly()
2913+
2914+
assert ctx.append_gens(*ctx1.names()[-2:]) == ctx1
29132915
else:
29142916
assert raises(lambda: quick_poly().coerce_to_context(ctx1), NotImplementedError)
29152917

0 commit comments

Comments
 (0)