Ticket #13837: trac_13837.2.patch

File trac_13837.2.patch, 10.8 KB (added by davidloeffler, 9 years ago)

copy with non-ASCII characters removed

  • sage/modular/modsym/ambient.py

    # HG changeset patch
    # User Andre Apitzsch <andre.apitzsch@etit.tu-chemnitz.de>
    # Date 1355697245 -3600
    # Node ID dd219b1f3c552905d83b65b4804c6e6425a7ff1f
    # Parent  23061edf00176562a9d754123cfebbb8e3f631d3
    trac 13837: typo + syntax changes in modular/modsym/ambient.py
    
    diff --git a/sage/modular/modsym/ambient.py b/sage/modular/modsym/ambient.py
    a b  
    149149        """
    150150        weight = int(weight)
    151151        if weight <= 1:
    152             raise ValueError, "Weight (=%s) Modular symbols of weight <= 1 not defined."%weight
     152            raise ValueError("Weight (=%s) Modular symbols of weight <= 1 not defined."%weight)
    153153        if not arithgroup.is_CongruenceSubgroup(group):
    154             raise TypeError, "group must be a congruence subgroup"
     154            raise TypeError("group must be a congruence subgroup")
    155155
    156156        sign = int(sign)
    157157        if not isinstance(base_ring, rings.Ring) and base_ring.is_field():
    158             raise TypeError, "base_ring must be a commutative ring"
     158            raise TypeError("base_ring must be a commutative ring")
    159159
    160160        if character == None and arithgroup.is_Gamma0(group):
    161161            character = dirichlet.TrivialCharacter(group.level(), base_ring)
     
    454454        """
    455455        if isinstance(x, free_module_element.FreeModuleElement):
    456456            if x.degree() != self.dimension():
    457                 raise TypeError, "Incompatible degrees: x has degree %s but modular symbols space has dimension %s"%(
    458                     x.degree(), self.dimension())
     457                raise TypeError("Incompatible degrees: x has degree %s\
     458                    but modular symbols space has dimension %s"%(
     459                    x.degree(), self.dimension()))
    459460            #if x.parent().base_ring() != self.base_ring():
    460461            #    raise TypeError, "Vector x is over %s, but modular symbols space is over %s."%(
    461462            #        x.parent().base_ring(), self.base_ring())
     
    482483            else:
    483484                return self.modular_symbol(x)
    484485
    485         raise TypeError, "No coercion of %s into %s defined."%(x, self)
     486        raise TypeError("No coercion of %s into %s defined."%(x, self))
    486487
    487488
    488489    def change_ring(self, R):
     
    521522            ValueError: No coercion defined
    522523        """
    523524        if not R.has_coerce_map_from(self.base_ring()):
    524             raise ValueError, "No coercion defined"
     525            raise ValueError("No coercion defined")
    525526        else:
    526527            return self.change_ring(R)
    527528
     
    556557
    557558        """
    558559        if not isinstance(g, list):
    559             raise TypeError, "g must be a list"
     560            raise TypeError("g must be a list")
    560561        if not len(g) == 4:
    561             raise TypeError, "g must be a list of length 4"
     562            raise TypeError("g must be a list of length 4")
    562563        return self._matrix_of_operator_on_modular_symbols(self, [g])
    563564
    564565    def manin_symbol(self, x, check=True):
     
    590591            if len(x) == 3:
    591592                # Manin symbol of the form (i, u, v), which corresponds to [X^i*Y^(k-2-i), (u,v)].
    592593                if x[0] < 0 or x[0] > self.weight()-2:
    593                     raise ValueError, "The first entry of the tuple (=%s) must be an integer between 0 and k-2 (=%s)."%(
    594                         x, self.weight()-2)
     594                    raise ValueError("The first entry of the tuple (=%s)\
     595                        must be an integer between 0 and k-2 (=%s)."%(
     596                        x, self.weight()-2))
    595597            else:
    596                 raise ValueError, "x (=%s) must be of length 2 or 3"%x
     598                raise ValueError("x (=%s) must be of length 2 or 3"%x)
    597599        # end check
    598600
    599601        N = self.level()
     
    770772                x = [0,x[0],x[1]]
    771773            elif len(x) == 3:
    772774                if x[0] < 0 or x[0] > self.weight()-2:
    773                     raise ValueError, "The first entry of the tuple (=%s) must be an integer between 0 and k-2 (=%s)."%(
    774                         x, self.weight()-2)
     775                    raise ValueError("The first entry of the tuple (=%s)\
     776                        must be an integer between 0 and k-2 (=%s)."%(
     777                        x, self.weight()-2))
    775778            else:
    776                 raise ValueError, "x (=%s) must be of length 2 or 3"%x
     779                raise ValueError("x (=%s) must be of length 2 or 3"%x)
    777780            i = rings.Integer(x[0])
    778781            alpha = Cusp(x[1])
    779782            beta = Cusp(x[2])
     
    815818        """
    816819        if check:
    817820            if len(x) != 3:
    818                 raise ValueError, "%s must have length 3"%x
     821                raise ValueError("%s must have length 3"%x)
    819822            f = x[0]
    820823            R = self.base_ring()['X','Y']
    821824            X = R.gen(0)
    822825            try:
    823826                f = R(f)
    824827            except TypeError:
    825                 raise ValueError, \
    826                       "f must be coercible to a polynomial over %s"%self.base_ring()
     828                raise ValueError("f must be coercible to a polynomial \
     829                    over %s"%self.base_ring())
    827830            if (not f.is_homogeneous()) or (f.degree() != self.weight()-2):
    828                 raise ValueError, "f must be a homogeneous polynomial of degree k-2"
     831                raise ValueError("f must be a homogeneous polynomial of degree k-2")
    829832            alpha = Cusp(x[1])
    830833            beta = Cusp(x[2])
    831834        else:
     
    892895
    893896        ALGORITHM:
    894897
    895         Uses Heilbronn-Cremonma matrices of `p` is prime, else use
     898        Use Heilbronn-Cremona matrices if `p` is prime, else use
    896899        Heilbronn-Merel matrices.
    897900
    898901        EXAMPLES:
     
    12631266        """
    12641267        chi = self.character()
    12651268        if chi is not None and chi.order() > 2:
    1266             raise ValueError, "Atkin-Lehner only leaves space invariant when character is trivial or quadratic.  In general it sends M_k(chi) to M_k(1/chi)"
     1269            raise ValueError("Atkin-Lehner only leaves space invariant when character is trivial or quadratic.  In general it sends M_k(chi) to M_k(1/chi)")
    12671270
    12681271        N = self.level()
    12691272        k = self.weight()
    12701273        R = self.base_ring()
    12711274        if N%d != 0:
    1272             raise ValueError, "d must divide N"
     1275            raise ValueError("d must divide N")
    12731276       
    12741277        g, x, y = arith.xgcd(d, -N//d)
    12751278        g = [d*x, y, N, d]
     
    15681571        """
    15691572        if isinstance(x, manin_symbols.ManinSymbol):
    15701573            if not x.parent().weight() == self.weight():
    1571                 raise ArithmeticError, "incompatible weights: Manin symbol has weight %s, but modular symbols space has weight %s"%(
    1572                     x.parent().weight(), self.weight())
     1574                raise ArithmeticError("incompatible weights: Manin symbol\
     1575                    has weight %s, but modular symbols space has weight %s"%(
     1576                    x.parent().weight(), self.weight()))
    15731577            t = self.manin_symbols().index(x.tuple())
    15741578            if isinstance(t, tuple):
    15751579                i, scalar = t
     
    15821586            M = x.parent()
    15831587            if M.ambient_hecke_module() != self:
    15841588                # TODO -- sometimes do something more sophisticated here.
    1585                 raise TypeError, "Modular symbol (%s) does not lie in this space."%x
     1589                raise TypeError("Modular symbol (%s) does not lie in this space."%x)
    15861590            return self(x.element())
    15871591           
    15881592        else:
    1589             raise ValueError, "Cannot create element of %s from %s."%(x,self)
     1593            raise ValueError("Cannot create element of %s from %s."%(x,self))
    15901594
    15911595    def dual_star_involution_matrix(self):
    15921596        """
     
    21032107        """
    21042108
    21052109        if not dirichlet.is_DirichletCharacter(eps):
    2106             raise TypeError, "eps must be a Dirichlet character."
     2110            raise TypeError("eps must be a Dirichlet character.")
    21072111        if (i < 0) or (i > self.weight()-2):
    2108             raise ValueError, "i must be between 0 and k-2."
     2112            raise ValueError("i must be between 0 and k-2.")
    21092113
    21102114        m = eps.modulus()
    21112115        s = self(0)
     
    22242228        elif algorithm == 'padic':
    22252229            B = B.echelon_form(algorithm='padic', include_zero_rows=False)
    22262230        else:
    2227             raise ValueError, "unknown algorithm '%s'"%algorithm
     2231            raise ValueError("unknown algorithm '%s'"%algorithm)
    22282232        W = B.row_module()
    22292233        if d != 1:
    22302234            W = W.scale(1/d)
     
    22852289            (1, -zeta6 - 1, 2*zeta6 - 2, zeta6, -2*zeta6 + 1, -2*zeta6 + 4, 0, 2*zeta6 - 1, -zeta6, 3*zeta6 - 3)
    22862290        """
    22872291        if self.sign() == 0:
    2288             raise ValueError, "sign must be nonzero"
     2292            raise ValueError("sign must be nonzero")
    22892293        v = list(v)
    22902294       
    22912295        # Get decomposition of this space
     
    23242328            cache = {}
    23252329            for i in range(len(D)):
    23262330                nz = D[i]._eigen_nonzero()
    2327                 if cache.has_key(nz):
     2331                if nz in cache:
    23282332                     R = cache[nz]
    23292333                else:
    23302334                     R = self.hecke_images(nz, v)
     
    24022406        k = int(k)
    24032407        sign = int(sign)
    24042408        if not sign in [-1,0,1]:
    2405             raise TypeError, "sign must be an int in [-1,0,1]"
     2409            raise TypeError("sign must be an int in [-1,0,1]")
    24062410           
    24072411        ModularSymbolsAmbient.__init__(self, weight=k, group=arithgroup.Gamma0(N),
    24082412                                       sign=sign, base_ring=F, custom_init=custom_init)
     
    34013405            # higher level (and we don't implement the degeneracy raising maps
    34023406            # anyway)
    34033407        else:
    3404             raise ValueError, "N (=%s) should be a factor of the level of this space (=%s)" % (N, self.level())
     3408            raise ValueError("N (=%s) should be a factor of the level\
     3409                of this space (=%s)" % (N, self.level()))
    34053410
    34063411
    34073412class ModularSymbolsAmbient_wtk_eps(ModularSymbolsAmbient):
     
    37113716        elif N % self.level() == 0:
    37123717            eps = self.character().extend(N)
    37133718        else:
    3714             raise ValueError, "The level N (=%s) must be a divisor or multiple of the modulus of the character (=%s)"%(N, self.level())
     3719            raise ValueError("The level N (=%s) must be a divisor or multiple of the modulus of the character (=%s)"%(N, self.level()))
    37153720        return modsym.ModularSymbols(eps, self.weight(), self.sign(), self.base_ring())
    37163721
    37173722    def modular_symbols_of_sign(self, sign):
     
    38063811           
    38073812        """
    38083813        if self.weight() != 2:
    3809             raise NotImplementedError, "hecke images only implemented when the weight is 2"
     3814            raise NotImplementedError("hecke images only implemented when the weight is 2")
    38103815        chi = self.character()
    38113816        # Find basis vector for ambient space such that it is not in
    38123817        # the kernel of the dual space corresponding to self.