# HG changeset patch
# User Valentin Feray <feray at labri.fr>
# Date 1280893909 25200
# Node ID f979bfe72ace37e92679e98579012a342a39537e
# Parent 23502da21e72d07ffcd490ccd18c78b281c51674
[mq]: fix_perfectmatching_vf.patch
diff git a/sage/combinat/perfect_matching.py b/sage/combinat/perfect_matching.py
a

b

REFERENCES: 
53  53  #***************************************************************************** 
54  54  
55  55  
56   #from sage.combinat.permutation import Permutation_Class 
57  56  from sage.structure.unique_representation import UniqueRepresentation 
58  57  from sage.structure.parent import Parent 
59  58  from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets 
… 
… 
from sage.structure.element import Eleme 
63  62  from sage.misc.cachefunc import cached_method 
64  63  from sage.rings.integer import Integer 
65  64  from sage.misc.flatten import flatten 
66   from sage.combinat.permutation import Permutation 
 65  from sage.combinat.permutation import Permutation, Permutation_class 
67  66  from sage.sets.set import Set 
68  67  from sage.combinat.partition import Partition 
69  68  from sage.misc.misc_c import prod 
… 
… 
class PerfectMatching(ElementWrapper): 
149  148  sage: TestSuite(m).run() 
150  149  sage: m=PerfectMatching([]) 
151  150  sage: TestSuite(m).run() 
 151  sage: PerfectMatching(6) 
 152  Traceback (most recent call last): 
 153  ... 
 154  ValueError: cannot convert p (= 6) to a PerfectMatching 
152  155  """ 
153  156  # we have to extract from the argument p the set of objects of the 
154  157  # matching and the list of pairs. 
… 
… 
class PerfectMatching(ElementWrapper): 
159  162  data=(map(tuple,p)) 
160  163  #check if the data are correct 
161  164  if not all([len(t)==2 for t in data]): 
162   raise ValueError, "%s is not a valid perfect matching: all elements of the list must be pairs"%p 
 165  raise ValueError, ("%s is not a valid perfect matching:\n" 
 166  "all elements of the list must be pairs"%p) 
163  167  if len(objects) < 2*len(data): 
164   raise ValueError, "%s is not a valid perfect matching: there are some repetitions"%p 
 168  raise ValueError, ("%s is not a valid perfect matching:\n" 
 169  "there are some repetitions"%p) 
165  170  # Second case: p is a permutation or a list of integers, we have to 
166  171  # check if it is a fixpointfree involution. 
167  172  elif ((isinstance(p,list) and 
168  173  all(map(lambda x: (isinstance(x,Integer) or isinstance(x,int)),p ))) 
169   or isinstance(p,sage.combinat.permutation.Permutation_class)): 
 174  or isinstance(p,Permutation_class)): 
170  175  p=Permutation(p) 
171  176  n=len(p) 
172  177  if not(p.cycle_type()==[2 for i in range(n//2)]): 