Skip to content

Commit 1de1d45

Browse files
author
Release Manager
committed
Trac #29971: Make categories doctests ready for random seeds
This ticket makes {{{ sage -t --long --random-seed=n src/sage/categories/ }}} pass for different values `n` than just `0`. URL: https://trac.sagemath.org/29971 Reported by: gh-kliem Ticket author(s): Jonathan Kliem Reviewer(s): Markus Wageringel
2 parents 6864757 + d3457de commit 1de1d45

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/sage/categories/finite_enumerated_sets.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,13 @@ def _random_element_from_unrank(self):
479479
EXAMPLES::
480480
481481
sage: C = FiniteEnumeratedSets().example()
482-
sage: C.random_element()
483-
1
484-
sage: C._random_element_from_unrank()
485-
2
482+
sage: n = C.random_element()
483+
sage: n in C
484+
True
485+
486+
sage: n = C._random_element_from_unrank()
487+
sage: n in C
488+
True
486489
487490
TODO: implement _test_random which checks uniformness
488491
"""

src/sage/categories/modules_with_basis.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -1276,20 +1276,22 @@ def random_element(self, n=2):
12761276
12771277
EXAMPLES::
12781278
1279-
sage: DihedralGroup(6).algebra(QQ).random_element()
1280-
-1/95*() - 1/2*(1,4)(2,5)(3,6)
1279+
sage: x = DihedralGroup(6).algebra(QQ).random_element()
1280+
sage: x.parent() is DihedralGroup(6).algebra(QQ)
1281+
True
12811282
12821283
Note, this result can depend on the PRNG state in libgap in a way
12831284
that depends on which packages are loaded, so we must re-seed GAP
12841285
to ensure a consistent result for this example::
12851286
12861287
sage: libgap.set_seed(0)
12871288
0
1288-
sage: SU(2, 13).algebra(QQ).random_element(1)
1289-
1/2*[ 1 9*a + 2]
1290-
[2*a + 12 2]
1291-
sage: CombinatorialFreeModule(ZZ, Partitions(4)).random_element() # random
1292-
2*B[[2, 1, 1]] + B[[2, 2]]
1289+
sage: m = SU(2, 13).algebra(QQ).random_element(1)
1290+
sage: m.parent() is SU(2, 13).algebra(QQ)
1291+
True
1292+
sage: p = CombinatorialFreeModule(ZZ, Partitions(4)).random_element()
1293+
sage: p.parent() is CombinatorialFreeModule(ZZ, Partitions(4))
1294+
True
12931295
12941296
TESTS:
12951297

0 commit comments

Comments
 (0)