Skip to content

Commit

Permalink
Trac #33039: Random doctest failure in continued_fraction_gosper
Browse files Browse the repository at this point in the history
{{{
sage -t --long --random-seed=129865150212556213443045001147722733023
src/sage/rings/continued_fraction_gosper.py
**********************************************************************
File "src/sage/rings/continued_fraction_gosper.py", line 109, in
sage.rings.continued_fraction_gosper.gosper_iterator.__iter__
Failed example:
    lg = [next(ig) for _ in range(10)]; lcf = [next(icf) for _ in
range(10)];
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_gosper.gosper_iterator.__iter__[4]>", line
1, in <module>
        lg = [next(ig) for _ in range(Integer(10))]; lcf = [next(icf)
for _ in range(Integer(10))];
      File "<doctest
sage.rings.continued_fraction_gosper.gosper_iterator.__iter__[4]>", line
1, in <listcomp>
        lg = [next(ig) for _ in range(Integer(10))]; lcf = [next(icf)
for _ in range(Integer(10))];
      File "/home/jonathan/Applications/sage/local/lib/python3.8/site-
packages/sage/rings/continued_fraction_gosper.py", line 138, in __next__
        raise StopIteration
    StopIteration
**********************************************************************
File "src/sage/rings/continued_fraction_gosper.py", line 110, in
sage.rings.continued_fraction_gosper.gosper_iterator.__iter__
Failed example:
    lg == lcf
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_gosper.gosper_iterator.__iter__[5]>", line
1, in <module>
        lg == lcf
    NameError: name 'lg' is not defined
**********************************************************************
File "src/sage/rings/continued_fraction_gosper.py", line 125, in
sage.rings.continued_fraction_gosper.gosper_iterator.__next__
Failed example:
    for i in range(10):
        assert next(ig) == next(icf)
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_gosper.gosper_iterator.__next__[4]>", line
2, in <module>
        assert next(ig) == next(icf)
      File "/home/jonathan/Applications/sage/local/lib/python3.8/site-
packages/sage/rings/continued_fraction_gosper.py", line 138, in __next__
        raise StopIteration
    StopIteration
**********************************************************************
2 items had failures:
   2 of   7 in
sage.rings.continued_fraction_gosper.gosper_iterator.__iter__
   1 of   6 in
sage.rings.continued_fraction_gosper.gosper_iterator.__next__
    [40 tests, 3 failures, 0.04 s]
----------------------------------------------------------------------
sage -t --long --random-seed=129865150212556213443045001147722733023
src/sage/rings/continued_fraction_gosper.py  # 3 doctests failed
----------------------------------------------------------------------
}}}

URL: https://trac.sagemath.org/33039
Reported by: gh-kliem
Ticket author(s): Jonathan Kliem
Reviewer(s): Frédéric Chapoton
  • Loading branch information
Release Manager committed Feb 12, 2022
2 parents 236856d + ae80b6d commit 8fb89a3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/sage/rings/continued_fraction_gosper.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ def __iter__(self):
TESTS::
sage: a = Integer(randint(-100,100)); b = Integer(randint(-100,100));
sage: c = Integer(randint(-100,100)); d = Integer(randint(-100,100));
sage: from sage.rings.continued_fraction_gosper import gosper_iterator
sage: ig = iter(gosper_iterator(a,b,c,d,continued_fraction(pi))); icf = iter(continued_fraction((a*pi+b)/(c*pi+d)));
sage: lg = [next(ig) for _ in range(10)]; lcf = [next(icf) for _ in range(10)];
sage: lg == lcf
True
sage: a, b, c, d = (Integer(randint(-100,100)) for _ in range(4))
sage: ig = iter(gosper_iterator(a, b, c, d, continued_fraction(pi)))
sage: icf = iter(continued_fraction((a*pi + b) / (c*pi + d)));
sage: for i in range(10):
....: try:
....: assert next(ig) == next(icf)
....: except StopIteration:
....: break
"""
return self

Expand All @@ -118,12 +120,10 @@ def __next__(self):
TESTS::
sage: a = Integer(randint(-100,100)); b = Integer(randint(-100,100));
sage: c = Integer(randint(-100,100)); d = Integer(randint(-100,100));
sage: from sage.rings.continued_fraction_gosper import gosper_iterator
sage: ig = iter(gosper_iterator(a,b,c,d,continued_fraction(pi))); icf = iter(continued_fraction((a*pi+b)/(c*pi+d)));
sage: for i in range(10):
....: assert next(ig) == next(icf)
sage: it = gosper_iterator(1, 0, 0, 1, continued_fraction(pi))
sage: list(next(it) for _ in range(10))
[3, 7, 15, 1, 292, 1, 1, 1, 2, 1]
"""
while True:
if self.currently_read >= self.input_preperiod_length:
Expand Down

0 comments on commit 8fb89a3

Please sign in to comment.