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, 11 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
    # Node ID f45efdbe8d70cce32eb1b68adcc4258309a23932
    # Parent  7f73030ab02b9425e645b7abd5a711b1ebb5f5b5
    #5048: fix coercion issues with elements of congruence subgroups
    
    diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/arithgroup_element.py
    a b  
    2525
    2626class ArithmeticSubgroupElement(MultiplicativeGroupElement):
    2727    r"""
    28     An element of an arithmetic subgroup of `{\rm SL}_2(\ZZ)`.
     28    An element of the group `{\rm SL}_2(\ZZ)`, i.e. a 2x2 integer matrix of
     29    determinant 1.
    2930    """
    3031
    3132    def __init__(self, parent, x, check=True):
     
    3334        Create an element of an arithmetic subgroup.
    3435
    3536        INPUT:
     37
    3638        - parent - an arithmetic subgroup
    3739
    3840        - x - data defining a 2x2 matrix over ZZ
     
    4244          is an arithmetic subgroup, and that
    4345          x defines a matrix of determinant 1
    4446
     47        We tend not to create elements of arithmetic subgroups that aren't
     48        SL2Z, in order to avoid coercion issues (that is, the other arithmetic
     49        subgroups are "facade parents").
     50
    4551        EXAMPLES::
    4652
    4753            sage: G = Gamma0(27)
     
    162168            [ 3  2]
    163169            [28 19]
    164170            sage: x.parent()
    165             Congruence Subgroup Gamma0(7)
     171            Modular Group SL(2,Z)
     172
     173        We check that #5048 is fixed::
     174
     175            sage: a = Gamma0(10).1 * Gamma0(5).2; a # random
     176            sage: a.parent()
     177            Modular Group SL(2,Z)
     178
    166179        """
    167180        return self.parent()(self.__x * right.__x, check=False)
    168181
  • sage/modular/arithgroup/arithgroup_generic.py

    diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/arithgroup_generic.py
    a b  
    4747    assuming that it has a working element testing routine.
    4848    """
    4949
     50    def __init__(self):
     51        r"""
     52        Standard init routine.
     53
     54        EXAMPLE::
     55
     56            sage: G = Gamma1(7)
     57            sage: G.category() # indirect doctest
     58            Category of groups
     59        """
     60        group.Group.__init__(self)
     61
    5062    def _repr_(self):
    5163        r"""
    5264        Return the string representation of self.
  • sage/modular/arithgroup/arithgroup_perm.py

    diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/arithgroup_perm.py
    a b  
    185185            [1 1]
    186186            [0 1]
    187187        """
    188         g = SL2Z(g)
     188        g = SL2Z(g, check=check)
    189189        if (not check) or (self.permutation_action(g)(1) == 1):
    190             g._parent = self
    191190            return g
    192191        else:
    193192            raise TypeError, "Not in group"
  • sage/modular/arithgroup/congroup_gamma.py

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

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

    diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_gamma1.py
    a b  
    288288            ...
    289289            TypeError: matrix must have diagonal entries (=1, 7) congruent to 1 modulo 5, and lower left entry (=6) divisible by 5
    290290        """
    291         if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self:
    292             return x
    293         x = ArithmeticSubgroupElement(self, x, check=check)
     291        from all import SL2Z
     292        x = SL2Z(x, check)
    294293        if not check:
    295294            return x
    296295       
     
    298297        c = x.c()
    299298        d = x.d()
    300299        N = self.level()
    301         if (a%N == 1) and (c%N == 0) and (d%N == 1):
     300        if (a%N == 1) and (c%N == 0):
    302301            return x
     302            # don't need to check d == 1 mod N as this is automatic from det
    303303        else:
    304304            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)
    305305
  • sage/modular/arithgroup/congroup_gammaH.py

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

    diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_generic.py
    a b  
    6464        if level <= 0:
    6565            raise ArithmeticError, "Congruence groups only defined for positive levels."
    6666        self.__level = level
     67        ArithmeticSubgroup.__init__(self)
    6768
    6869    def _repr_(self):
    6970        """
     
    197198        else:
    198199            raise NotImplementedError
    199200
    200     def __call__(self, x, check=True):
    201         """
    202         Coerce x into self.
    203 
    204         NOTE: This function should be overridden by any subclass the
    205         user will interact with directly.
    206 
    207         EXAMPLES::
    208 
    209             sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroup(5).__call__(0)
    210             Traceback (most recent call last):
    211             ...
    212             NotImplementedError
    213         """
    214         if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self:
    215             return x
    216         raise NotImplementedError
  • sage/modular/arithgroup/congroup_sl2z.py

    diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/arithgroup/congroup_sl2z.py
    a b  
    2020################################################################################
    2121
    2222from congroup_gamma0 import Gamma0_class
     23from arithgroup_element import ArithmeticSubgroupElement
    2324from sage.rings.integer_ring import ZZ
    2425from sage.modular.cusps import Cusp
    2526from sage.rings.arith import gcd
     
    9293        """
    9394        return _SL2Z_ref, ()
    9495
     96    def __call__(self, x, check=True):
     97        r"""
     98        Create an element of self from x. If check=True (the default), check
     99        that x really defines a 2x2 integer matrix of det 1.
     100        """
     101        return ArithmeticSubgroupElement(self, x, check=check)
     102
    95103    def _repr_(self):
    96104        """
    97105        Return the string representation of self.
  • sage/modular/modform/constructor.py

    diff -r 7f73030ab02b -r f45efdbe8d70 sage/modular/modform/constructor.py
    a b  
    8484        (5, Congruence Subgroup Gamma0(5), 7, Integer Ring)
    8585        sage: type(v[0]), type(v[1]), type(v[2]), type(v[3])
    8686        (<type 'sage.rings.integer.Integer'>,
    87          <class 'sage.modular.arithgroup.congroup_gamma0.Gamma0_class'>,
     87         <class 'sage.modular.arithgroup.congroup_gamma0.Gamma0_class_with_category'>,
    8888         <type 'sage.rings.integer.Integer'>,
    8989         <type 'sage.rings.integer_ring.IntegerRing_class'>)
    9090        sage: canonical_parameters( 5, 7, 7, ZZ )