Skip to content

Commit 341e351

Browse files
committed
gr: disable some feature/tests for FLINT < 3.1
1 parent 8106ecb commit 341e351

File tree

2 files changed

+130
-119
lines changed

2 files changed

+130
-119
lines changed

src/flint/types/_gr.pxd

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ from flint.flintlib.functions.gr_domains cimport (
6464

6565
gr_ctx_init_real_qqbar,
6666
gr_ctx_init_complex_qqbar,
67-
_gr_ctx_qqbar_set_limits,
67+
# _gr_ctx_qqbar_set_limits,
6868

6969
gr_ctx_init_real_ca,
7070
gr_ctx_init_complex_ca,
@@ -89,13 +89,14 @@ from flint.flintlib.functions.gr cimport (
8989
gr_set_str,
9090
gr_get_str,
9191
gr_set,
92+
gr_set_si,
9293
gr_get_si,
9394

9495
gr_zero,
9596
gr_one,
9697
gr_gen,
9798
gr_gens,
98-
gr_gens_recursive,
99+
# gr_gens_recursive,
99100
gr_ctx_set_gen_names,
100101

101102
gr_i,
@@ -224,6 +225,15 @@ cdef class gr_ctx(flint_ctx):
224225
raise self._error(err, "Failed to parse string")
225226
return py_val
226227

228+
@cython.final
229+
cdef inline gr from_si(self, slong n):
230+
cdef gr py_val
231+
py_val = self.new_gr()
232+
err = gr_set_si(py_val.pval, n, self.ctx_t)
233+
if err != GR_SUCCESS:
234+
raise self._error(err, "Failed to parse string")
235+
return py_val
236+
227237
@cython.final
228238
cdef inline str to_str(self, val: gr):
229239
cdef str py_str
@@ -348,25 +358,25 @@ cdef class gr_ctx(flint_ctx):
348358
gr_vec_clear(gens, self.ctx_t)
349359
return py_gens
350360

351-
@cython.final
352-
cdef inline list _gens_recursive(self):
353-
cdef int err
354-
cdef gr g
355-
cdef gr_vec_t gens
356-
gr_vec_init(gens, 0, self.ctx_t)
357-
err = gr_gens_recursive(gens, self.ctx_t)
358-
if err != GR_SUCCESS:
359-
raise self._error(err, "Cannot get recursive generators")
360-
length = gr_vec_length(gens, self.ctx_t)
361-
py_gens = [None] * length
362-
for 0 <= i < length:
363-
g = self.new_gr()
364-
err = gr_set(g.pval, gr_vec_entry_ptr(gens, i, self.ctx_t), self.ctx_t)
365-
if err != GR_SUCCESS:
366-
raise self._error(err, "Failed to copy generator.")
367-
py_gens[i] = g
368-
gr_vec_clear(gens, self.ctx_t)
369-
return py_gens
361+
# @cython.final
362+
# cdef inline list _gens_recursive(self):
363+
# cdef int err
364+
# cdef gr g
365+
# cdef gr_vec_t gens
366+
# gr_vec_init(gens, 0, self.ctx_t)
367+
# err = gr_gens_recursive(gens, self.ctx_t)
368+
# if err != GR_SUCCESS:
369+
# raise self._error(err, "Cannot get recursive generators")
370+
# length = gr_vec_length(gens, self.ctx_t)
371+
# py_gens = [None] * length
372+
# for 0 <= i < length:
373+
# g = self.new_gr()
374+
# err = gr_set(g.pval, gr_vec_entry_ptr(gens, i, self.ctx_t), self.ctx_t)
375+
# if err != GR_SUCCESS:
376+
# raise self._error(err, "Failed to copy generator.")
377+
# py_gens[i] = g
378+
# gr_vec_clear(gens, self.ctx_t)
379+
# return py_gens
370380

371381

372382
cdef class gr_scalar_ctx(gr_ctx):
@@ -584,7 +594,9 @@ cdef class gr_real_qqbar_ctx(gr_scalar_ctx):
584594
ctx.bits_limit = bits_limit
585595
if deg_limit != -1 or bits_limit != -1:
586596
# Maybe add setters for these?
587-
_gr_ctx_qqbar_set_limits(ctx.ctx_t, deg_limit, bits_limit)
597+
# XXX: Not available in FLINT 3.0.1
598+
# _gr_ctx_qqbar_set_limits(ctx.ctx_t, deg_limit, bits_limit)
599+
pass
588600
return ctx
589601

590602

@@ -603,7 +615,9 @@ cdef class gr_complex_qqbar_ctx(gr_scalar_ctx):
603615
ctx.bits_limit = bits_limit
604616
if deg_limit != -1 or bits_limit != -1:
605617
# Maybe add setters for these?
606-
_gr_ctx_qqbar_set_limits(ctx.ctx_t, deg_limit, bits_limit)
618+
# XXX: Not available in FLINT 3.0.1
619+
# _gr_ctx_qqbar_set_limits(ctx.ctx_t, deg_limit, bits_limit)
620+
pass
607621
return ctx
608622

609623

src/flint/types/_gr.pyx

Lines changed: 93 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ from flint.flintlib.functions.gr_domains cimport (
1919
gr_ctx_is_algebraically_closed,
2020
gr_ctx_is_finite_characteristic,
2121
gr_ctx_is_ordered_ring,
22-
gr_ctx_is_zero_ring,
22+
# gr_ctx_is_zero_ring,
2323
gr_ctx_is_exact,
2424
gr_ctx_is_canonical,
2525
gr_ctx_has_real_prec,
@@ -165,10 +165,10 @@ cdef class gr_ctx(flint_ctx):
165165
"""
166166
return truth_to_py(gr_ctx_is_ordered_ring(self.ctx_t))
167167

168-
@property
169-
def is_zero_ring(self) -> bool | None:
170-
"""True if the domain is a zero ring (can be ``None`` if unknown)."""
171-
return truth_to_py(gr_ctx_is_zero_ring(self.ctx_t))
168+
# @property
169+
# def is_zero_ring(self) -> bool | None:
170+
# """True if the domain is a zero ring (can be ``None`` if unknown)."""
171+
# return truth_to_py(gr_ctx_is_zero_ring(self.ctx_t))
172172

173173
@property
174174
def is_exact(self) -> bool | None:
@@ -229,7 +229,10 @@ cdef class gr_ctx(flint_ctx):
229229
>>> ctx(2)
230230
2
231231
"""
232-
return self.from_str(str(arg))
232+
try:
233+
return self.from_str(str(arg))
234+
except AssertionError:
235+
return self.from_si(int(arg))
233236

234237
def zero(self) -> gr:
235238
"""Return the zero element of the domain.
@@ -314,11 +317,11 @@ cdef class gr_ctx(flint_ctx):
314317
def gen(self) -> gr:
315318
"""Return the generator of the domain (if available).
316319

317-
>>> from flint.types._gr import gr_fmpzi_ctx, gr_fq_nmod_ctx
320+
>>> from flint.types._gr import gr_fmpzi_ctx, gr_fq_ctx
318321
>>> ctx = gr_fmpzi_ctx
319322
>>> ctx.gen()
320323
I
321-
>>> ctx = gr_fq_nmod_ctx.new(5, 2)
324+
>>> ctx = gr_fq_ctx.new(5, 2)
322325
>>> ctx.gen()
323326
a
324327
"""
@@ -327,23 +330,25 @@ cdef class gr_ctx(flint_ctx):
327330
def gens(self) -> list[gr]:
328331
"""Return the top-level generators of the domain
329332

330-
>>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx
331-
>>> ctx = gr_gr_mpoly_ctx.new(gr_fmpzi_ctx, ['x', 'y'])
332-
>>> ctx.gens()
333-
[x, y]
334-
>>> gr_fmpzi_ctx.gens()
335-
[I]
336-
>>> ctx.gens_recursive()
337-
[I, x, y]
333+
# XXX: Does not work with FLINT < 3.1
334+
335+
# >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx
336+
# >>> ctx = gr_gr_mpoly_ctx.new(gr_fmpzi_ctx, ['x', 'y'])
337+
# >>> ctx.gens()
338+
# [x, y]
339+
# >>> gr_fmpzi_ctx.gens()
340+
# [I]
341+
# >>> ctx.gens_recursive()
342+
# [I, x, y]
338343
"""
339344
return self._gens()
340345

341-
def gens_recursive(self) -> list[gr]:
342-
"""Return all generators of the domain
346+
# def gens_recursive(self) -> list[gr]:
347+
# """Return all generators of the domain
343348

344-
See :meth:`gens` for an example.
345-
"""
346-
return self._gens_recursive()
349+
# See :meth:`gens` for an example.
350+
# """
351+
# return self._gens_recursive()
347352

348353

349354
cdef class gr_scalar_ctx(gr_ctx):
@@ -534,8 +539,6 @@ cdef class gr_fmpz_mod_ctx(gr_scalar_ctx):
534539
>>> Z64 = gr_fmpz_mod_ctx.new(2**64 + 1)
535540
>>> Z64
536541
gr_fmpz_mod_ctx(18446744073709551617)
537-
>>> Z64(2**64+1)
538-
0
539542
>>> Z64(2)**64 + 2
540543
1
541544
>>> Z64.is_prime
@@ -625,21 +628,22 @@ cdef class gr_fq_nmod_ctx(gr_scalar_ctx):
625628
def new(p, d, name=None) -> gr_fq_nmod_ctx:
626629
"""Create a new context for finite fields.
627630

628-
>>> from flint.types._gr import gr_fq_nmod_ctx
629-
>>> F9 = gr_fq_nmod_ctx.new(3, 2)
630-
>>> F9
631-
gr_fq_nmod_ctx(3, 2)
632-
>>> F9(2) + F9(3)
633-
2
634-
>>> F9.characteristic()
635-
3
636-
>>> F9.degree()
637-
2
638-
>>> F9.gen()
639-
a
640-
>>> a = F9.gen()
641-
>>> (1 + a) ** 2 + a
642-
a+2
631+
# XXX: Does not work with FLINT < 3.1
632+
# >>> from flint.types._gr import gr_fq_nmod_ctx
633+
# >>> F9 = gr_fq_nmod_ctx.new(3, 2)
634+
# >>> F9
635+
# gr_fq_nmod_ctx(3, 2)
636+
# >>> F9(2) + F9(3)
637+
# 2
638+
# >>> F9.characteristic()
639+
# 3
640+
# >>> F9.degree()
641+
# 2
642+
# >>> F9.gen()
643+
# a
644+
# >>> a = F9.gen()
645+
# >>> (1 + a) ** 2 + a
646+
# a+2
643647
"""
644648
cdef bytes name_b
645649
cdef char *name_c
@@ -677,21 +681,22 @@ cdef class gr_fq_zech_ctx(gr_scalar_ctx):
677681
def new(p, d, name=None) -> gr_fq_zech_ctx:
678682
"""Create a new context for finite fields with small characteristic.
679683

680-
>>> from flint.types._gr import gr_fq_zech_ctx
681-
>>> F9 = gr_fq_zech_ctx.new(3, 2)
682-
>>> F9
683-
gr_fq_zech_ctx(3, 2)
684-
>>> F9(2) + F9(3) # XXX: Is this correct?
685-
a^4
686-
>>> F9.characteristic()
687-
3
688-
>>> F9.degree()
689-
2
690-
>>> F9.gen()
691-
a^1
692-
>>> a = F9.gen()
693-
>>> (1 + a) ** 2 + a # doctest: +SKIP
694-
a+2
684+
# XXX: Does not work with FLINT < 3.1
685+
# >>> from flint.types._gr import gr_fq_zech_ctx
686+
# >>> F9 = gr_fq_zech_ctx.new(3, 2)
687+
# >>> F9
688+
# gr_fq_zech_ctx(3, 2)
689+
# >>> F9(2) + F9(3) # XXX: Is this correct?
690+
# a^4
691+
# >>> F9.characteristic()
692+
# 3
693+
# >>> F9.degree()
694+
# 2
695+
# >>> F9.gen()
696+
# a^1
697+
# >>> a = F9.gen()
698+
# >>> (1 + a) ** 2 + a # doctest: +SKIP
699+
# a+2
695700
"""
696701
cdef bytes name_b
697702
cdef char *name_c
@@ -1066,22 +1071,18 @@ cdef class gr_gr_poly_ctx(gr_poly_ctx):
10661071
def new(base_ring) -> gr_gr_poly_ctx:
10671072
"""Create a new context for dense univariate polynomial rings.
10681073

1069-
>>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_poly_ctx
1070-
>>> ZI = gr_fmpzi_ctx
1071-
>>> R = gr_gr_poly_ctx.new(ZI)
1074+
>>> from flint.types._gr import gr_fmpz_ctx, gr_gr_poly_ctx
1075+
>>> Z = gr_fmpz_ctx
1076+
>>> R = gr_gr_poly_ctx.new(Z)
10721077
>>> R
1073-
gr_gr_poly_ctx(gr_fmpzi_ctx)
1078+
gr_gr_poly_ctx(gr_fmpz_ctx)
10741079
>>> R.base_ring
1075-
gr_fmpzi_ctx
1080+
gr_fmpz_ctx
10761081
>>> R.gen()
10771082
x
1078-
>>> ZI.gen()
1079-
I
1080-
>>> R.gens_recursive()
1081-
[I, x]
1082-
>>> I, x = R.gens_recursive()
1083-
>>> (I + x) ** 2
1084-
-1 + (2*I)*x + x^2
1083+
>>> x = R.gen()
1084+
>>> (1 + x) ** 2
1085+
1 + 2*x + x^2
10851086
"""
10861087
return gr_gr_poly_ctx._new(base_ring)
10871088

@@ -1101,26 +1102,24 @@ cdef class gr_gr_mpoly_ctx(gr_mpoly_ctx):
11011102
def new(base_ring, names, order=None) -> gr_gr_mpoly_ctx:
11021103
"""Create a new context for dense multivariate polynomial rings.
11031104

1104-
>>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx
1105-
>>> ZI = gr_fmpzi_ctx
1106-
>>> R = gr_gr_mpoly_ctx.new(ZI, ['x', 'y'])
1107-
>>> R
1108-
gr_gr_mpoly_ctx(gr_fmpzi_ctx, ('x', 'y'), Ordering.lex)
1109-
>>> R.base_ring
1110-
gr_fmpzi_ctx
1111-
>>> R.names
1112-
('x', 'y')
1113-
>>> R.nvars
1114-
2
1115-
>>> R.order
1116-
<Ordering.lex: 'lex'>
1117-
>>> R.gens()
1118-
[x, y]
1119-
>>> R.gens_recursive()
1120-
[I, x, y]
1121-
>>> I, x, y = R.gens_recursive()
1122-
>>> (I + x + y) ** 2
1123-
x^2 + 2*x*y + (2*I)*x + y^2 + (2*I)*y - 1
1105+
# >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx
1106+
# >>> ZI = gr_fmpzi_ctx
1107+
# >>> R = gr_gr_mpoly_ctx.new(ZI, ['x', 'y'])
1108+
# >>> R
1109+
# gr_gr_mpoly_ctx(gr_fmpzi_ctx, ('x', 'y'), Ordering.lex)
1110+
# >>> R.base_ring
1111+
# gr_fmpzi_ctx
1112+
# >>> R.names
1113+
# ('x', 'y')
1114+
# >>> R.nvars
1115+
# 2
1116+
# >>> R.order
1117+
# <Ordering.lex: 'lex'>
1118+
# >>> R.gens()
1119+
# [x, y]
1120+
# >>> I, [x, y] = ZI.gen(), R.gens()
1121+
# >>> (I + x + y) ** 2
1122+
# x^2 + 2*x*y + (2*I)*x + y^2 + (2*I)*y - 1
11241123
"""
11251124
if order is None:
11261125
order = Ordering.lex
@@ -1194,20 +1193,18 @@ cdef class gr_series_ctx(gr_ctx):
11941193
def new(base_ring, prec) -> gr_series_ctx:
11951194
"""Create a new context for series with precision `n`.
11961195

1197-
>>> from flint.types._gr import gr_fmpzi_ctx, gr_series_ctx
1198-
>>> ZI = gr_fmpzi_ctx
1199-
>>> R = gr_series_ctx.new(ZI, 10)
1196+
>>> from flint.types._gr import gr_fmpz_ctx, gr_series_ctx
1197+
>>> Z = gr_fmpz_ctx
1198+
>>> R = gr_series_ctx.new(Z, 10)
12001199
>>> R
1201-
gr_series_ctx(gr_fmpzi_ctx, 10)
1200+
gr_series_ctx(gr_fmpz_ctx, 10)
12021201
>>> R.base_ring
1203-
gr_fmpzi_ctx
1202+
gr_fmpz_ctx
12041203
>>> R.prec
12051204
10
1206-
>>> R.gens_recursive()
1207-
[I, x]
1208-
>>> I, x = R.gens_recursive()
1209-
>>> 1 / (I - x)
1210-
-I - x + I*x^2 + x^3 - I*x^4 - x^5 + I*x^6 + x^7 - I*x^8 - x^9 + O(x^10)
1205+
>>> x = R.gen()
1206+
>>> 1 / (1 - x)
1207+
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + O(x^10)
12111208
"""
12121209
return gr_series_ctx._new(base_ring, prec)
12131210

@@ -1589,7 +1586,7 @@ cdef class gr(flint_scalar):
15891586

15901587
>>> from flint.types._gr import gr_complex_acb_ctx
15911588
>>> C = gr_complex_acb_ctx.new(10)
1592-
>>> (1 + C.i()).csgn()
1589+
>>> (1 + C.i()).csgn() # doctest: +SKIP
15931590
1
15941591
"""
15951592
return self._csgn()

0 commit comments

Comments
 (0)