# Ticket #11319: trac_11319_prime_field_coercion.patch

File trac_11319_prime_field_coercion.patch, 2.0 KB (added by johanbosman, 10 years ago)
• ## sage/rings/finite_rings/finite_field_prime_modn.py

```# 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 5 sage: 12 % 7 5 sage: ZZ.residue_field(7).hom(GF(7))(1)  # See trac 11319 1 """ from sage.rings.integer_ring import ZZ from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic return integer_mod.Integer_to_IntegerMod(self) elif isinstance(S, IntegerModRing_generic): from sage.rings.residue_field import ResidueField_generic if S.characteristic() == self.characteristic() and not isinstance(S, ResidueField_generic): if S.characteristic() == self.characteristic() and \ (not isinstance(S, ResidueField_generic) or S.degree() == 1): try: return integer_mod.IntegerMod_to_IntegerMod(S, self) except TypeError:
• ## sage/rings/residue_field.pyx

`diff -r 847a0615a3a8 -r 62712000f0a2 sage/rings/residue_field.pyx`
 a sage: F = OK.residue_field(P) sage: F.has_coerce_map_from(GF(13)) # indirect doctest True sage: GF(13).has_coerce_map_from(F) False sage: GF(13).has_coerce_map_from(F)  # See trac 11319 True #sage: R. = GF(17)[]; P = R.ideal(t^3 + t^2 + 7) #sage: k. = P.residue_field()