]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/clan/random.py: add "nontrivial" param to random_clan()
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 10 Apr 2026 01:12:59 +0000 (21:12 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 10 Apr 2026 01:12:59 +0000 (21:12 -0400)
mjo/clan/random.py

index 246d51ed3dbc1b8677aed60a6cf409888232705b..688968c0bd74e003180b4b40c98e42a9d824d361 100644 (file)
@@ -2,12 +2,17 @@ r"""
 Random test helpers.
 """
 
-def random_clan():
+def random_clan(nontrivial=False):
     r"""
     Return a random clan from a pre-determined list.
 
     At the moment, this is guaranteed to return a normal decomposition.
 
+    INPUT:
+
+      - ``nontrivial`` -- boolean; whether or not the result is
+        guaranteed to be nontrivial
+
     SETUP::
 
         sage: from mjo.clan.clan import Clans
@@ -18,6 +23,11 @@ def random_clan():
         sage: random_clan() in Clans
         True
 
+    ::
+
+        sage: random_clan(nontrivial=True).rank() > 0
+        True
+
     """
     from sage.rings.rational_field import QQ
     from random import choice
@@ -28,11 +38,13 @@ def random_clan():
                                          RealSymmetricClan)
     from mjo.clan.trivial_clan import TrivialClan
 
-    choices = { TrivialClan: [QQ],
-                VinbergClan: [QQ],
+    choices = { VinbergClan: [QQ],
                 JordanSpinClan: tuple(range(1,10)),
                 RealSymmetricClan: tuple(range(1,7)),
                 ComplexHermitianClan: tuple(range(1,6)) }
+    if not nontrivial:
+        choices[TrivialClan] = [QQ]
+
     key = choice(list(choices.keys()))
     arg = choice(choices[key])
     return key(arg)