From b192330d4253f2eb25a4df04daf0fd17fae265d8 Mon Sep 17 00:00:00 2001 From: Sebastian Spindler Date: Wed, 13 Nov 2024 21:41:00 +0100 Subject: [PATCH] Avoid non-invertible scaling and zero endomorphism --- .../function_field/drinfeld_modules/drinfeld_module.py | 10 +++++++++- .../rings/function_field/drinfeld_modules/morphism.py | 6 ++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py index c4ad9f1376d..e29626593b4 100644 --- a/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py +++ b/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py @@ -1855,7 +1855,7 @@ def rank(self): def velu(self, isog): r""" - Return a new Drinfeld module such that input is an + Return a new Drinfeld module such that ``isog`` defines an isogeny to this module with domain ``self``; if no such isogeny exists, raise an exception. @@ -2018,11 +2018,19 @@ def hom(self, x, codomain=None): Traceback (most recent call last): ... ValueError: Ore polynomial does not define a morphism + + Check that x = 0 (without specified codomain) gives the zero endomorphism:: + + sage: phi.hom(K.zero()) + Endomorphism of Drinfeld module defined by ... + Defn: 0 """ # When `x` is in the function ring (or something that coerces to it): if self.function_ring().has_coerce_map_from(x.parent()): return self.Hom(self)(x) if codomain is None: + if x.is_zero(): + return self.Hom(self)(0) try: codomain = self.velu(x) except TypeError: diff --git a/src/sage/rings/function_field/drinfeld_modules/morphism.py b/src/sage/rings/function_field/drinfeld_modules/morphism.py index 82c1d7a0da1..26d90ae625a 100644 --- a/src/sage/rings/function_field/drinfeld_modules/morphism.py +++ b/src/sage/rings/function_field/drinfeld_modules/morphism.py @@ -536,9 +536,11 @@ def __invert__(self): sage: K. = Fq.extension(3) sage: coeffs = [z] + [K.random_element() for _ in range(10)] sage: phi = DrinfeldModule(A, coeffs) - sage: f = phi.hom(K.random_element()) + sage: a = K.random_element() + sage: while a.is_zero(): + ....: a = K.random_element() + sage: f = phi.hom(a) sage: g = ~f - sage: (f*g).is_identity() True sage: (g*f).is_identity()