# HG changeset patch
# User Christian Stump <christian.stump at gmail.com>
# Date 1367571881 7200
# Node ID 98e9365aefcbde9114ff1355722d40413d2763ab
# Parent 1077314f416653b28e199c382667a1f11e444bdd
Trac 14497: fixes bug to convert zero to rationals
diff git a/sage/rings/universal_cyclotomic_field/universal_cyclotomic_field.py b/sage/rings/universal_cyclotomic_field/universal_cyclotomic_field.py
a

b

class UniversalCyclotomicField(UniqueRep 
1243  1243  4/5 
1244  1244  sage: x.parent() 
1245  1245  Rational Field 
 1246  
 1247  sage: UCF(0)._rational_() 
 1248  0 
 1249  
 1250  sage: UCF.gen(5)._rational_() 
 1251  Traceback (most recent call last): 
 1252  ... 
 1253  TypeError: No conversion of E(5) to the rational field QQ. 
1246  1254  """ 
1247   if self.is_rational(): 
 1255  if self.is_zero(): 
 1256  return QQ.zero() 
 1257  elif self.is_rational(): 
1248  1258  return self.value._monomial_coefficients[(1,0)] 
1249   raise TypeError("No conversion of %s to the rational field QQ."%str(self)) 
 1259  else: 
 1260  raise TypeError("No conversion of %s to the rational field QQ."%str(self)) 
1250  1261  
1251  1262  def _integer_(self): 
1252  1263  r""" 
… 
… 
class UniversalCyclotomicField(UniqueRep 
1495  1506  return self.parent().one() 
1496  1507  elif k == 1: 
1497  1508  return self 
 1509  elif self.is_zero(): 
 1510  return self.parent().zero() 
1498  1511  elif self.is_rational(): 
1499  1512  return self.parent()._from_dict({ (1,0) : self.value._monomial_coefficients[(1,0)]**k }, remove_zeros=False) 
1500  1513  elif len(self.value._monomial_coefficients) == 1: 