From 74b18f4ecf8c2ba0109a4f9e79ac701ddbd4c5a3 Mon Sep 17 00:00:00 2001 From: Darij Grinberg Date: Tue, 28 Oct 2014 11:28:37 -0400 Subject: [PATCH] review --- src/sage/combinat/tableau.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index 6422d6cb7cd..6d0e47baf58 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -5650,10 +5650,11 @@ def random_element(self): # We compute the number of involutions of size ``size``. from sage.misc.prandom import randrange involution_index = randrange(0, StandardTableaux(self.size).cardinality()) + # ``involution_index`` is our random integer `r`. partial_sum = 0 fixed_point_number = self.size % 2 - - from sage.functions.other import binomial + # ``fixed_point_number`` will become `k`. + from sage.rings.arith import binomial while True: # We add the number of involutions with ``fixed_point_number`` # fixed points. @@ -5668,10 +5669,12 @@ def random_element(self): # We generate a subset of size "fixed_point_number" of the set {1, # ..., size}. from sage.misc.prandom import sample - fixed_point_positions = set(sample(range(1, self.size + 1), fixed_point_number)) - # We generate a list of tuples with the first part being the fixed - # points of the permutation and the second part being a perfect - # matching on the remaining values. + fixed_point_positions = set(sample(xrange(1, self.size + 1), fixed_point_number)) + # We generate a list of tuples which will form the cycle + # decomposition of our random involution. This list contains + # singletons (corresponding to the fixed points of the + # involution) and pairs (forming a perfect matching on the + # remaining values). from sage.combinat.perfect_matching import PerfectMatchings permutation_cycle_rep = [(fixed_point,) for fixed_point in fixed_point_positions] + \ list(PerfectMatchings(set(range(1, self.size + 1)) - set(fixed_point_positions)).random_element())