# HG changeset patch
# User PaulOlivier Dehaye <paulolivier@gmail.com>
# Date 1306853886 7200
# Node ID aabc13e9ba456cb947723555485971bbd535d9ed
# Parent 45daebca2840fd49d3271697a57aa05e92c5dc35
#11412: fixed creation of partition from core and quotient
diff r 45daebca2840 r aabc13e9ba45 sage/combinat/partition.py
a

b


306  306  
307  307  sage: Partition(core=[2,1], quotient=[[2,1],[3],[1,1,1]]) 
308  308  [11, 5, 5, 3, 2, 2, 2] 
 309  sage: test = lambda x, k: x == Partition(core=x.core(k),quotient=x.quotient(k)) 
 310  sage: all(test(mu,k) for k in range(1,5) for n in range(10) for mu in Partitions(n)) 
 311  True 
 312  sage: test2 = lambda core, mus: \ 
 313  Partition(core=core, quotient=mus).core(len(mus)) == core and \ 
 314  Partition(core=core, quotient=mus).quotient(len(mus)) == mus 
 315  sage: all(test2(core,tuple(mus)) for k in range(1,10) for n_core in range(10k) for core in Partitions(n_core) if core.core(k) == core for n_mus in range(10k) for mus in PartitionTuples(n_mus,k)) 
 316  True 
309  317  """ 
310  318  length = len(quotient) 
311   k = length*max( [ceil(len(core)/length),len(core)] + [len(q) for q in quotient] ) + length 
312   v = [ core[i](i+1)+1 for i in range(len(core))] + [ i + 1 for i in range(len(core)+1,k+1) ] 
 319  k = length*max(len(q) for q in quotient) + len(core) 
 320  # k needs to be large enough. this seems to me like the smallest it can be 
 321  v = [core[i]i for i in range(len(core))] + [ i for i in range(len(core),k) ] 
313  322  w = [ filter(lambda x: (xi) % length == 0, v) for i in range(1, length+1) ] 
314  323  new_w = [] 
315  324  for i in range(length): 
316   new_w += [ w[i][j] + length*quotient[i][j] for j in range(len(quotient[i]))] 
317   new_w += [ w[i][j] for j in range(len(quotient[i]), len(w[i])) ] 
318   new_w.sort() 
319   new_w.reverse() 
320   return Partition([new_w[i1]+i1 for i in range(1, len(new_w)+1)]) 
321   
 325  lw = len(w[i]) 
 326  lq = len(quotient[i]) 
 327  # k needs to be chosen so lw >= lq 
 328  new_w += [ w[i][j] + length*quotient[i][j] for j in range(lq)] 
 329  new_w += [ w[i][j] for j in range(lq,lw)] 
 330  new_w.sort(reverse=True) 
 331  return Partition([new_w[i]+i for i in range(len(new_w))]) 
 332  
322  333  class Partition_class(CombinatorialObject): 
323  334  def ferrers_diagram(self): 
324  335  """ 