Skip to content

Commit

Permalink
Merge pull request #255 from Tom-Hubrecht/gr-ctx-methods
Browse files Browse the repository at this point in the history
gr: Add context methods
  • Loading branch information
oscarbenjamin authored Jan 31, 2025
2 parents 7786fc0 + 8b7f0c6 commit e50cda6
Show file tree
Hide file tree
Showing 4 changed files with 1,096 additions and 24 deletions.
20 changes: 20 additions & 0 deletions src/flint/flintlib/types/gr.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ from flint.flintlib.types.flint cimport (
flint_bitcnt_t,
)

cdef extern from *:
"""
/*
* The following functions were introduced in FLINT 3.2.0
*/
#if __FLINT_RELEASE < 30200
#define gr_min(res, x, y, ctx) GR_UNABLE
#define gr_max(res, x, y, ctx) GR_UNABLE
#define gr_le(x, y, ctx) T_UNKNOWN
#define gr_lt(x, y, ctx) T_UNKNOWN
#define gr_ge(x, y, ctx) T_UNKNOWN
#define gr_gt(x, y, ctx) T_UNKNOWN
#define gr_abs_le(x, y, ctx) T_UNKNOWN
#define gr_abs_lt(x, y, ctx) T_UNKNOWN
#define gr_abs_ge(x, y, ctx) T_UNKNOWN
#define gr_abs_gt(x, y, ctx) T_UNKNOWN
#endif
"""


cdef extern from "flint/gr.h":

Expand Down
18 changes: 14 additions & 4 deletions src/flint/test/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

import flint

dunder_test_regex = re.compile(r'^(.*?)__test__\..*?\.(.*) \(line (\d+)\)$')
dunder_test_regex = re.compile(r'^(.*?)__test__\.(.*?\.)(.*) \(line (\d+)\)$')

test_flint_at_least = {
"flint.types._gr.gr_ctx.gens": 30100,
"flint.types._gr.gr_ctx.neg": 30100,
}


def find_doctests(module):
Expand All @@ -20,9 +25,14 @@ def find_doctests(module):
m = dunder_test_regex.match(test.name)
if m is not None:
groups = m.groups()
test.name = groups[0] + groups[1]
test.lineno = int(groups[2])
res.append(test)
test.name = groups[0] + groups[2]
test.lineno = int(groups[3])

if (
test_flint_at_least.get("".join(groups[:3]), flint.__FLINT_RELEASE__)
<= flint.__FLINT_RELEASE__
):
res.append(test)

tests.append((module_info.name, res))

Expand Down
Loading

0 comments on commit e50cda6

Please sign in to comment.