Skip to content

Work around cython parameter passing bug. #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/flint/functions/showgood.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ from flint.flintlib.acb cimport *

ctx = thectx

# xxx: this doesn't work when changed to a cdef function. why?
def __goodness(x, bint parts=True, metric=None):
cdef slong __goodness(x, bint parts, metric):
if metric is not None:
x = metric(x)
if isinstance(x, arb):
return arb_rel_accuracy_bits((<arb>x).val)
if isinstance(x, acb):
if parts:
return min(__goodness(x.real), __goodness(x.imag))
return min(__goodness(x.real, parts, metric), __goodness(x.imag, parts, metric))
else:
return acb_rel_accuracy_bits((<acb>x).val)
if isinstance(x, (tuple, list, arb_mat, acb_mat, arb_poly, acb_poly, arb_series, acb_series)):
return min(__goodness(y, parts) for y in x)
return min(__goodness(y, parts, metric) for y in x)
raise TypeError("must have arb or acb")

cdef goodstr(x):
Expand Down
3 changes: 2 additions & 1 deletion src/flint/test/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def run_doctests(verbose=None):
flint.types.acb_poly,
flint.types.acb_mat,
flint.types.acb_series,
flint.types.dirichlet]
flint.types.dirichlet,
flint.functions.showgood]
results = [doctest.testmod(x) for x in modules]
# ffmpz, tfmpz = doctest.testmod(flint._fmpz, verbose=verbose)
# failed, total = doctest.testmod(flint.pyflint, verbose=verbose)
Expand Down