Ticket #13156: trac_13156.patch

File trac_13156.patch, 1.9 KB (added by davidloeffler, 6 years ago)

patch against 5.11.beta3

  • sage/modular/modform/space.py

    # HG changeset patch
    # User David Loeffler <d.loeffler.01@cantab.net>
    # Date 1374581120 -3600
    # Node ID 79257c6e569dce6edfc811f1afe9bf697fd6aeb4
    # Parent  5d8c13e7b81a1e152855073f97a4d48ee97255d1
    #13156: bug creating mod form element from exact zero q-expansion
    
    diff --git a/sage/modular/modform/space.py b/sage/modular/modform/space.py
    a b  
    7070
    7171from sage.matrix.constructor import zero_matrix
    7272from sage.rings.arith import gcd
     73from sage.rings.infinity import PlusInfinity
    7374
    7475WARN=False
    7576
     
    11181119            ValueError: q-expansion does not correspond to a form in self
    11191120            sage: f = q-24*q^2+O(q^3) ; S(f)
    11201121            q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)
     1122
     1123        Test that :trac:`13156` is fixed::
     1124
     1125            sage: R.<q> = QQ[[]]
     1126            sage: ModularForms(1, 12)(R(0))
     1127            0
     1128            sage: ModularForms(1, 12)(R(1))
     1129            Traceback (most recent call last):
     1130            ...
     1131            TypeError: unable to create modular form from exact non-zero polynomial
     1132           
     1133            sage: E=ModularForms(3,12).cuspidal_subspace()
     1134            sage: f=E.gens()[0]
     1135            sage: g=f-f
     1136            sage: g.is_old()
     1137            True
    11211138        """
    11221139        if isinstance(x, element.ModularFormElement):
    11231140            if x.parent() is self:
     
    11381155            raise TypeError, "unable to coerce x (= %s) into %s"%(x, self)
    11391156       
    11401157        elif rings.is_PowerSeries(x):
     1158            if x.prec() == PlusInfinity():
     1159                if x == 0:
     1160                    return element.ModularFormElement(self, self.free_module().zero_element())
     1161                else:
     1162                    raise TypeError, "unable to create modular form from exact non-zero polynomial"
    11411163            W = self._q_expansion_module()
    11421164            if W.degree() <= x.prec():
    11431165                try: