Skip to content

Commit 4e3136b

Browse files
author
Release Manager
committed
sagemathgh-40384: src/sage/geometry/cone.py: speed up a random_cone() test We have two `random_cone()` tests that test hard-to-reach code paths. Usually these will run for a long time, until we get lucky. But testing these code paths does not actually require randomization -- we need only a random seed that triggers the desired path. This commit combines the two slow tests, and chooses a random seed (for those tests only) that makes them succeed quickly. URL: sagemath#40384 Reported by: Michael Orlitzky Reviewer(s):
2 parents 65f826f + e5375f4 commit 4e3136b

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/sage/geometry/cone.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6575,27 +6575,21 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
65756575
generators. Please decrease min_rays.
65766576
65776577
Ensure that we can obtain a cone in three dimensions with a large
6578-
number (in particular, more than 2*dim) rays. The ``max_rays`` is
6579-
not strictly necessary, but it minimizes the number of times that
6580-
we will loop with an absurd, unattainable, number of rays::
6581-
6582-
sage: K = random_cone(min_ambient_dim=3, # long time
6583-
....: max_ambient_dim=3,
6584-
....: min_rays=7,
6585-
....: max_rays=9)
6586-
sage: K.nrays() >= 7 # long time
6587-
True
6588-
sage: K.lattice_dim() # long time
6589-
3
6590-
6591-
We need three dimensions to obtain five rays; we should throw out
6592-
cones in zero/one/two dimensions until we get lucky::
6593-
6594-
sage: K = random_cone(max_ambient_dim=3, min_rays=5)
6595-
sage: K.nrays() >= 5
6578+
number (in particular, more than 2*dim) rays. Note that at least
6579+
dimension three is required for seven rays; we should throw out
6580+
cones in zero/one/two dimensions until we get lucky. We set the
6581+
random seed manually to ensure that the test completes in a
6582+
reasonable amount of time::
6583+
6584+
sage: # long time
6585+
sage: _initial_seed = initial_seed()
6586+
sage: set_random_seed(8)
6587+
sage: K = random_cone(max_ambient_dim=3, min_rays=7)
6588+
sage: K.nrays() >= 7
65966589
True
65976590
sage: K.lattice_dim()
65986591
3
6592+
sage: set_random_seed(_initial_seed)
65996593
66006594
It is an error to request a non-strictly-convex trivial cone::
66016595

0 commit comments

Comments
 (0)