sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.47k stars 485 forks source link

random doctest error in `DrinfeldModuleMorphism` #38953

Closed dcoudert closed 1 week ago

dcoudert commented 2 weeks ago

Steps To Reproduce

sage -t --warn-long 5.0 --random-seed=253765283679809954490123971186451640485 src/sage/rings/function_field/drinfeld_modules/morphism.py

Expected Behavior

All tests passed.

Actual Behavior

sage -t --warn-long 5.0 --random-seed=253765283679809954490123971186451640485 src/sage/rings/function_field/drinfeld_modules/morphism.py
**********************************************************************
File "src/sage/rings/function_field/drinfeld_modules/morphism.py", line 539, in sage.rings.function_field.drinfeld_modules.morphism.?.__invert__
Failed example:
    f = phi.hom(K.random_element())
Exception raised:
    Traceback (most recent call last):
      File "/usr/share/miniconda3/envs/sage/lib/python3.11/site-packages/sage/doctest/forker.py", line 715, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/usr/share/miniconda3/envs/sage/lib/python3.11/site-packages/sage/doctest/forker.py", line 1136, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.rings.function_field.drinfeld_modules.morphism.?.__invert__[5]>", line 1, in <module>
        f = phi.hom(K.random_element())
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/share/miniconda3/envs/sage/lib/python3.11/site-packages/sage/rings/function_field/drinfeld_modules/drinfeld_module.py", line 2027, in hom
        codomain = self.velu(x)
                   ^^^^^^^^^^^^
      File "/usr/share/miniconda3/envs/sage/lib/python3.11/site-packages/sage/rings/function_field/drinfeld_modules/drinfeld_module.py", line 1934, in velu
        raise e
    ValueError: the input does not define an isogeny

Additional Information

using this method, we can find a failing case

def foo():
    Fq = GF(5)
    A.<T> = Fq[]
    K.<z> = Fq.extension(3)
    while True:
        coeffs = [z] + [K.random_element() for _ in range(10)]
        phi = DrinfeldModule(A, coeffs)
        r = K.random_element()
        try:
            f = phi.hom(r)
        except:
            print(coeffs)
            print(type(r))
            print(r)
            break
sage: foo()
[z, 2, 3*z^2 + 4*z + 3, 3*z^2 + 4*z + 4, 3*z^2 + 4, 3*z^2 + z + 2, 3*z^2 + 4*z + 4, 2*z^2 + 4*z, z^2 + 4*z + 1, 2*z^2 + z + 4, 3*z^2]
<class 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement'>
0
sage: foo()
[z, 2*z + 2, 2*z^2 + 4*z + 2, 3, 3*z^2 + 4*z + 4, z^2 + z, 2*z^2 + 3*z, z + 1, 2*z + 4, 3*z^2 + z + 1, 4*z^2 + z + 1]
<class 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement'>
0

Environment

Checklist

user202729 commented 2 weeks ago

ping @xcaruso , as the author of 43f07029f1bb97a8210557e0a206ebddefb535ab