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
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
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)