Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fix pickling for embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
xcaruso committed Apr 2, 2020
1 parent 8f40b0a commit cb588b8
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/sage/rings/finite_rings/hom_finite_field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,68 @@ cdef class FiniteFieldHomomorphism_generic(RingHomomorphism_im_gens):
return self.section()(b)

def __hash__(self):
r"""
Return a hash of this morphism
TESTS::
sage: k.<t> = GF(5^3)
sage: Frob = k.frobenius_endomorphism()
sage: embed = Frob.fixed_field()[1]
sage: hash(embed) # random
-2441354824160407762
"""
return Morphism.__hash__(self)

cdef dict _extra_slots(self):
r"""
Helper function for copying and pickling
TESTS::
sage: k.<t> = GF(5^3)
sage: Frob = k.frobenius_endomorphism()
sage: embed = Frob.fixed_field()[1]
sage: embed.__reduce__() # indirect doctest
(<built-in function unpickle_map>,
(<class 'sage.rings.finite_rings.hom_prime_finite_field.FiniteFieldHomomorphism_prime'>,
Set of field embeddings from Finite Field of size 5 to Finite Field in t of size 5^3,
{},
{'__im_gens': [1],
'_base_map': None,
'_codomain': Finite Field in t of size 5^3,
'_domain': Finite Field of size 5,
'_is_coercion': False,
'_lift': None,
'_repr_type_str': None,
'_section_class': <class 'sage.rings.finite_rings.hom_prime_finite_field.SectionFiniteFieldHomomorphism_prime'>}))
"""
cdef dict slots
slots = RingHomomorphism_im_gens._extra_slots(self)
slots['_section_class'] = self._section_class
return slots

cdef _update_slots(self, dict slots):
r"""
Helper function for copying and pickling
TESTS::
sage: k.<t> = GF(5^3)
sage: Frob = k.frobenius_endomorphism()
sage: embed = Frob.fixed_field()[1]
sage: f = loads(dumps(embed))
sage: f == embed
True
sage: f.section()
Section of Ring morphism:
From: Finite Field of size 5
To: Finite Field in t of size 5^3
Defn: 1 |--> 1
"""
RingHomomorphism_im_gens._update_slots(self, slots)
self._section_class = slots['_section_class']


cdef class FrobeniusEndomorphism_finite_field(FrobeniusEndomorphism_generic):
"""
Expand Down

0 comments on commit cb588b8

Please sign in to comment.