Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random doctest error in DrinfeldModuleMorphism #38953

Open
2 tasks done
dcoudert opened this issue Nov 10, 2024 · 1 comment · May be fixed by #38964
Open
2 tasks done

random doctest error in DrinfeldModuleMorphism #38953

dcoudert opened this issue Nov 10, 2024 · 1 comment · May be fixed by #38964
Labels

Comments

@dcoudert
Copy link
Contributor

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

  • OS: macOS 14.7.1 and Fedora 39
  • Sage Version: 10.5.beta9

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@user202729
Copy link
Contributor

ping @xcaruso , as the author of 43f0702

vbraun pushed a commit to vbraun/sage that referenced this issue Nov 14, 2024
….hom` and avoid inversion of zero endomorphism

    
This PR fixes sagemath#38953 and is inspired by the error raised in the issue:
- The main fix is to avoid sampling the zero element of the base field
in the test of `__invert__`, so that `phi.hom(a)` actually returns an
invertible morphism.
- However, the error raised in the issue named above was slightly
confusing, as the call of `phi.hom(K.zero())` does not return any
homomorphism: Since the codomain is not specified, it tries to find a
codomain via the `.velu`-method, but this only works if the given
element defines an isogeny, which `K.zero()` does not. Instead of
raising an error for this special case in `.hom`, it seems more robust
to default to the zero endomorphism of `self` instead.
- Also added the mention of `isog` in the `.velu`-method.
    
URL: sagemath#38964
Reported by: Sebastian A. Spindler
Reviewer(s): Xavier Caruso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants