Ticket #9682: fix_perfectmatching_vf.patch

File fix_perfectmatching_vf.patch, 2.8 KB (added by vferay, 11 years ago)
  • sage/combinat/perfect_matching.py

    # 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: 
    56 #from sage.combinat.permutation import Permutation_Class
    5756from sage.structure.unique_representation import UniqueRepresentation
    5857from sage.structure.parent import Parent
    5958from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
    from sage.structure.element import Eleme 
    6362from sage.misc.cachefunc import cached_method
    6463from sage.rings.integer import Integer
    6564from sage.misc.flatten import flatten
    66 from sage.combinat.permutation import Permutation
     65from sage.combinat.permutation import Permutation, Permutation_class
    6766from sage.sets.set import Set
    6867from sage.combinat.partition import Partition
    6968from sage.misc.misc_c import prod
    class PerfectMatching(ElementWrapper): 
    149148             sage: TestSuite(m).run()
    150149             sage: m=PerfectMatching([])
    151150             sage: TestSuite(m).run()
     151             sage: PerfectMatching(6)
     152             Traceback (most recent call last):
     153             ...
     154             ValueError: cannot convert p (= 6) to a PerfectMatching             
    152155        """
    153156        # we have to extract from the argument p the set of objects of the
    154157        # matching and the list of pairs.
    class PerfectMatching(ElementWrapper): 
    159162            data=(map(tuple,p))
    160163            #check if the data are correct
    161164            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)
    163167            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)
    165170        # Second case: p is a permutation or a list of integers, we have to
    166171        # check if it is a fix-point-free involution.
    167172        elif ((isinstance(p,list) and
    168173            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)):
    170175            p=Permutation(p)
    171176            n=len(p)
    172177            if not(p.cycle_type()==[2 for i in range(n//2)]):