sagemath/sage

apply_homography unstable for continued fraction

Opened this issue · 1 comments

kliem commented
sage -t --long --random-seed=9349834848432 src/sage/rings/continued_fraction.py
**********************************************************************
File "src/sage/rings/continued_fraction.py", line 1189, in sage.rings.continued_fraction.ContinuedFraction_base.apply_homography
Failed example:
    for _ in range(100):
        cf = choice(CF)
        forward_value = choice([True, False])
        a = ZZ.random_element(-30, 30)
        b = ZZ.random_element(-30, 30)
        c = ZZ.random_element(-30, 30)
        d = ZZ.random_element(-30, 30)
        if not c and not d:
            continue
        cf_gosper = cf.apply_homography(a, b, c, d, forward_value)
        x = cf.value()
        cf_hom = continued_fraction((a*x + b) / (c*x + d))
        for i in range(30):
            try:
                assert cf_gosper[i] == cf_hom[i]
            except:
                break
Exception raised:
    Traceback (most recent call last):
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 714, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1133, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.rings.continued_fraction.ContinuedFraction_base.apply_homography[10]>", line 10, in <module>
        cf_gosper = cf.apply_homography(a, b, c, d, forward_value)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/rings/continued_fraction.py", line 1249, in apply_homography
        return continued_fraction(lazy_list(_i), value)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/rings/continued_fraction.py", line 2627, in continued_fraction
        return ContinuedFraction_infinite(x, value)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/rings/continued_fraction.py", line 2056, in __init__
        k = w[i]
      File "sage/misc/lazy_list.pyx", line 807, in sage.misc.lazy_list.lazy_list_generic.__getitem__ (build/cythonized/sage/misc/lazy_list.c:5101)
        return self.get(key)
      File "sage/misc/lazy_list.pyx", line 651, in sage.misc.lazy_list.lazy_list_generic.get (build/cythonized/sage/misc/lazy_list.c:4628)
        raise IndexError("lazy list index out of range")
    IndexError: lazy list index out of range

In #29979, a doctest was marked not tested because of this.

CC: @slel

Component: commutative algebra

Keywords: continued fraction homography

Issue created by migration from https://trac.sagemath.org/ticket/32086

Description changed:

--- 
+++ 
@@ -41,3 +41,5 @@
         raise IndexError("lazy list index out of range")
     IndexError: lazy list index out of range
 ```
+
+In #29979, a doctest was marked `not tested` because of this.