# HG changeset patch
# User Johan Bosman <johan.g.bosman@gmail.com>
# Date 1305044964 3600
# Node ID 62712000f0a2b17b20e4e9c59092ddef239a2c03
# Parent 847a0615a3a8feefa364145a3a6ac147d7ce19ef
Trac 11319: allow coercion from prime residue field into prime finite field
diff r 847a0615a3a8 r 62712000f0a2 sage/rings/finite_rings/finite_field_prime_modn.py
a

b


136  136  5 
137  137  sage: 12 % 7 
138  138  5 
 139  sage: ZZ.residue_field(7).hom(GF(7))(1) # See trac 11319 
 140  1 
139  141  """ 
140  142  from sage.rings.integer_ring import ZZ 
141  143  from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic 
… 
… 

145  147  return integer_mod.Integer_to_IntegerMod(self) 
146  148  elif isinstance(S, IntegerModRing_generic): 
147  149  from sage.rings.residue_field import ResidueField_generic 
148   if S.characteristic() == self.characteristic() and not isinstance(S, ResidueField_generic): 
 150  if S.characteristic() == self.characteristic() and \ 
 151  (not isinstance(S, ResidueField_generic) or S.degree() == 1): 
149  152  try: 
150  153  return integer_mod.IntegerMod_to_IntegerMod(S, self) 
151  154  except TypeError: 
diff r 847a0615a3a8 r 62712000f0a2 sage/rings/residue_field.pyx
a

b


508  508  sage: F = OK.residue_field(P) 
509  509  sage: F.has_coerce_map_from(GF(13)) # indirect doctest 
510  510  True 
511   sage: GF(13).has_coerce_map_from(F) 
512   False 
 511  sage: GF(13).has_coerce_map_from(F) # See trac 11319 
 512  True 
513  513  
514  514  #sage: R.<t> = GF(17)[]; P = R.ideal(t^3 + t^2 + 7) 
515  515  #sage: k.<a> = P.residue_field() 