From bf5b68a6f738e9f59adf57dbccb8936286d6bc99 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 9 Apr 2026 21:12:59 -0400 Subject: [PATCH] mjo/clan/random.py: add "nontrivial" param to random_clan() --- mjo/clan/random.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mjo/clan/random.py b/mjo/clan/random.py index 246d51e..688968c 100644 --- a/mjo/clan/random.py +++ b/mjo/clan/random.py @@ -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) -- 2.53.0