Skip to content

Commit

Permalink
Add append_gens method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Moss committed Sep 17, 2024
1 parent 4ea2ba8 commit aa2901a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/flint/flint_base/flint_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,17 @@ cdef class flint_mpoly_context(flint_elem):

return self.from_context(self, names=remaining_gens)

def append_gens(self, *gens: str):
"""
Get a context with the specified generators appended.
>>> from flint import fmpz_mpoly_ctx
>>> ctx = fmpz_mpoly_ctx.get(('x', 'y', 'z'))
>>> ctx.append_gens('a', 'b')
fmpz_mpoly_ctx(5, '<Ordering.lex: 'lex'>', ('x', 'y', 'z', 'a', 'b'))
"""
return self.from_context(self, names=self.names() + gens)

def infer_generator_mapping(self, ctx: flint_mpoly_context):
"""
Infer a mapping of generator indexes from this contexts generators, to the
Expand Down
2 changes: 2 additions & 0 deletions src/flint/test/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -2910,6 +2910,8 @@ def quick_poly():
new_ctx = new_ctx.from_context(new_ctx, ordering=ctx.ordering())
assert new_ctx == ctx
assert new_poly.coerce_to_context(new_ctx) == quick_poly()

assert ctx.append_gens(*ctx1.names()[-2:]) == ctx1
else:
assert raises(lambda: quick_poly().coerce_to_context(ctx1), NotImplementedError)

Expand Down

0 comments on commit aa2901a

Please sign in to comment.