Skip to content

Commit 170f212

Browse files
committed
Add invariant tests and correct doc strings
1 parent 9dc4f4c commit 170f212

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/flint/test/test_all.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,14 +3239,24 @@ def quick_poly():
32393239
assert (x0**3 - 6*x0**2 + 11*x0 - 6).discriminant('x0') == 4
32403240
assert (x0**2 + 4*x0*x1 + 4*x1**2 - 1).discriminant('x0') == 4
32413241

3242-
res, stride = (3*x0**2*x1**2 + 6*x0*x1**2 + 9*x1**2).deflation()
3242+
f1 = 3*x0**2*x1**2 + 6*x0*x1**2 + 9*x1**2
3243+
res, stride = f1.deflation()
32433244
assert res == 3*x0**2 + 6*x0 + 9
32443245
assert tuple(stride) == (1, 0)
32453246

3246-
res, stride = ((x0**2 + x1**2)**3 + (x0**2 + x1**2)**2 + 1).deflation()
3247+
g1 = ((x0**2 + x1**2)**3 + (x0**2 + x1**2)**2 + 1)
3248+
res, stride = g1.deflation()
32473249
assert res == x0**3 + 3*x0**2*x1 + x0**2 + 3*x0*x1**2 + 2*x0*x1 + x1**3 + x1**2 + 1
32483250
assert tuple(stride) == (2, 2)
32493251

3252+
for p in [f1, g1]:
3253+
n, m = p.deflation_monom()
3254+
assert m * p.deflate(n).inflate(n) == p
3255+
3256+
n, i = p.deflation_index()
3257+
m = ctx.term(exp_vec=i)
3258+
assert p.deflate(n).inflate(n) * m == p
3259+
32503260
if P is flint.fmpz_mpoly:
32513261
assert (x0**2 * x1 + x0 * x1).primitive() == (1, x0**2*x1 + x0*x1)
32523262
assert (4 * x0 + 2 * x0 * x1).primitive() == (2, x0 * x1 + 2 * x0)

src/flint/types/fmpq_mpoly.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,7 @@ cdef class fmpq_mpoly(flint_mpoly):
10531053

10541054
def deflation(self) -> tuple[fmpq_mpoly, list[int]]:
10551055
"""
1056-
Compute the deflation of ``self``, that is ``p(X^(1/N))`` for maximal
1057-
N. Returns ``q, N`` such that ``self == q.inflate(N)``.
1056+
Compute the deflation of ``self``, that is ``p(X^(1/N))`` for maximal N.
10581057

10591058
>>> from flint import Ordering
10601059
>>> ctx = fmpq_mpoly_ctx.get_context(2, Ordering.lex, nametup=('x', 'y'))

src/flint/types/fmpz_mpoly.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,8 +1149,7 @@ cdef class fmpz_mpoly(flint_mpoly):
11491149

11501150
def deflation(self) -> tuple[fmpz_mpoly, list[int]]:
11511151
"""
1152-
Compute the deflation of ``self``, that is ``p(X^(1/N))`` for maximal
1153-
N. Returns ``q, N`` such that ``self == q.inflate(N)``.
1152+
Compute the deflation of ``self``, that is ``p(X^(1/N))`` for maximal N.
11541153

11551154
>>> from flint import Ordering
11561155
>>> ctx = fmpz_mpoly_ctx.get_context(2, Ordering.lex, nametup=('x', 'y'))

src/flint/types/nmod_mpoly.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,7 @@ cdef class nmod_mpoly(flint_mpoly):
11021102

11031103
def deflation(self) -> tuple[nmod_mpoly, list[int]]:
11041104
"""
1105-
Compute the deflation of ``self``, that is ``p(X^(1/N))`` for maximal
1106-
N. Returns ``q, N`` such that ``self == q.inflate(N)``.
1105+
Compute the deflation of ``self``, that is ``p(X^(1/N))`` for maximal N.
11071106

11081107
>>> from flint import Ordering
11091108
>>> ctx = nmod_mpoly_ctx.get_context(2, Ordering.lex, 11, nametup=('x', 'y'))

0 commit comments

Comments
 (0)