# Ticket #5048: trac_5048-sl2z_coercion-rebased_for_10452.patch

File trac_5048-sl2z_coercion-rebased_for_10452.patch, 8.8 KB (added by davidloeffler, 12 years ago)

Version that will apply happily after #10452

• ## sage/modular/arithgroup/arithgroup_element.py

# HG changeset patch
# User David Loeffler <d.loeffler.01@cantab.net>
# Date 1291928574 0
# Parent  7f73030ab02b9425e645b7abd5a711b1ebb5f5b5
#5048: fix coercion issues with elements of congruence subgroups

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/arithgroup_element.py
 a class ArithmeticSubgroupElement(MultiplicativeGroupElement): r""" An element of an arithmetic subgroup of {\rm SL}_2(\ZZ). An element of the group {\rm SL}_2(\ZZ), i.e. a 2x2 integer matrix of determinant 1. """ def __init__(self, parent, x, check=True): Create an element of an arithmetic subgroup. INPUT: - parent - an arithmetic subgroup - x - data defining a 2x2 matrix over ZZ is an arithmetic subgroup, and that x defines a matrix of determinant 1 We tend not to create elements of arithmetic subgroups that aren't SL2Z, in order to avoid coercion issues (that is, the other arithmetic subgroups are "facade parents"). EXAMPLES:: sage: G = Gamma0(27) [ 3  2] [28 19] sage: x.parent() Congruence Subgroup Gamma0(7) Modular Group SL(2,Z) We check that #5048 is fixed:: sage: a = Gamma0(10).1 * Gamma0(5).2; a # random sage: a.parent() Modular Group SL(2,Z) """ return self.parent()(self.__x * right.__x, check=False)
• ## sage/modular/arithgroup/arithgroup_generic.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/arithgroup_generic.py
 a assuming that it has a working element testing routine. """ def __init__(self): r""" Standard init routine. EXAMPLE:: sage: G = Gamma1(7) sage: G.category() # indirect doctest Category of groups """ group.Group.__init__(self) def _repr_(self): r""" Return the string representation of self.
• ## sage/modular/arithgroup/arithgroup_perm.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/arithgroup_perm.py
 a [1 1] [0 1] """ g = SL2Z(g) g = SL2Z(g, check=check) if (not check) or (self.permutation_action(g)(1) == 1): g._parent = self return g else: raise TypeError, "Not in group"
• ## sage/modular/arithgroup/congroup_gamma.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_gamma.py
 a TypeError: matrix must have diagonal entries (=1, 7) congruent to 1 modulo 5, and off-diagonal entries (=1,6) divisible by 5 """ if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self: return x x = ArithmeticSubgroupElement(self, x, check=check) from all import SL2Z x = SL2Z(x, check) if not check: return x
• ## sage/modular/arithgroup/congroup_gamma0.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_gamma0.py
 a ... TypeError: matrix must have lower left entry (=23) divisible by 12 """ if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self: return x x = ArithmeticSubgroupElement(self, x, check=check) from all import SL2Z x = SL2Z(x, check) if not check: return x
• ## sage/modular/arithgroup/congroup_gamma1.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_gamma1.py
 a ... TypeError: matrix must have diagonal entries (=1, 7) congruent to 1 modulo 5, and lower left entry (=6) divisible by 5 """ if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self: return x x = ArithmeticSubgroupElement(self, x, check=check) from all import SL2Z x = SL2Z(x, check) if not check: return x c = x.c() d = x.d() N = self.level() if (a%N == 1) and (c%N == 0) and (d%N == 1): if (a%N == 1) and (c%N == 0): return x # don't need to check d == 1 mod N as this is automatic from det else: raise TypeError, "matrix must have diagonal entries (=%s, %s) congruent to 1 modulo %s, and lower left entry (=%s) divisible by %s" %(a, d, N, c, N)
• ## sage/modular/arithgroup/congroup_gammaH.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_gammaH.py
 a ... TypeError: matrix must have lower right entry (=3) congruent modulo 10 to some element of H """ if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self: return x x = ArithmeticSubgroupElement(self, x, check=check) from all import SL2Z x = SL2Z(x, check) if not check: return x
• ## sage/modular/arithgroup/congroup_generic.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_generic.py
 a if level <= 0: raise ArithmeticError, "Congruence groups only defined for positive levels." self.__level = level ArithmeticSubgroup.__init__(self) def _repr_(self): """ else: raise NotImplementedError def __call__(self, x, check=True): """ Coerce x into self. NOTE: This function should be overridden by any subclass the user will interact with directly. EXAMPLES:: sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroup(5).__call__(0) Traceback (most recent call last): ... NotImplementedError """ if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self: return x raise NotImplementedError
• ## sage/modular/arithgroup/congroup_sl2z.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_sl2z.py
 a ################################################################################ from congroup_gamma0 import Gamma0_class from arithgroup_element import ArithmeticSubgroupElement from sage.rings.integer_ring import ZZ from sage.modular.cusps import Cusp from sage.rings.arith import gcd """ return _SL2Z_ref, () def __call__(self, x, check=True): r""" Create an element of self from x. If check=True (the default), check that x really defines a 2x2 integer matrix of det 1. """ return ArithmeticSubgroupElement(self, x, check=check) def _repr_(self): """ Return the string representation of self.
• ## sage/modular/modform/constructor.py

diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/modform/constructor.py
 a (5, Congruence Subgroup Gamma0(5), 7, Integer Ring) sage: type(v[0]), type(v[1]), type(v[2]), type(v[3]) (, , , , ) sage: canonical_parameters( 5, 7, 7, ZZ )