Ticket #11370: trac_11370-perm_empty_standard_fix-fh.patch

File trac_11370-perm_empty_standard_fix-fh.patch, 1.2 KB (added by hivert, 11 years ago)
  • sage/combinat/permutation.py

    # HG changeset patch
    # User Florent Hivert <Florent.Hivert@univ-rouen.fr>
    # Date 1306155576 -7200
    # Node ID c92b256cf64c0289398558181b033591eb9aeb3e
    # Parent  b3909260e27c0a9b02e6ce7480811f5fbd599ca1
    #11370: permutation.to_standard() breaks on empty permutations
            fixed the return type of from_reduced_word([])
    
    diff --git a/sage/combinat/permutation.py b/sage/combinat/permutation.py
    a b def from_reduced_word(rw): 
    34653465        sage: permutation.from_reduced_word([])
    34663466        []
    34673467    """
    3468     if rw == []:
    3469         return []
     3468    if not rw:
     3469        return Permutation([])
    34703470
    34713471    p = [i+1 for i in range(max(rw)+1)]
    34723472
    def permutohedron_lequal(p1, p2, side="r 
    42354235def to_standard(p):
    42364236    r"""
    42374237    Returns a standard permutation corresponding to the permutation p.
    4238    
     4238
    42394239    EXAMPLES::
    4240    
     4240
    42414241        sage: import sage.combinat.permutation as permutation
    42424242        sage: permutation.to_standard([4,2,7])
    42434243        [2, 1, 3]
    42444244        sage: permutation.to_standard([1,2,3])
    42454245        [1, 2, 3]
     4246        sage: permutation.to_standard([])
     4247        []
    42464248    """
    4247 
     4249    if not p:
     4250        return Permutation([])
    42484251    s = p[:]
    42494252    biggest = max(p) + 1
    42504253    i = 1