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 test failure in quaternion_algebra.py #37488

Closed
2 tasks done
GiacomoPope opened this issue Feb 27, 2024 · 1 comment · Fixed by #37489
Closed
2 tasks done

Random test failure in quaternion_algebra.py #37488

GiacomoPope opened this issue Feb 27, 2024 · 1 comment · Fixed by #37489

Comments

@GiacomoPope
Copy link
Contributor

Steps To Reproduce

When running the CI https://github.com/sagemath/sage/actions/runs/8063335292/job/22024916321?pr=37443 the following random test failed.

sage -t --random-seed=558346185206384723433409773377632267 src/sage/algebras/quatalg/quaternion_algebra.py
**********************************************************************
File "src/sage/algebras/quatalg/quaternion_algebra.py", line 2167, in sage.algebras.quatalg.quaternion_algebra.QuaternionOrder.isomorphism_to
Failed example:
    iso = O0.isomorphism_to(O1); iso
Expected:
    Ring morphism: ...
Got:
    Ring endomorphism of Order of Quaternion Algebra (-345, -777) with base ring Rational Field with basis (1, i, j, 1/2 + 1/2*i + 23/74*j + 1/222*k)
      Defn: i |--> i
            j |--> j
            k |--> k

Expected Behavior

The doctests should pass

Actual Behavior

The doctests fail

Additional Information

No response

Environment

- **Sage Version**: SageMath version 10.3.rc0, Release Date: 2024-02-25

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
@GiacomoPope
Copy link
Contributor Author

The issue is simply that sometimes O0 == O1 which changes the output from Morphism to Endomorphism in the __repr__ of the map. I will fix this in a PR.

vbraun pushed a commit to vbraun/sage that referenced this issue Mar 30, 2024
…nion_algebra.py`

    
The current code:

```py
sage: set_random_seed(558346185206384723433409773377632267)
sage: q = randrange(1,1000)
....: p = randrange(1,1000)
....: Quat.<i,j,k> = QuaternionAlgebra(-q, -p)
....: O0 = Quat.maximal_order()
....: while True:
....:     b = Quat.random_element()
....:     if gcd(b.reduced_norm(), Quat.discriminant()) == 1:
....:         break
....: O1 = (b * O0).left_order()
....: iso = O0.isomorphism_to(O1); iso
Ring endomorphism of Order of Quaternion Algebra (-667, -662) with base
ring Rational Field with basis (1, 1/2 + 1/2*i, j, 1/2 + 11/58*i + 1/2*j
+ 1/58*k)
  Defn: i |--> i
        j |--> j
        k |--> k
sage: O0
Order of Quaternion Algebra (-667, -662) with base ring Rational Field
with basis (1, 1/2 + 1/2*i, j, 1/2 + 11/58*i + 1/2*j + 1/58*k)
sage: O1
Order of Quaternion Algebra (-667, -662) with base ring Rational Field
with basis (1, 1/2 + 1/2*i, j, 1/2 + 11/58*i + 1/2*j + 1/58*k)
```

Causes a doctest to fail as a `Ring morphism` is expected but when `O0
== O1` then instead a `Ring endomorphism` is computed instead.

We simply truncate the expected output for the random testing from `Ring
morphism` to `Ring ...` fixing the failure.

```
sage -t --random-seed=558346185206384723433409773377632267
src/sage/algebras/quatalg/quaternion_algebra.py
    [562 tests, 17.35 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Total time for all tests: 18.7 seconds
    cpu time: 15.6 seconds
    cumulative wall time: 17.3 seconds
```

Fixes sagemath#37488
    
URL: sagemath#37489
Reported by: Giacomo Pope
Reviewer(s): Lorenz Panny
@mkoeppe mkoeppe added this to the sage-10.4 milestone Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants