Ticket #15269: trac_15269-review-ts.patch

File trac_15269-review-ts.patch, 1.9 KB (added by tscrim, 8 years ago)
  • sage/combinat/tableau.py

    # HG changeset patch
    # User Travis Scrimshaw <tscrim@ucdavis.edu>
    # Date 1381685686 25200
    # Node ID f66b412d534db51930538892527226bf609a0d23
    # Parent  3117b4505bce4075f378a123a6abea6b76017ac2
    #15269: review patch.
    
    diff --git a/sage/combinat/tableau.py b/sage/combinat/tableau.py
    a b class Tableau(CombinatorialObject, Eleme 
    12171217
    12181218            sage: Tableau([[1,3,3,7],[4,2],[2,3]]).weight()
    12191219            [1, 2, 3, 1, 0, 0, 1]
     1220
     1221        TESTS:
     1222
     1223        We check that this agrees with going to the word::
     1224
     1225            sage: t = Tableau([[1,3,4,7],[6,2],[2,3]])
     1226            sage: def by_word(T):
     1227            ....:     ed = T.to_word().evaluation_dict()
     1228            ....:     m = max(ed.keys()) + 1
     1229            ....:     return [ed.get(k,0) for k in range(1,m)]
     1230            sage: by_word(t) == t.weight()
     1231            True
     1232            sage: SST = SemistandardTableaux(shape=[3,1,1])
     1233            sage: all(by_word(t) == t.weight() for t in SST)
     1234            True
    12201235        """
    12211236        if len(self) == 0:
    12221237            return []
    1223         m = max([max(row) for row in self])
     1238        m = max(max(row) for row in self)
    12241239        res = [0] * m
    12251240        for row in self:
    12261241            for i in row:
    12271242                res[i - 1] += 1
    12281243        return res
    1229         # Old alternative implementation:
    1230         # ed = self.to_word().evaluation_dict()
    1231         # entries = ed.keys()
    1232         # m = max(entries) + 1 if entries else -1
    1233         # return [ed.get(k,0) for k in range(1,m)]
    12341244
    12351245    evaluation = weight
    12361246
    class Tableau(CombinatorialObject, Eleme 
    14171427        cell_list = []
    14181428        for r in range(len(self)-1, -1, -1):
    14191429            rth_row = self[r]
    1420             for c in range(len(rth_row)):
    1421                 if rth_row[c] == i:
     1430            for c,val in enumerate(rth_row):
     1431                if val == i:
    14221432                    cell_list.append((r,c))
    14231433        return cell_list
    14241434