Opened 2 years ago

Closed 13 months ago

#29979 closed enhancement (fixed)

Make rings doctests ready for random seeds

Reported by: gh-kliem Owned by:
Priority: major Milestone: sage-9.5
Component: doctest framework Keywords:
Cc: Merged in:
Authors: Jonathan Kliem Reviewers: Markus Wageringel
Report Upstream: N/A Work issues:
Branch: 3ddf396 (Commits, GitHub, GitLab) Commit: 3ddf39680c30112c597187514652731b9e76173d
Dependencies: #32084, #32109, #32117, #32124 Stopgaps:

Status badges

Description

This ticket makes

sage -t --long --random-seed=n src/sage/rings/

pass for different values n than just 0.

Change History (40)

comment:1 Changed 2 years ago by gh-kliem

I have a partial fix. After that at least the following need fixes:

sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/complex_double.pyx  # 3 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/complex_field.py  # 4 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/complex_interval_field.py  # 3 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/finite_rings/element_givaro.pyx  # 2 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/finite_rings/element_ntl_gf2e.pyx  # 2 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/finite_rings/finite_field_base.pyx  # 1 doctest failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/finite_rings/finite_field_givaro.py  # 2 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/finite_rings/finite_field_ntl_gf2e.py  # 2 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/finite_rings/integer_mod_ring.py  # 1 doctest failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/integer_ring.pyx  # 10 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/number_field/order.py  # 1 doctest failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/padics/generic_nodes.py  # 3 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/padics/padic_extension_generic.py  # 4 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/padics/tests.py  # 1 doctest failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/pari_ring.py  # 3 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/cyclotomic.pyx  # 1 doctest failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/multi_polynomial_element.py  # 1 doctest failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/multi_polynomial_ideal.py  # 5 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/multi_polynomial_ring_base.pyx  # 13 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/pbori.pyx  # 27 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/polynomial_element.pyx  # 4 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/polynomial_quotient_ring.py  # 1 doctest failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/polynomial_ring.py  # 7 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/polynomial/skew_polynomial_element.pyx  # 15 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/rational_field.py  # 6 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/real_double.pyx  # 2 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/real_mpfi.pyx  # 5 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/real_mpfr.pyx  # 12 doctests failed
sage -t --long --random-seed=151058820726654196682836430928254760259 src/sage/rings/ring.pyx  # 1 doctest failed

comment:2 Changed 2 years ago by gh-kliem

Dependencies: #29962

comment:3 Changed 2 years ago by gh-kliem

Branch: public/29979
Commit: d076be5dceffaefb9f032f8f708ecc01c4101358

New commits:

da1c6bestart from a "random" random seed for doctesting
b7b836dmake random seed reproducible
eedbe5edocument random_seed
998b1b9default random seed 0 for now
1d7b00edash instead of underscore for command line options
d076be5partially make rings fuzz ready

comment:4 Changed 2 years ago by Matthias Köppe

Milestone: sage-9.2sage-9.3

comment:5 Changed 19 months ago by Matthias Köppe

Milestone: sage-9.3sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

comment:6 Changed 18 months ago by Markus Wageringel

Dependencies: #29962#29962, #31752

comment:7 Changed 15 months ago by git

Commit: d076be5dceffaefb9f032f8f708ecc01c41013582a3eebb84578104c5cda41cb4b6359b0c14483b1

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

a03aebbmake some files of rings fuzz ready
e92d0a6some changes to make rings fuzz ready
8d93480make rings ready for fuzzed doctests
f008269add ticket numbers to `not tested`
540413efix various remaining doctests in rings
2a3eebba few more doctests

comment:8 Changed 15 months ago by gh-kliem

Authors: Jonathan Kliem
Status: newneeds_review

comment:9 Changed 15 months ago by gh-kliem

If a reviewer feels like we should split this into several tickets, then this is also fine with me (e.g. start with some submodules).

comment:10 Changed 15 months ago by git

Commit: 2a3eebb84578104c5cda41cb4b6359b0c14483b15c027a75c85e00c8a0bb3da6ecbaa2a7a49281c1

Branch pushed to git repo; I updated commit sha1. New commits:

5c027a7get a random nonzero element

comment:11 Changed 15 months ago by gh-kliem

Dependencies: #29962, #31752

comment:12 Changed 15 months ago by gh-kliem

Work issues: remove marked bug from #32084

comment:13 Changed 15 months ago by git

Commit: 5c027a75c85e00c8a0bb3da6ecbaa2a7a49281c16d56c0a470da541fecdaa469fc2083e4c12c014c

Branch pushed to git repo; I updated commit sha1. New commits:

6d56c0aremove bug tag as bug has been resolved in 32084

comment:14 Changed 15 months ago by gh-kliem

Work issues: remove marked bug from #32084

comment:15 Changed 15 months ago by git

Commit: 6d56c0a470da541fecdaa469fc2083e4c12c014c74c242515324f491ffe24ff555771ee3ad53e26e

Branch pushed to git repo; I updated commit sha1. New commits:

74c2425two more failing tests for rings

comment:16 Changed 15 months ago by Markus Wageringel

Status: needs_reviewneeds_work

There are a few more tests that fail (some of these might be duplicates):

sage -t --long --warn-long 62.5 --random-seed=3000 src/sage/rings/tate_algebra_element.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3000 src/sage/rings/tests.py  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3002 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3002 src/sage/rings/padics/padic_generic_element.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3003 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3004 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3007 src/sage/rings/polynomial/ore_function_field.py  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3009 src/sage/rings/polynomial/ore_polynomial_element.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3009 src/sage/rings/tests.py  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3011 src/sage/rings/polynomial/ore_function_element.py  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3012 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3013 src/sage/rings/continued_fraction.py  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3014 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3017 src/sage/rings/invariants/invariant_theory.py  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3019 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3023 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3028 src/sage/rings/padics/padic_generic_element.pyx  # 2 doctests failed
sage -t --long --warn-long 62.5 --random-seed=3030 src/sage/rings/tests.py  # 7 doctests failed
sage -t --long --warn-long 62.5 --random-seed=3031 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3035 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3037 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3040 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3042 src/sage/rings/padics/padic_generic_element.pyx  # 2 doctests failed
sage -t --long --warn-long 62.5 --random-seed=3043 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3043 src/sage/rings/invariants/invariant_theory.py  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3043 src/sage/rings/polynomial/ore_function_element.py  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3049 src/sage/rings/tate_algebra_element.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3050 src/sage/rings/finite_rings/integer_mod.pyx  # 1 doctest failed
sage -t --long --warn-long 62.5 --random-seed=3050 src/sage/rings/padics/padic_generic_element.pyx  # 1 doctest failed

comment:17 Changed 15 months ago by gh-kliem

Thanks for catching those. It's really hard to catch all those one in a thousand failures in all of sage...

comment:18 Changed 15 months ago by gh-kliem

Dependencies: #32084

comment:19 Changed 15 months ago by gh-kliem

Dependencies: #32084#32084, #32109

comment:20 Changed 15 months ago by gh-kliem

And some of the errors are really something.

In src/sage/rings/tests.py we are trying to construct a relative number field by only checking that the polynomial is irreducible over ZZ...

comment:21 Changed 15 months ago by gh-kliem

Dependencies: #32084, #32109#32084, #32109, #32117

comment:22 Changed 15 months ago by gh-kliem

Branch: public/29979public/29979-reb
Commit: 74c242515324f491ffe24ff555771ee3ad53e26e3752b9c83e87b679c271e67d1c027e8f9253e57e
Status: needs_workneeds_review

Last 10 new commits:

0994f0ftrac 32084 fix nth root
226fe84trac 32084 fix nth root
e280083Merge branch 'public/32084r2' of git://trac.sagemath.org/sage into public/29979-reb
9e53965fix 0/0 in ore function field
192b564add ticked number to test
b20059cMerge branch 'public/32109' of git://trac.sagemath.org/sage into public/29979-reb
ce98d48two more doctests
34a233dpull in 32117
cfe869bmodulo n better be for n > 0
3752b9csome more remaining tests

comment:23 Changed 15 months ago by git

Commit: 3752b9c83e87b679c271e67d1c027e8f9253e57e36c7c5884835e3f4a5fcb6ab370f54f01161f464

Branch pushed to git repo; I updated commit sha1. New commits:

e6a697atruely ignore ignored bounds for ZZ.random_element
36c7c58pull 32124

comment:24 Changed 15 months ago by gh-kliem

Dependencies: #32084, #32109, #32117#32084, #32109, #32117, #32124

comment:25 Changed 15 months ago by git

Commit: 36c7c5884835e3f4a5fcb6ab370f54f01161f464be3e05fd8a41556347e3696bd9e79364dd4bfb52

Branch pushed to git repo; I updated commit sha1. New commits:

be3e05f29979: a few more fixes

comment:26 in reply to:  17 Changed 15 months ago by Markus Wageringel

Replying to gh-kliem:

It's really hard to catch all those one in a thousand failures in all of sage...

I agree and I appreciate all the work you put into this a lot. In the last commit, I have just added a few small fixes for some other test failures I found.

comment:27 Changed 15 months ago by gh-kliem

The continue_fraction_gosper.py doctest sometimes fails for negative period as well. I'm not sure if this is a bug or just the doctest being incorrect::

sage: def foo(a, b, c, d): 
....:      from sage.rings.continued_fraction_gosper import gosper_iterator 
....:      x = continued_fraction(([1,2],[3,4])); i = iter(gosper_iterator(a,b,c,d,x)) 
....:      l = list(i) 
....:      preperiod_length = i.output_preperiod_length 
....:      preperiod = l[:preperiod_length] 
....:      period = [abs(w) for w in l[preperiod_length:]] 
....:      c == d == 0 or continued_fraction((preperiod, period), x.value()) == continued_fraction((a*x.value()+b)/(c*x.value()+d)) 
sage: for i in range(-10, 11): 
....:     for j in range(-10, 11): 
....:         try: 
....:             foo(0,0,i,j) 
....:         except: 
....:             print("foo(0, 0, %s, %s)" % (i, j)) 
....:              
....:                                                                                                                                 
foo(0, 0, -9, 10)
foo(0, 0, -8, 9)
foo(0, 0, -8, 10)
foo(0, 0, -7, 8)
foo(0, 0, -7, 9)
foo(0, 0, -7, 10)
foo(0, 0, -6, 7)
foo(0, 0, -6, 8)
foo(0, 0, -6, 9)
foo(0, 0, -5, 6)
foo(0, 0, -5, 7)
foo(0, 0, -4, 5)
foo(0, 0, -4, 6)
foo(0, 0, -3, 4)
foo(0, 0, -2, 3)
foo(0, 0, 2, -3)
foo(0, 0, 3, -4)
foo(0, 0, 4, -6)
foo(0, 0, 4, -5)
foo(0, 0, 5, -7)
foo(0, 0, 5, -6)
foo(0, 0, 6, -9)
foo(0, 0, 6, -8)
foo(0, 0, 6, -7)
foo(0, 0, 7, -10)
foo(0, 0, 7, -9)
foo(0, 0, 7, -8)
foo(0, 0, 8, -10)
foo(0, 0, 8, -9)
foo(0, 0, 9, -10)

comment:28 Changed 15 months ago by git

Commit: be3e05fd8a41556347e3696bd9e79364dd4bfb525f0f5dcff46772dcb33ea7c018f1d4c43e1db373

Branch pushed to git repo; I updated commit sha1. New commits:

5f0f5dc29979: mark failing tests as not tested

comment:29 in reply to:  27 Changed 15 months ago by Markus Wageringel

Replying to gh-kliem:

The continue_fraction_gosper.py doctest sometimes fails for negative period as well. I'm not sure if this is a bug or just the doctest being incorrect::

I am not sure either. I have opened #32127 for this problem and have now marked this test as well as the other tests for which I opened tickets yesterday as not tested.

Last edited 15 months ago by Markus Wageringel (previous) (diff)

comment:30 Changed 15 months ago by git

Commit: 5f0f5dcff46772dcb33ea7c018f1d4c43e1db373bc1e14a889b407b41792fedb0dce5266c93ae71a

Branch pushed to git repo; I updated commit sha1. New commits:

bc1e14a29979: minor tweaks of doctests

comment:31 Changed 15 months ago by Markus Wageringel

Reviewers: Markus Wageringel

I have now reviewed your code and made a few small adjustments. The line I removed in multi_polynomial_ring_base seems redundant since R is the base ring of S, but I think the test might have failed if f happened to be zero.

Do you agree with my changes? It is inevitable that there are still sporadic failures, but to me the current branch seems robust enough for now. Nice work.

comment:32 Changed 15 months ago by gh-kliem

Thanks for the improvements.

comment:33 Changed 15 months ago by Markus Wageringel

Status: needs_reviewpositive_review

So we can set this ticket to positive then.

comment:34 Changed 15 months ago by git

Commit: bc1e14a889b407b41792fedb0dce5266c93ae71a5330692057331ff01c0a9a2801532039c27ff1d7
Status: positive_reviewneeds_review

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

5330692minor style error

comment:35 Changed 15 months ago by gh-kliem

Status: needs_reviewpositive_review

comment:36 Changed 15 months ago by gh-kliem

Thank you.

comment:37 Changed 15 months ago by Volker Braun

Status: positive_reviewneeds_work

Merge conflict

comment:38 Changed 14 months ago by gh-kliem

Branch: public/29979-rebpublic/29979-reb2
Commit: 5330692057331ff01c0a9a2801532039c27ff1d73ddf39680c30112c597187514652731b9e76173d
Status: needs_workpositive_review

Rebased.


New commits:

3ddf396merge 29979 into develop

comment:39 Changed 14 months ago by Matthias Köppe

Milestone: sage-9.4sage-9.5

comment:40 Changed 13 months ago by Volker Braun

Branch: public/29979-reb23ddf39680c30112c597187514652731b9e76173d
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.