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

Commit

Permalink
Try a bunch of stuff in RingExtensionHomomorphism.__init__ check. Not…
Browse files Browse the repository at this point in the history
… sure if it is all a good idea, but it makes a test pass
  • Loading branch information
roed314 committed Feb 19, 2022
1 parent 7624b5d commit 69610f0
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/sage/rings/ring_extension_morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -208,27 +208,36 @@ cdef class RingExtensionHomomorphism(RingMap):
if current_morphism(x) != y:
raise ValueError("images do not define a valid homomorphism")
coercion_morphism = backend_morphism(domain.defining_morphism(base))
restriction_current_morphism = current_morphism * coercion_morphism
if base_map is None:
backend_base_map = coercion_morphism
else:
backend_base_map = backend_morphism(base_map)
if backend_base_map.domain() is not current_morphism.domain():
phi = backend_base_map.domain().coerce_map_from(current_morphism.domain())
# the base map might be an automorphism of the base
if backend_base_map.codomain() is coercion_morphism.domain():
backend_base_map = coercion_morphism * backend_base_map
if backend_base_map.domain() is not restriction_current_morphism.domain():
phi = backend_base_map.domain().coerce_map_from(restriction_current_morphism.domain())
if phi is None:
msg = "Cannot coerce base map into correct domain:\n"
msg += f" Domain is {backend_base_map.domain()}\n"
msg += f" Needs to be {current_morphism.domain()}"
msg += f" Needs to be {restriction_current_morphism.domain()}"
raise ValueError(msg)
backend_base_map = backend_base_map * phi
if backend_base_map.codomain() is not current_morphism.codomain():
phi = current_morphism.codomain().coerce_map_from(backend_base_map.codomain())
if backend_base_map.codomain() is not restriction_current_morphism.codomain():
R = backend_base_map.codomain()
phi = restriction_current_morphism.codomain().coerce_map_from(R)
if phi is None:
# Try into the backend
back, from_back, to_back = backend_parent(R, map=True)
if back is not R and to_back is not None and restriction_current_morphism.codomain().has_coerce_map_from(back):
phi = restriction_current_morphism.codomain().coerce_map_from(back) * to_back
if phi is None:
msg = "Cannot coerce base map into correct codomain:\n"
msg += f" Domain is {backend_base_map.codomain()}\n"
msg += f" Needs to be {current_morphism.codomain()}"
msg += f" Codomain is {backend_base_map.codomain()}\n"
msg += f" Needs to be {restriction_current_morphism.codomain()}"
raise ValueError(msg)
backend_base_map = phi * backend_base_map
restriction_current_morphism = current_morphism * coercion_morphism
differing = are_different_morphisms(restriction_current_morphism, backend_base_map)
if differing:
msg = "images do not define a valid homomorphism:\n"
Expand Down

0 comments on commit 69610f0

Please sign in to comment.