Bug in continued fraction doctest
kliem opened this issue · 13 comments
kliem commented
Part of #32544:
sage -t --long --random-seed=77478494819088915365500074763386376542 src/sage/rings/continued_fraction.py
**********************************************************************
File "src/sage/rings/continued_fraction.py", line 265, in sage.rings.continued_fraction.rat_interval_cf_list
Failed example:
for prec in range(10,54):
R = RealIntervalField(20)
for _ in range(100):
x = R.random_element() * R.random_element() + R.random_element() / 100
l = x.lower().exact_rational()
u = x.upper().exact_rational()
cf = rat_interval_cf_list(l,u)
a = continued_fraction(cf).value()
b = continued_fraction(cf+[1]).value()
if a > b:
a,b = b,a
assert a <= l
assert b >= u
Exception raised:
Traceback (most recent call last):
File "/home/jonathan/Applications/sage/local/lib/python3.8/site-packages/sage/doctest/forker.py", line 694, in _run
self.compile_and_execute(example, compiler, test.globs)
File "/home/jonathan/Applications/sage/local/lib/python3.8/site-packages/sage/doctest/forker.py", line 1088, in compile_and_execute
exec(compiled, globs)
File "<doctest sage.rings.continued_fraction.rat_interval_cf_list[2]>", line 8, in <module>
a = continued_fraction(cf).value()
File "/home/jonathan/Applications/sage/local/lib/python3.8/site-packages/sage/rings/continued_fraction.py", line 2625, in continued_fraction
x1, x2 = check_and_reduce_pair(x)
File "/home/jonathan/Applications/sage/local/lib/python3.8/site-packages/sage/rings/continued_fraction.py", line 2254, in check_and_reduce_pair
raise ValueError("continued fraction can not represent infinity")
ValueError: continued fraction can not represent infinity
**********************************************************************
1 item had failures:
1 of 4 in sage.rings.continued_fraction.rat_interval_cf_list
[437 tests, 1 failure, 5.09 s]
-------------------------------------------------------------
Component: basic arithmetic
Author: Jonathan Kliem
Branch/Commit: e1664ff
Reviewer: Kwankyu Lee
Issue created by migration from https://trac.sagemath.org/ticket/32774
kliem commented
Branch: public/32544
kliem commented
Author: Jonathan Kliem
kliem commented
comment:2
The doctest assumes that two rational numbers that are close enough have the same floor, which needs not to hold.
kliem commented
Changed branch from public/32544 to public/32774
kwankyu commented
comment:4
The doctest is still strange in that prec is not used.
sagetrac-git commented
sagetrac-git commented
Branch pushed to git repo; I updated commit sha1. New commits:
e1664ff | use different precisions in doctest |
kwankyu commented
Reviewer: Kwankyu Lee
kwankyu commented
comment:7
Looks good.
kliem commented
comment:8
Thank you.
vbraun commented
Changed branch from public/32774 to e1664ff