Ticket #9290: trac-9290-review.patch

File trac-9290-review.patch, 6.4 KB (added by chapoton, 8 years ago)
  • sage/combinat/root_system/cartan_matrix.py

    # HG changeset patch
    # User Frederic Chapoton <chapoton at math.univ-lyon1.fr>
    # Date 1382300757 -7200
    # Node ID b6212ce803a2bf1e73fdac7f33525ba1fc970891
    # Parent  f82f4f1be6c3087fe7d660d6eed5f1fd92e439a3
    trac #9290 review, minor details
    
    diff --git a/sage/combinat/root_system/cartan_matrix.py b/sage/combinat/root_system/cartan_matrix.py
    a b class CartanMatrix(Matrix_integer_sparse 
    353353
    354354        EXAMPLES::
    355355
    356             sage: C = CartanMatrix(['B',4,1])
    357356            sage: cm = CartanMatrix([[2,-5],[-2,2]])
    358357            sage: cm.symmetrizer()
    359358            Finite family {0: 2, 1: 5}
    class CartanMatrix(Matrix_integer_sparse 
    373372        if not sym:
    374373            raise ValueError("the Cartan matrix is not symmetrizable")
    375374        iset = self.index_set()
    376         # The result from is_symmetrizable needs to be scaled to integer coefficients
     375        # The result from is_symmetrizable needs to be scaled
     376        # to integer coefficients
    377377        from sage.rings.arith import LCM
    378378        from sage.rings.all import QQ
    379379        scalar = LCM(map(lambda x: QQ(x).denominator(), sym))
    380         return Family( {iset[i]: ZZ(val*scalar) for i,val in enumerate(sym)} )
     380        return Family( {iset[i]: ZZ(val*scalar) for i, val in enumerate(sym)} )
    381381
    382382    ##########################################################################
    383383    # Cartan type methods
  • sage/combinat/root_system/coxeter_group.py

    diff --git a/sage/combinat/root_system/coxeter_group.py b/sage/combinat/root_system/coxeter_group.py
    a b def CoxeterGroup(data, implementation=No 
    148148            return WeylGroup(cartan_type)
    149149        return CoxeterMatrixGroup(cartan_type, base_ring, index_set)
    150150
    151     raise NotImplementedError("Coxeter group of type %s as %s group not implemented "%(cartan_type, implementation))
     151    raise NotImplementedError("Coxeter group of type %s as %s group not implemented " % (cartan_type, implementation))
    152152
    153153@cached_function
    154154def is_chevie_available():
  • sage/combinat/root_system/weyl_group.py

    diff --git a/sage/combinat/root_system/weyl_group.py b/sage/combinat/root_system/weyl_group.py
    a b def WeylGroup(x, prefix=None): 
    190190    try:
    191191        ct = CartanType(x)
    192192    except TypeError:
    193         ct = CartanMatrix(x) # See if it's a Cartan matrix
     193        ct = CartanMatrix(x)  # See if it is a Cartan matrix
    194194    if ct.is_finite():
    195195        return WeylGroup_gens(ct.root_system().ambient_space(), prefix=prefix)
    196196    return WeylGroup_gens(ct.root_system().root_space(), prefix=prefix)
  • sage/groups/matrix_gps/coxeter_group.py

    diff --git a/sage/groups/matrix_gps/coxeter_group.py b/sage/groups/matrix_gps/coxeter_group.py
    a b from sage.rings.all import ZZ 
    3232from sage.rings.infinity import infinity
    3333from sage.rings.universal_cyclotomic_field.universal_cyclotomic_field import UniversalCyclotomicField
    3434
     35
    3536class CoxeterMatrixGroup(FinitelyGeneratedMatrixGroup_generic, UniqueRepresentation):
    3637    r"""
    3738    A Coxeter group represented as a matrix group.
    class CoxeterMatrixGroup(FinitelyGenerat 
    185186    @staticmethod
    186187    def __classcall_private__(cls, data, base_ring=None, index_set=None):
    187188        """
    188         Normalize arguements to ensure a unique representation.
     189        Normalize arguments to ensure a unique representation.
    189190
    190191        EXAMPLES::
    191192
    class CoxeterMatrixGroup(FinitelyGenerat 
    222223            n = G.num_verts()
    223224
    224225            # Setup the basis matrix as all 2 except 1 on the diagonal
    225             data = matrix(ZZ, [[2]*n for i in range(n)])
     226            data = matrix(ZZ, [[2]*n]*n)
    226227            for i in range(n):
    227                 data[i,i] = ZZ.one()
     228                data[i, i] = ZZ.one()
    228229
    229230            verts = G.vertices()
    230231            for e in G.edges():
    231232                m = e[2]
    232233                if m is None:
    233234                    m = 3
    234                 elif m == infinity or m == -1: # FIXME: Hack because there is no ZZ\cup\{\infty\}
     235                elif m == infinity or m == -1:  # FIXME: Hack because there is no ZZ\cup\{\infty\}
    235236                    m = -1
    236237                elif m <= 1:
    237238                    raise ValueError("invalid Coxeter graph label")
    238239                i = verts.index(e[0])
    239240                j = verts.index(e[1])
    240                 data[j,i] = data[i,j] = m
     241                data[j, i] = data[i, j] = m
    241242
    242243            if index_set is None:
    243244                index_set = G.vertices()
    class CoxeterMatrixGroup(FinitelyGenerat 
    250251                raise ValueError("the Coxeter matrix is not symmetric")
    251252            if any(d != 1 for d in data.diagonal()):
    252253                raise ValueError("the Coxeter matrix diagonal is not all 1")
    253             if any(val <= 1 and val != -1 for i,row in enumerate(data.rows()) for val in row[i+1:]):
     254            if any(val <= 1 and val != -1 for i, row in enumerate(data.rows())
     255                   for val in row[i+1:]):
    254256                raise ValueError("invalid Coxeter label")
    255257
    256258            if index_set is None:
    class CoxeterMatrixGroup(FinitelyGenerat 
    288290            from sage.functions.trig import cos
    289291            from sage.symbolic.constants import pi
    290292            val = lambda x: base_ring(2*cos(pi / x)) if x != -1 else base_ring(2)
    291         gens = [MS.one() + MS({(i, j): val(coxeter_matrix[i,j]) for j in range(n)})
     293        gens = [MS.one() + MS({(i, j): val(coxeter_matrix[i, j])
     294                               for j in range(n)})
    292295                for i in range(n)]
    293         FinitelyGeneratedMatrixGroup_generic.__init__(self, n, base_ring, gens, category=CoxeterGroups())
     296        FinitelyGeneratedMatrixGroup_generic.__init__(self, n, base_ring,
     297                                                      gens,
     298                                                      category=CoxeterGroups())
    294299
    295300    def _repr_(self):
    296301        """
    class CoxeterMatrixGroup(FinitelyGenerat 
    399404            [ 0  1 -1]
    400405        """
    401406        if not i in self._index_set:
    402             raise ValueError("%s is not in the index set %s"%(i, self.index_set()))
     407            raise ValueError("%s is not in the index set %s" % (i, self.index_set()))
    403408        return self.gen(self._index_set.index(i))
    404409
    405410    class Element(MatrixGroupElement_generic):