# HG changeset patch
# User Jason Bandlow <jbandlow@gmail.com>
# Date 1245094287 14400
# Node ID 8c7e07da06802ea104ec774369cec32cf96acf90
# Parent  6c7354ace3b6e0bf4c33ddb730531bd23a9fb92c
imported patch partition-update-AM.patch

diff -r 6c7354ace3b6 -r 8c7e07da0680 sage/combinat/partition.py
--- a/sage/combinat/partition.py	Sat Jun 06 09:55:28 2009 -0700
+++ b/sage/combinat/partition.py	Mon Jun 15 15:31:27 2009 -0400
@@ -187,21 +187,21 @@
     sage: Partition([4,3,1]).corners()
     [[0, 3], [1, 2], [2, 0]]
 
-We can compute the r-core and r-quotient of a partition and build
+We can compute the core and quotient of a partition and build
 the partition back up from them.
 
 ::
 
-    sage: Partition([6,3,2,2]).r_core(3)
+    sage: Partition([6,3,2,2]).core(3)
     [2, 1, 1]
-    sage: Partition([7,7,5,3,3,3,1]).r_quotient(3)
+    sage: Partition([7,7,5,3,3,3,1]).quotient(3)
     [[2], [1], [2, 2, 2]]
     sage: p = Partition([11,5,5,3,2,2,2])
-    sage: p.r_core(3)
+    sage: p.core(3)
     []
-    sage: p.r_quotient(3)
+    sage: p.quotient(3)
     [[2, 1], [4], [1, 1, 1]]
-    sage: Partition(core_and_quotient=([],[[2, 1], [4], [1, 1, 1]]))
+    sage: Partition(core=[],quotient=[[2, 1], [4], [1, 1, 1]])
     [11, 5, 5, 3, 2, 2, 2]
 """
 #*****************************************************************************
@@ -237,96 +237,135 @@
 from integer_vector import IntegerVectors
 from cartesian_product import CartesianProduct
 from integer_list import IntegerListsLex
-
-def Partition(l=None, exp=None, core_and_quotient=None):
-    """
-    Returns a partition object.
-    
-    Note that Sage uses the English convention for partitions and
-    tableaux.
-    
-    EXAMPLES::
-    
+from sage.functions.other import ceil
+
+def Partition(mu=None, **key_word):                                              
+    """                                                                          
+    A partition is a weakly decreasing ordered sequence of non-negative          
+    integers. This function returns a Sage partition object which can            
+    be specified in one of the following ways::                                  
+      * a list (the default)                                                     
+      * using exponential notation                                               
+      * by beta numbers (TODO)                                                   
+      * specifying the core and the quotient                                     
+      * specifying the core and the canonical quotient (TODO)                    
+    See the examples below.                                                      
+                                                                                 
+    Sage follows the usual python conventions when dealing with partitions,      
+    so that the first part of the partition ``mu=Partition([4,3,2,2])`` is       
+    ``mu[0]``, the second part is ``mu[1]`` and so on. As is usual, Sage ignores 
+    trailing zeros at the end of partitions.                                     
+                                                                                 
+    EXAMPLES::                                                                   
+                                                                                 
+        sage: Partition([3,2,1])                                                 
+        [3, 2, 1]                                                                
+        sage: Partition([3,2,1,0])                                               
+        [3, 2, 1]                                                                
         sage: Partition(exp=[2,1,1])
         [3, 2, 1, 1]
-        sage: Partition(core_and_quotient=([2,1], [[2,1],[3],[1,1,1]]))
+        sage: Partition(core=[2,1], quotient=[[2,1],[3],[1,1,1]])
         [11, 5, 5, 3, 2, 2, 2]
-        sage: Partition([3,2,1])
-        [3, 2, 1]
         sage: [2,1] in Partitions()
         True
         sage: [2,1,0] in Partitions()
         False
-        sage: Partition([2,1,0])
-        [2, 1]
         sage: Partition([1,2,3])
         Traceback (most recent call last):
         ...
         ValueError: [1, 2, 3] is not a valid partition
     """
-    number_of_arguments = 0
-    for arg in ['l', 'exp', 'core_and_quotient']:
-        if locals()[arg] is not None:
-            number_of_arguments += 1
-
-    if number_of_arguments != 1:
-        raise ValueError, "you must specify exactly one argument"
-
-    if l is not None:
-        l = [i for i in l if i != 0]
-        if l in Partitions_all():
-            return Partition_class(l)
-        else:
-            raise ValueError, "%s is not a valid partition"%l
-    elif exp is not None:
-        return from_exp(exp)
-    else:
-        return from_core_and_quotient(*core_and_quotient)
-    
+    if mu is not None and len(key_word)==0:
+        mu = [i for i in mu if i != 0]
+        if mu in Partitions_all():
+            return Partition_class(mu)
+        else:
+            raise ValueError, "%s is not a valid partition"%mu
+    elif 'beta_numbers' in key_word and len(key_word)==1:
+        raise NotImplementedError
+    elif 'exp' in key_word and len(key_word)==1:
+        return Partition_class([]).from_exp(key_word['exp'])
+    elif 'core' in key_word and 'quotient' in key_word and len(key_word)==2:
+        return Partition_class([]).from_core_and_quotient(key_word['core'], key_word['quotient'])
+    elif 'core' in key_word and 'canonical_quotient' in key_word and len(key_word)==2:
+        raise NotImplementedError
+    elif 'core_and_quotient' in key_word and len(key_word)==1:
+        from sage.misc.misc import deprecation
+        deprecation('"core_and_quotient=(*)" is deprecated. Use "core=[*], quotient=[*]" instead.')
+        return Partition_class([]).from_core_and_quotient(*key_word['core_and_quotient'])
+    else:
+        raise ValueError, 'incorrect syntax for Partition()'
 
 def from_exp(a):
     """
+    ** This function is being deprecated - use Partition(exp=*) instead **
     Returns a partition from its list of multiplicities.
     
     EXAMPLES::
     
-        sage: partition.from_exp([1,2,1])
+        sage: Partition(exp=[1,2,1])
         [3, 2, 2, 1]
     """
-
-    p = []
-    for i in reversed(range(len(a))):
-        p += [i+1]*a[i]
-
-    return Partition(p)
-
+    from sage.misc.misc import deprecation
+    deprecation('"from_exp" is deprecated. Use "Partition(exp=[*])" instead.')
+    return Partition(exp=a)
 
 def from_core_and_quotient(core, quotient):
     """
-    Returns a partition from its r-core and r-quotient.
+    ** This function is being deprecated - use Partition(core=*, quotient=*) instead **
+    
+    Returns a partition from its core and quotient.
     
     Algorithm from mupad-combinat.
     
     EXAMPLES::
     
-        sage: partition.from_core_and_quotient([2,1], [[2,1],[3],[1,1,1]])
+        sage: Partition(core=[2,1], quotient=[[2,1],[3],[1,1,1]])
         [11, 5, 5, 3, 2, 2, 2]
     """
-    from sage.functions.all import ceil
-    length = len(quotient)
-    k = length*max( [ceil(len(core)/length),len(core)] + [len(q) for q in quotient] ) + length
-    v = [ core[i]-(i+1)+1 for i in range(len(core))] + [ -i + 1 for i in range(len(core)+1,k+1) ]
-    w = [ filter(lambda x: (x-i) % length == 0, v) for i in range(1, length+1) ]
-    new_w = []
-    for i in range(length):
-        new_w += [ w[i][j] + length*quotient[i][j] for j in range(len(quotient[i]))]
-        new_w += [ w[i][j] for j in range(len(quotient[i]), len(w[i])) ]
-    new_w.sort()
-    new_w.reverse()
-    return filter(lambda x: x != 0, [new_w[i-1]+i-1 for i in range(1, len(new_w)+1)])
-
+    from sage.misc.misc import deprecation
+    deprecation('"from_core_and_quotient" is deprecated. Use "Partition(core=[*],quotient=[*])" instead.')
+    return Partition(core=core,quotient=quotient)
     
 class Partition_class(CombinatorialObject):
+    def from_exp(self,exp):
+        """
+        Returns a partition from its list of multiplicities.
+        
+        EXAMPLES::
+        
+            sage: Partition(exp=[1,2,1])
+            [3, 2, 2, 1]
+        """
+        p = []
+        for i in reversed(range(len(exp))):
+            p += [i+1]*exp[i]
+        return Partition(p)
+
+    def from_core_and_quotient(self, core, quotient):
+        """
+        Returns a partition from its core and quotient.
+        
+        Algorithm from mupad-combinat.
+        
+        EXAMPLES::
+        
+            sage: Partition(core=[2,1], quotient=[[2,1],[3],[1,1,1]])
+            [11, 5, 5, 3, 2, 2, 2]
+        """
+        length = len(quotient)
+        k = length*max( [ceil(len(core)/length),len(core)] + [len(q) for q in quotient] ) + length
+        v = [ core[i]-(i+1)+1 for i in range(len(core))] + [ -i + 1 for i in range(len(core)+1,k+1) ]
+        w = [ filter(lambda x: (x-i) % length == 0, v) for i in range(1, length+1) ]
+        new_w = []
+        for i in range(length):
+            new_w += [ w[i][j] + length*quotient[i][j] for j in range(len(quotient[i]))]
+            new_w += [ w[i][j] for j in range(len(quotient[i]), len(w[i])) ]
+        new_w.sort()
+        new_w.reverse()
+        return Partition([new_w[i-1]+i-1 for i in range(1, len(new_w)+1)])
+
+
     def ferrers_diagram(self):
         """
         Return the Ferrers diagram of pi.
@@ -344,18 +383,6 @@
             *****
             **
             *        
-            sage: pi = Partitions(10).list()[11] ## [6,1,1,1,1]
-            sage: print pi.ferrers_diagram()
-            ******
-            *
-            *
-            *
-            *
-            sage: pi = Partitions(10).list()[8] ## [6, 3, 1]
-            sage: print pi.ferrers_diagram()
-            ******
-            ***
-            *
         """
         return '\n'.join(['*'*p for p in self])
 
@@ -507,8 +534,7 @@
 
     def sign(self):
         r"""
-        partition_sign( pi ) returns the sign of a permutation with cycle
-        structure given by the partition pi.
+        Returns the sign of a permutation with cycle type of the partition.
         
         This function corresponds to a homomorphism from the symmetric
         group `S_n` into the cyclic group of order 2, whose kernel
@@ -516,8 +542,6 @@
         `1` are called even partitions while partitions of sign
         `-1` are called odd.
         
-        Wraps GAP's SignPartition.
-        
         EXAMPLES::
         
             sage: Partition([5,3]).sign()
@@ -577,8 +601,7 @@
 
         - http://en.wikipedia.org/wiki/Zolotarev's_lemma
         """
-        ans=gap.eval("SignPartition(%s)"%(self))
-        return sage_eval(ans)
+        return (-1)**(self.size()-self.length())
 
     def up(self):
         r"""
@@ -791,7 +814,6 @@
             sage: Partition([5,4,2,1,1,1]).associated().associated()
             [5, 4, 2, 1, 1, 1]
         """
-
         return self.conjugate()
 
     def arm(self, i, j):
@@ -1415,28 +1437,35 @@
         return res
 
     def r_core(self, length):
-        """
-        Returns the r-core of the partition p. The construction of the
-        r-core can be visualized by repeatedly removing border strips of
-        size r from p until this is no longer possible. The remaining
-        partition is the r-core.
-        
-        EXAMPLES::
-        
-            sage: Partition([6,3,2,2]).r_core(3)
+      """ *** deprecate *** """
+      from sage.misc.misc import deprecation
+      deprecation('r_core is deprecated. Use core instead.')
+      return self.core(self, length)
+
+    def core(self, length):
+        """
+        Returns the core of the partition -- in the literature the core is
+        commonly referred to as the k-core, p-core, r-core, ... . The
+        construction of the core can be visualized by repeatedly removing
+        border strips of size r from p until this is no longer possible.
+        The remaining partition is the core.
+        
+        EXAMPLES::
+        
+            sage: Partition([6,3,2,2]).core(3)
             [2, 1, 1]
-            sage: Partition([]).r_core(3)
-            []
-            sage: Partition([8,7,7,4,1,1,1,1,1]).r_core(3)
+            sage: Partition([]).core(3)
+            []
+            sage: Partition([8,7,7,4,1,1,1,1,1]).core(3)
             [2, 1, 1]
         
         TESTS::
         
-            sage: Partition([3,3,3,2,1]).r_core(3)
-            []
-            sage: Partition([10,8,7,7]).r_core(4)
-            []
-            sage: Partition([21,15,15,9,6,6,6,3,3]).r_core(3)
+            sage: Partition([3,3,3,2,1]).core(3)
+            []
+            sage: Partition([10,8,7,7]).core(4)
+            []
+            sage: Partition([21,15,15,9,6,6,6,3,3]).core(3)
             []
         """
         p = self
@@ -1462,36 +1491,45 @@
         return filter(lambda x: x != 0, part)
 
     def r_quotient(self, length):
-        """
-        Returns the r-quotient of the partition p. The r-quotient is a list
-        of r partitions, constructed in the following way. Label each cell
-        in p with its content, modulo r. Let R_i be the set of rows ending
-        in a box labelled i, and C_i be the set of columns ending in a box
-        labelled i. Then the jth component of the r-quotient of p is the
-        partition defined by intersecting R_j with C_j+1.
-        
-        EXAMPLES::
-        
-            sage: Partition([7,7,5,3,3,3,1]).r_quotient(3)
+        """ *** deprecate *** """
+        from sage.misc.misc import deprecation
+        deprecation('r_quotient is deprecated. Use quotient instead.')
+        return self.quotient(self,length)
+
+
+    def quotient(self, length):
+        """
+        Returns the quotient of the partition  -- in the literature the
+        core is commonly referred to as the k-core, p-core, r-core, ... . The
+        quotient is a list of r partitions, constructed in the following
+        way. Label each cell in p with its content, modulo r. Let R_i be
+        the set of rows ending in a box labelled i, and C_i be the set of
+        columns ending in a box labelled i. Then the jth component of the
+        quotient of p is the partition defined by intersecting R_j with
+        C_j+1.
+        
+        EXAMPLES::
+
+            sage: Partition([7,7,5,3,3,3,1]).quotient(3)
             [[2], [1], [2, 2, 2]]
         
         TESTS::
         
-            sage: Partition([8,7,7,4,1,1,1,1,1]).r_quotient(3)
+            sage: Partition([8,7,7,4,1,1,1,1,1]).quotient(3)
             [[2, 1], [2, 2], [2]]
-            sage: Partition([10,8,7,7]).r_quotient(4)
+            sage: Partition([10,8,7,7]).quotient(4)
             [[2], [3], [2], [1]]
-            sage: Partition([6,3,3]).r_quotient(3)
+            sage: Partition([6,3,3]).quotient(3)
             [[1], [1], [2]]
-            sage: Partition([3,3,3,2,1]).r_quotient(3)
+            sage: Partition([3,3,3,2,1]).quotient(3)
             [[1], [1, 1], [1]]
-            sage: Partition([6,6,6,3,3,3]).r_quotient(3)
+            sage: Partition([6,6,6,3,3,3]).quotient(3)
             [[2, 1], [2, 1], [2, 1]]
-            sage: Partition([21,15,15,9,6,6,6,3,3]).r_quotient(3)
+            sage: Partition([21,15,15,9,6,6,6,3,3]).quotient(3)
             [[5, 2, 1], [5, 2, 1], [7, 3, 2]]
-            sage: Partition([21,15,15,9,6,6,3,3]).r_quotient(3)
+            sage: Partition([21,15,15,9,6,6,3,3]).quotient(3)
             [[5, 2], [5, 2, 1], [7, 3, 1]]
-            sage: Partition([14,12,11,10,10,10,10,9,6,4,3,3,2,1]).r_quotient(5)
+            sage: Partition([14,12,11,10,10,10,10,9,6,4,3,3,2,1]).quotient(5)
             [[3, 3], [2, 2, 1], [], [3, 3, 3], [1]]
         """
         p = self
@@ -3984,25 +4022,15 @@
     
     EXAMPLES::
     
-        sage: print ferrers_diagram([5,5,2,1])
+        sage: print Partition([5,5,2,1]).ferrers_diagram()
         *****
         *****
         **
         *        
-        sage: pi = partitions_list(10)[30] ## [6,1,1,1,1]
-        sage: print ferrers_diagram(pi)
-        ******
-        *
-        *
-        *
-        *
-        sage: pi = partitions_list(10)[33] ## [6, 3, 1]
-        sage: print ferrers_diagram(pi)
-        ******
-        ***
-        *
-    """
-    return '\n'.join(['*'*p for p in pi])
+    """
+    from sage.misc.misc import deprecation
+    deprecation('"ferrers_diagram deprecated. Use Partition(pi).ferrers_diagram() instead')
+    return Partition(pi).ferrers_diagram()
 
 
 def ordered_partitions(n,k=None):
@@ -4277,7 +4305,9 @@
 
 def partition_sign(pi):
     r"""
-    partition_sign( pi ) returns the sign of a permutation with cycle
+    ** This function is being deprecated -- use Partition(*).sign() instead.  **
+
+    Partition( pi ).sign() returns the sign of a permutation with cycle
     structure given by the partition pi.
     
     This function corresponds to a homomorphism from the symmetric
@@ -4285,14 +4315,14 @@
     is exactly the alternating group `A_n`. Partitions of sign
     `1` are called even partitions while partitions of sign
     `-1` are called odd.
-    
-    Wraps GAP's SignPartition.
-    
-    EXAMPLES::
-    
-        sage: partition_sign([5,3])
+   
+    This function is deprecated: use Partition( pi ).sign() instead.
+
+    EXAMPLES::
+    
+        sage: Partition([5,3]).sign()
         1
-        sage: partition_sign([5,2])
+        sage: Partition([5,2]).sign()
         -1
     
     Zolotarev's lemma states that the Legendre symbol
@@ -4322,7 +4352,7 @@
         sage: p = PermutationGroupElement('(1, 2, 4, 8, 5, 10, 9, 7, 3, 6)')
         sage: p.sign()
         -1
-        sage: partition_sign([10])
+        sage: Partition([10]).sign()
         -1
         sage: kronecker_symbol(11,2)
         -1
@@ -4338,7 +4368,7 @@
         1
         sage: kronecker_symbol(3,11)
         1
-        sage: partition_sign([5,1,1,1,1,1])
+        sage: Partition([5,1,1,1,1,1]).sign()
         1
     
     In both cases, Zolotarev holds.
@@ -4347,26 +4377,29 @@
 
     - http://en.wikipedia.org/wiki/Zolotarev's_lemma
     """
-    ans=gap.eval("SignPartition(%s)"%(pi))
-    return sage_eval(ans)
+    from sage.misc.misc import deprecation
+    deprecation('"partition_sign deprecated. Use Partition(pi).sign() instead')
+    return Partition(pi).sign()
 
 def partition_associated(pi):
     """
+    ** This function is being deprecated -- use Partition(*).conjugate() instead.  **
+
     partition_associated( pi ) returns the "associated" (also called
     "conjugate" in the literature) partition of the partition pi which
     is obtained by transposing the corresponding Ferrers diagram.
     
     EXAMPLES::
     
-        sage: partition_associated([2,2])
+        sage: Partition([2,2]).conjugate()
         [2, 2]
-        sage: partition_associated([6,3,1])
+        sage: Partition([6,3,1]).conjugate()
         [3, 2, 2, 1, 1, 1]
-        sage: print ferrers_diagram([6,3,1])
+        sage: print Partition([6,3,1]).ferrers_diagram()
         ******
         ***
         *
-        sage: print ferrers_diagram([3,2,2,1,1,1])
+        sage: print Partition([6,3,1]).conjugate().ferrers_diagram()
         ***
         **
         **
@@ -4374,5 +4407,7 @@
         *
         *
     """
-    return list(Partition(pi).conjugate())
-            
+    from sage.misc.misc import deprecation
+    deprecation('"partition_associated deprecated. Use Partition(pi).conjugte() instead')
+    return Partition(pi).conjugate()
+            
diff -r 6c7354ace3b6 -r 8c7e07da0680 sage/combinat/ribbon_tableau.py
--- a/sage/combinat/ribbon_tableau.py	Sat Jun 06 09:55:28 2009 -0700
+++ b/sage/combinat/ribbon_tableau.py	Mon Jun 15 15:31:27 2009 -0400
@@ -142,7 +142,7 @@
     """
     if shape in partition.Partitions():
         shape = partition.Partition(shape)
-        shape = skew_partition.SkewPartition([shape, shape.r_core(length)])
+        shape = skew_partition.SkewPartition([shape, shape.core(length)])
     else:
         shape = skew_partition.SkewPartition(shape)
 
@@ -880,7 +880,7 @@
             sage: a = SkewPartition([[8,7,6,5,1,1],[2,1,1]])
             sage: weight = [3,3,2]
             sage: k = 3
-            sage: s = SemistandardMultiSkewTableaux(a.r_quotient(k),weight)
+            sage: s = SemistandardMultiSkewTableaux(a.quotient(k),weight)
             sage: len(s.list())
             34
             sage: RibbonTableaux(a,weight,k).cardinality()
diff -r 6c7354ace3b6 -r 8c7e07da0680 sage/combinat/sf/llt.py
--- a/sage/combinat/sf/llt.py	Sat Jun 06 09:55:28 2009 -0700
+++ b/sage/combinat/sf/llt.py	Mon Jun 15 15:31:27 2009 -0400
@@ -146,14 +146,14 @@
             
         elif isinstance(skp, list) and skp[0] in sage.combinat.skew_partition.SkewPartitions():
             #skp is a list of skew partitions
-            skp =  [sage.combinat.partition.Partition(core_and_quotient=([], skp[i][0])) for i in range(len(skp))]
-            skp += [sage.combinat.partition.Partition(core_and_quotient=([], skp[i][1])) for i in range(len(skp))]
+            skp =  [sage.combinat.partition.Partition(core=[], quotient=skp[i][0]) for i in range(len(skp))]
+            skp += [sage.combinat.partition.Partition(core=[], quotient=skp[i][1]) for i in range(len(skp))]
             mu = sage.combinat.partition.Partitions(ZZ(sum( [ s.size() for s in skp] ) / self.level()))
 
             
         elif isinstance(skp, list) and skp[0] in sage.combinat.partition.Partitions():
             #skp is a list of partitions
-            skp = sage.combinat.partition.Partition(core_and_quotient=([], skp))
+            skp = sage.combinat.partition.Partition(core=[], quotient=skp)
             mu = sage.combinat.partition.Partitions( ZZ(sum(skp) / self.level() ))
         else:
             raise ValueError, "LLT polynomials not defined for %s"%skp
diff -r 6c7354ace3b6 -r 8c7e07da0680 sage/combinat/skew_partition.py
--- a/sage/combinat/skew_partition.py	Sat Jun 06 09:55:28 2009 -0700
+++ b/sage/combinat/skew_partition.py	Mon Jun 15 15:31:27 2009 -0400
@@ -452,22 +452,28 @@
         return G
 
 
-    def r_quotient(self, k):
+    def r_quotient(self, length):
+      """ *** deprecate *** """
+      from sage.misc.misc import deprecation
+      deprecation('r_quotient is deprecated. Use quotient instead.')
+      return self.quotient(self,length)
+
+    def quotient(self, k):
         """
         The quotient map extended to skew partitions.
         
         EXAMPLES::
         
-            sage: SkewPartition([[3, 3, 2, 1], [2, 1]]).r_quotient(2)
+            sage: SkewPartition([[3, 3, 2, 1], [2, 1]]).quotient(2)
             [[[3], []], [[], []]]
         """
         ## k-th element is the skew partition built using the k-th partition of the
         ## k-quotient of the outer and the inner partition.
         ## This bijection is only defined if the inner and the outer partition
         ## have the same core
-        if self.inner().r_core(k) == self.outer().r_core(k):
-            rqinner = self.inner().r_quotient(k)
-            rqouter = self.outer().r_quotient(k)
+        if self.inner().core(k) == self.outer().core(k):
+            rqinner = self.inner().quotient(k)
+            rqouter = self.outer().quotient(k)
             return [ SkewPartition_class([rqouter[i],rqinner[i]]) for i in range(k) ]
         else:
             raise ValueError, "quotient map is only defined for skew partitions with inner and outer partitions having the same core"
