# 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 qexpansion
diff git a/sage/modular/modform/space.py b/sage/modular/modform/space.py
a

b


70  70  
71  71  from sage.matrix.constructor import zero_matrix 
72  72  from sage.rings.arith import gcd 
 73  from sage.rings.infinity import PlusInfinity 
73  74  
74  75  WARN=False 
75  76  
… 
… 

1118  1119  ValueError: qexpansion does not correspond to a form in self 
1119  1120  sage: f = q24*q^2+O(q^3) ; S(f) 
1120  1121  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 nonzero polynomial 
 1132  
 1133  sage: E=ModularForms(3,12).cuspidal_subspace() 
 1134  sage: f=E.gens()[0] 
 1135  sage: g=ff 
 1136  sage: g.is_old() 
 1137  True 
1121  1138  """ 
1122  1139  if isinstance(x, element.ModularFormElement): 
1123  1140  if x.parent() is self: 
… 
… 

1138  1155  raise TypeError, "unable to coerce x (= %s) into %s"%(x, self) 
1139  1156  
1140  1157  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 nonzero polynomial" 
1141  1163  W = self._q_expansion_module() 
1142  1164  if W.degree() <= x.prec(): 
1143  1165  try: 