-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #29935: implicitly fuzz RNG-dependent doctests with a random ran…
…dom seed Our documentation and tests include a variety of examples and tests involving randomness. Those depend on a randomness seed, and up to Sage 9.1 they always used the same one: 0. Thus every run of `sage -t` or `make [p]test[all][long]` would run those "random" doctests deterministically. In many cases, the output of those tests even relied on that. As a result, random examples and tests were actually testing that they were run non-randomly! This is reminiscent of an [https://xkcd.com/221/ xkcd comic illustration of random number generators]. Based on these considerations and the related [https://groups.google.com/d/msg/sage- devel/c4UbKSdt3Aw/UQAo1iYoAAAJ sage-devel discussion], we propose to: - allow specifying a randomness when running tests (#29962), - adapt tests involving randomness, making sure they test mathematical functionality independent of the randomness seed used to run them (see roadmap), - default to a random randomness seed when none is specified (present ticket), thus making those tests more robust and more useful, by becoming more likely to reveal bugs in a variety of cases including corner cases. The first step (see #29962, merged in Sage 9.2) adds a `--random-seed` flag to `sage -t`, allowing: {{{ sage -t --long --random-seed=9876543210 src/sage/ }}} Still, when no randomness seed is specified, the default seed 0 is used. This means most testers test with the same randomness seed, making "random" doctests still mostly deterministic in practice. Here is a way to pick a random randomness seed and run tests with it (can be used to work on the tickets in the roadmap): {{{ $ randseed() { sage -c "import sage.misc.randstate as randstate; \ randstate.set_random_seed(); \ print(randstate.initial_seed())"; } $ SEED=$(randseed) $ DIR=src/sage $ echo "$ sage -t --long --random-seed=${SEED} ${DIR}" \ && ./sage -t --long --random-seed=${SEED} ${DIR} }}} Once examples and tests involving randomness have been adapted, the present ticket puts the final touch by making it so that when running tests with no seed specified, a random one will be used: {{{ sage -t src/sage/all.py Running doctests with ID 2020-06-23-23-19-03-8003eea5. ... sage -t --warn-long 89.5 --random- seed=273987373473433732996760115183658447263 src/sage/all.py [16 tests, 0.73 s] ---------------------------------------------------------------------- All tests passed! ---------------------------------------------------------------------- Total time for all tests: 0.8 seconds cpu time: 0.7 seconds cumulative wall time: 0.7 seconds }}} Being displayed in the output, the seed used can be used again if needed: {{{ sage -t --warn-long 89.5 --random- seed=273987373473433732996760115183658447263 src/sage/all.py }}} allowing to explore any problematic case revealed by running the tests with that seed. Roadmap: - Allow fuzzing: #29962 - Make all parts of sage ready for default fuzzing: - #29945: coding - #29963: geometry - #29964: libs - #29965: graphs - #32107: groups - #29967: interfaces - #29968: algebras - #29969: misc - #29970: arith - #29971: categories - #29972: stats - #29973: sets - #29974: combinat - #29975: numerical, probability - #29976: matrix - #29977: modular - #29978: modules - #29979: rings - #29980: crypto - #29981: documentation - #29982: dynamics - #29983: finance - #29984: symbolic - #29985: schemes - #29986: plot - #32188: various missed tests along the way - #32216: Update the developers guide for implicitly fuzzing doctests - Finally make fuzzing default with this ticket. Follow-up: - #32544: Meta-ticket: Fix unstable doctests detected after #29935 - Remove `set_random_seed` in doctests where possible. Errors discovered by this ticket: - #29936: Hyperbolic geometry bugs revealed by fuzzing - #29945: Failing doctest in `src/sage/coding/linear_code.py` (just a wrong doctest, will be fixed here) - #29954: Unstable plotting - #29956: Bug in `KlyachkoBundle_class.random_deformation` - #29957: Bug in `ContinuedFraction` rounding - #29958: Too many strong articulation points - #29961: Random symbolic expression is completely unstable - #30045: Bug in Reed-Solomon encoder and error-erasure decoder - Index error with random derangement (fixed in #29974) - #31890: simplify_hypergeometric is unstable - #31891: `ZeroDivisonError` when creating polynomial system - #31892: Conic parametrization broken - #32075: Polynomial generic power trunk broken - #32083: Various errors with polybori including segmentation fault - #32084 `_nth_root_naive` fails for integer mod - #32085: Errors when computing norms of padic elements - #32086: apply_homography unstable for continue fraction - #32095: DiFUB algorithm fails on some random graph - #32108: Fix random tree on one or less vertices - #32109: Fix 0/0 in ore function field - #32111: Unstable minimal polynomial for element of 2-adic Eisenstein Extension Field in pi defined by x^4 - 2*a - #32117: Random relative number field checks only irreducibility over QQ - #32118: AlgebraicForm checks invariance with random matrix that can be the identity - #32124: SL2Z.random_element unstable - #32125: random Ore polynomials do not respect minimum degree bound - #32126: padic QpLC.random_element is broken - #32127: gosper_iterator of continued fractions is unstable - #32129: sage_input is unreliable for elements of ComplexField - #32131: Cut width of graph with one edge incorrect - #32132: Wrong gyration orbit length - #32138: is_groebner fails over fraction fields - #32141: Unstable doctest involving permutation groups - #32169: Bug in edge disjoint spanning trees - #32185: Failing weak order assertion on random symbolic expression - #32186: Random bounded tolerance graph - #32187: permutation group generated by list perms in L of degree n incorrect when compared to GAP - #32657: `plot_vector_field` unstable URL: https://trac.sagemath.org/29935 Reported by: dimpase Ticket author(s): Jonathan Kliem Reviewer(s): Michael Orlitzky
- Loading branch information
Showing
18 changed files
with
84 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters