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

Mark several tests as random to avoid test failure #39153

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

user202729
Copy link
Contributor

@user202729 user202729 commented Dec 18, 2024

This fails sometimes in e.g. https://github.com/sagemath/sage/actions/runs/12388661556/job/34580166155?pr=39152#step:10:9714

Marking this as random looks reasonable because one of the test above (specifying the exact embedding) is also marked as random, and if the embedding is random then of course the element representation in terms of the generator a should also be random.

More context:


Should the entry in /.github/workflows/ci-conda-known-test-failures.json be removed?

    "sage.rings.qqbar": {
        "failed": "unreported failure on macOS seen in https://github.com/sagemath/sage/actions/runs/9525536510/job/26259809272?pr=37998"
    },

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies


Other failing tests:

TESTS:

Number fields defined by non-monic and non-integral
polynomials are supported (:issue:`252`)::

    sage: K.<a> = NumberField(2*x^4 + 6*x^2 + 1/2)
    sage: K.optimized_subfields()
    [
    (Number Field in a0 with defining polynomial x, Ring morphism:
      From: Number Field in a0 with defining polynomial x
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
      Defn: 0 |--> 0, None),
    (Number Field in a1 with defining polynomial x^2 - 2*x + 2, Ring morphism:
      From: Number Field in a1 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
      Defn: a1 |--> a^3 + 7/2*a + 1, None),
    (Number Field in a2 with defining polynomial x^2 - 2*x + 2, Ring morphism:
      From: Number Field in a2 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
      Defn: a2 |--> -a^3 - 7/2*a + 1, None),
    (Number Field in a3 with defining polynomial x^2 - 2, Ring morphism:
      From: Number Field in a3 with defining polynomial x^2 - 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
      Defn: a3 |--> a^2 + 3/2, None),
    (Number Field in a4 with defining polynomial x^2 + 1, Ring morphism:
      From: Number Field in a4 with defining polynomial x^2 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
      Defn: a4 |--> a^3 + 7/2*a, None),
    (Number Field in a5 with defining polynomial x^2 + 2, Ring morphism:
      From: Number Field in a5 with defining polynomial x^2 + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
      Defn: a5 |--> 2*a^3 + 5*a, None),
    (Number Field in a6 with defining polynomial x^4 + 1, Ring morphism:
      From: Number Field in a6 with defining polynomial x^4 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
      Defn: a6 |--> a^3 + 1/2*a^2 + 5/2*a + 3/4, Ring morphism:
      From: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
      To:   Number Field in a6 with defining polynomial x^4 + 1
      Defn: a |--> -1/2*a6^3 + a6^2 - 1/2*a6)
    ]

I look into what determines the ordering.
It uses _subfields_helper which uses either f.polred(2) or f.nfsubfields(degree),
and there's no sorting going on.

Conclusion: marking as random sort order is fine. In fact it doesn't even say which subfields
should be returned exactly, and other tests in that function are marked as # random anyway,
so marking as # random is fine.


2024-12-18T08:35:49.0399180Z File "src/sage/rings/number_field/number_field.py", line 8777, in sage.rings.number_field.number_field.NumberField_absolute.subfields
2024-12-18T08:35:49.0500510Z Failed example:
2024-12-18T08:35:49.0601390Z     K.subfields()
2024-12-18T08:35:49.0707380Z Expected:
2024-12-18T08:35:49.0829700Z     [
2024-12-18T08:35:49.1013090Z     (Number Field in a0 with defining polynomial x, Ring morphism:
2024-12-18T08:35:49.1114120Z       From: Number Field in a0 with defining polynomial x
2024-12-18T08:35:49.1215190Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1319910Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.1426370Z     (Number Field in a1 with defining polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.1528730Z       From: Number Field in a1 with defining polynomial x^2 - 2
2024-12-18T08:35:49.1631010Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1659980Z       Defn: a1 |--> a^2 + 3/2, None),
2024-12-18T08:35:49.1761220Z     (Number Field in a2 with defining polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.1862420Z       From: Number Field in a2 with defining polynomial x^2 + 4
2024-12-18T08:35:49.1970640Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2072220Z       Defn: a2 |--> 2*a^3 + 7*a, None),
2024-12-18T08:35:49.2173950Z     (Number Field in a3 with defining polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.2275370Z       From: Number Field in a3 with defining polynomial x^2 + 2
2024-12-18T08:35:49.2368240Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2476650Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.2570570Z     (Number Field in a4 with defining polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.2672100Z       From: Number Field in a4 with defining polynomial x^4 + 1
2024-12-18T08:35:49.2774030Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2875400Z       Defn: a4 |--> a^3 + 1/2*a^2 + 5/2*a + 3/4, Ring morphism:
2024-12-18T08:35:49.2977450Z       From: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3080080Z       To:   Number Field in a4 with defining polynomial x^4 + 1
2024-12-18T08:35:49.3179890Z       Defn: a |--> -1/2*a4^3 + a4^2 - 1/2*a4)
2024-12-18T08:35:49.3281410Z     ]
2024-12-18T08:35:49.3382370Z Got:
2024-12-18T08:35:49.3483260Z     [
2024-12-18T08:35:49.3584610Z     (Number Field in a0 with defining polynomial x, Ring morphism:
2024-12-18T08:35:49.3643330Z       From: Number Field in a0 with defining polynomial x
2024-12-18T08:35:49.3714430Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3816090Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.3923670Z     (Number Field in a1 with defining polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.4037810Z       From: Number Field in a1 with defining polynomial x^2 - 2
2024-12-18T08:35:49.4142230Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4289560Z       Defn: a1 |--> -a^2 - 3/2, None),
2024-12-18T08:35:49.4391330Z     (Number Field in a2 with defining polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.4492300Z       From: Number Field in a2 with defining polynomial x^2 + 4
2024-12-18T08:35:49.4602960Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4705310Z       Defn: a2 |--> -2*a^3 - 7*a, None),
2024-12-18T08:35:49.4793770Z     (Number Field in a3 with defining polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.4794540Z       From: Number Field in a3 with defining polynomial x^2 + 2
2024-12-18T08:35:49.4795030Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4795830Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.4796320Z     (Number Field in a4 with defining polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.4796780Z       From: Number Field in a4 with defining polynomial x^4 + 1
2024-12-18T08:35:49.4797230Z       To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4797760Z       Defn: a4 |--> a^3 - 1/2*a^2 + 5/2*a - 3/4, Ring morphism:
2024-12-18T08:35:49.4798180Z       From: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4852940Z       To:   Number Field in a4 with defining polynomial x^4 + 1
2024-12-18T08:35:49.4987040Z       Defn: a |--> -1/2*a4^3 - a4^2 - 1/2*a4)
2024-12-18T08:35:49.5088200Z     ]

Uses https://pari.math.u-bordeaux.fr/dochtml/html/General_number_fields.html#se:nfsubfields internally. It doesn't state any resulting sort order, so I just reorder them (the discriminants are all distincts so it's fine).

Alternatively it looks like just doctest against the set() of it might work.


Copy link

github-actions bot commented Dec 18, 2024

Documentation preview for this PR (built with commit 7e0ebbe; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@user202729 user202729 changed the title Mark test in qqbar.py as random to avoid test failure Mark several tests as random to avoid test failure Dec 18, 2024
Copy link
Contributor

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 23, 2024
    
This fails sometimes in e.g. https://github.com/sagemath/sage/actions/ru
ns/12388661556/job/34580166155?pr=39152#step:10:9714

Marking this as random looks reasonable because one of the test above
(specifying the exact embedding) is also marked as random, and if the
embedding is random then of course the element representation in terms
of the generator `a` should also be random.


More context:

* the first `# random` is added first in https://github.com/sagemath/sag
e/commit/37fc8e88689a0197c5513161b85b8bbadd5630ab#diff-
c63508ebde0716605e6cdac05e43c8945616c2245158d30ff5ae39936ff4d9a0R1892
* then the note that `number_field_elements_from_algebraics` is OS-
dependent ("32 versus 64 bit") is removed at https://github.com/sagemath
/sage/commit/61e4df9fabf9e06a21d75eb6320ab3179bc28096 for reasons I
can't figure out. (how to find out the discussion around a commit? it
was before trac to GitHub migration)

------

Should the entry in `/.github/workflows/ci-conda-known-test-
failures.json` be removed?

```
    "sage.rings.qqbar": {
        "failed": "unreported failure on macOS seen in https://github.co
m/sagemath/sage/actions/runs/9525536510/job/26259809272?pr=37998"
    },
```

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->


------


Other failing tests:

```
TESTS:

Number fields defined by non-monic and non-integral
polynomials are supported (:issue:`252`)::

    sage: K.<a> = NumberField(2*x^4 + 6*x^2 + 1/2)
    sage: K.optimized_subfields()
    [
    (Number Field in a0 with defining polynomial x, Ring morphism:
      From: Number Field in a0 with defining polynomial x
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: 0 |--> 0, None),
    (Number Field in a1 with defining polynomial x^2 - 2*x + 2, Ring
morphism:
      From: Number Field in a1 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a1 |--> a^3 + 7/2*a + 1, None),
    (Number Field in a2 with defining polynomial x^2 - 2*x + 2, Ring
morphism:
      From: Number Field in a2 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a2 |--> -a^3 - 7/2*a + 1, None),
    (Number Field in a3 with defining polynomial x^2 - 2, Ring morphism:
      From: Number Field in a3 with defining polynomial x^2 - 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a3 |--> a^2 + 3/2, None),
    (Number Field in a4 with defining polynomial x^2 + 1, Ring morphism:
      From: Number Field in a4 with defining polynomial x^2 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a4 |--> a^3 + 7/2*a, None),
    (Number Field in a5 with defining polynomial x^2 + 2, Ring morphism:
      From: Number Field in a5 with defining polynomial x^2 + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a5 |--> 2*a^3 + 5*a, None),
    (Number Field in a6 with defining polynomial x^4 + 1, Ring morphism:
      From: Number Field in a6 with defining polynomial x^4 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a6 |--> a^3 + 1/2*a^2 + 5/2*a + 3/4, Ring morphism:
      From: Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      To:   Number Field in a6 with defining polynomial x^4 + 1
      Defn: a |--> -1/2*a6^3 + a6^2 - 1/2*a6)
    ]
```

I look into what determines the ordering.
It uses `_subfields_helper` which uses either `f.polred(2)` or
`f.nfsubfields(degree)`,
and there's no sorting going on.

Conclusion: marking as `random sort order` is fine. In fact it doesn't
even say which subfields
should be returned exactly, and other tests in that function are marked
as `# random` anyway,
so marking as `# random` is fine.

------

```
2024-12-18T08:35:49.0399180Z File
"src/sage/rings/number_field/number_field.py", line 8777, in
sage.rings.number_field.number_field.NumberField_absolute.subfields
2024-12-18T08:35:49.0500510Z Failed example:
2024-12-18T08:35:49.0601390Z     K.subfields()
2024-12-18T08:35:49.0707380Z Expected:
2024-12-18T08:35:49.0829700Z     [
2024-12-18T08:35:49.1013090Z     (Number Field in a0 with defining
polynomial x, Ring morphism:
2024-12-18T08:35:49.1114120Z       From: Number Field in a0 with
defining polynomial x
2024-12-18T08:35:49.1215190Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1319910Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.1426370Z     (Number Field in a1 with defining
polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.1528730Z       From: Number Field in a1 with
defining polynomial x^2 - 2
2024-12-18T08:35:49.1631010Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1659980Z       Defn: a1 |--> a^2 + 3/2, None),
2024-12-18T08:35:49.1761220Z     (Number Field in a2 with defining
polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.1862420Z       From: Number Field in a2 with
defining polynomial x^2 + 4
2024-12-18T08:35:49.1970640Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2072220Z       Defn: a2 |--> 2*a^3 + 7*a, None),
2024-12-18T08:35:49.2173950Z     (Number Field in a3 with defining
polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.2275370Z       From: Number Field in a3 with
defining polynomial x^2 + 2
2024-12-18T08:35:49.2368240Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2476650Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.2570570Z     (Number Field in a4 with defining
polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.2672100Z       From: Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.2774030Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2875400Z       Defn: a4 |--> a^3 + 1/2*a^2 + 5/2*a +
3/4, Ring morphism:
2024-12-18T08:35:49.2977450Z       From: Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3080080Z       To:   Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.3179890Z       Defn: a |--> -1/2*a4^3 + a4^2 -
1/2*a4)
2024-12-18T08:35:49.3281410Z     ]
2024-12-18T08:35:49.3382370Z Got:
2024-12-18T08:35:49.3483260Z     [
2024-12-18T08:35:49.3584610Z     (Number Field in a0 with defining
polynomial x, Ring morphism:
2024-12-18T08:35:49.3643330Z       From: Number Field in a0 with
defining polynomial x
2024-12-18T08:35:49.3714430Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3816090Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.3923670Z     (Number Field in a1 with defining
polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.4037810Z       From: Number Field in a1 with
defining polynomial x^2 - 2
2024-12-18T08:35:49.4142230Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4289560Z       Defn: a1 |--> -a^2 - 3/2, None),
2024-12-18T08:35:49.4391330Z     (Number Field in a2 with defining
polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.4492300Z       From: Number Field in a2 with
defining polynomial x^2 + 4
2024-12-18T08:35:49.4602960Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4705310Z       Defn: a2 |--> -2*a^3 - 7*a, None),
2024-12-18T08:35:49.4793770Z     (Number Field in a3 with defining
polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.4794540Z       From: Number Field in a3 with
defining polynomial x^2 + 2
2024-12-18T08:35:49.4795030Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4795830Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.4796320Z     (Number Field in a4 with defining
polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.4796780Z       From: Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.4797230Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4797760Z       Defn: a4 |--> a^3 - 1/2*a^2 + 5/2*a -
3/4, Ring morphism:
2024-12-18T08:35:49.4798180Z       From: Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4852940Z       To:   Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.4987040Z       Defn: a |--> -1/2*a4^3 - a4^2 -
1/2*a4)
2024-12-18T08:35:49.5088200Z     ]
```

Uses https://pari.math.u-
bordeaux.fr/dochtml/html/General_number_fields.html#se:nfsubfields
internally. It doesn't state any resulting sort order, so I just reorder
them (the discriminants are all distincts so it's fine).

Alternatively it looks like just doctest against the `set()` of it might
work.

------
    
URL: sagemath#39153
Reported by: user202729
Reviewer(s): Tobias Diez
@user202729
Copy link
Contributor Author

user202729 commented Dec 23, 2024

Apparently merge upstream from git makes the bot reset the label to [needs review]… can you change back the label? Thanks.

@tobiasdiez
Copy link
Contributor

Done!
You can ask to join https://github.com/orgs/sagemath/teams/triage, then you can change the labels in the future yourself.

@user202729
Copy link
Contributor Author

Merge conflict with #39027 prevents this one from being merged from 10.6.beta3 . Fixed now.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 7, 2025
    
This fails sometimes in e.g. https://github.com/sagemath/sage/actions/ru
ns/12388661556/job/34580166155?pr=39152#step:10:9714

Marking this as random looks reasonable because one of the test above
(specifying the exact embedding) is also marked as random, and if the
embedding is random then of course the element representation in terms
of the generator `a` should also be random.


More context:

* the first `# random` is added first in https://github.com/sagemath/sag
e/commit/37fc8e88689a0197c5513161b85b8bbadd5630ab#diff-
c63508ebde0716605e6cdac05e43c8945616c2245158d30ff5ae39936ff4d9a0R1892
* then the note that `number_field_elements_from_algebraics` is OS-
dependent ("32 versus 64 bit") is removed at https://github.com/sagemath
/sage/commit/61e4df9fabf9e06a21d75eb6320ab3179bc28096 for reasons I
can't figure out. (how to find out the discussion around a commit? it
was before trac to GitHub migration)

------

Should the entry in `/.github/workflows/ci-conda-known-test-
failures.json` be removed?

```
    "sage.rings.qqbar": {
        "failed": "unreported failure on macOS seen in https://github.co
m/sagemath/sage/actions/runs/9525536510/job/26259809272?pr=37998"
    },
```

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->


------


Other failing tests:

```
TESTS:

Number fields defined by non-monic and non-integral
polynomials are supported (:issue:`252`)::

    sage: K.<a> = NumberField(2*x^4 + 6*x^2 + 1/2)
    sage: K.optimized_subfields()
    [
    (Number Field in a0 with defining polynomial x, Ring morphism:
      From: Number Field in a0 with defining polynomial x
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: 0 |--> 0, None),
    (Number Field in a1 with defining polynomial x^2 - 2*x + 2, Ring
morphism:
      From: Number Field in a1 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a1 |--> a^3 + 7/2*a + 1, None),
    (Number Field in a2 with defining polynomial x^2 - 2*x + 2, Ring
morphism:
      From: Number Field in a2 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a2 |--> -a^3 - 7/2*a + 1, None),
    (Number Field in a3 with defining polynomial x^2 - 2, Ring morphism:
      From: Number Field in a3 with defining polynomial x^2 - 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a3 |--> a^2 + 3/2, None),
    (Number Field in a4 with defining polynomial x^2 + 1, Ring morphism:
      From: Number Field in a4 with defining polynomial x^2 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a4 |--> a^3 + 7/2*a, None),
    (Number Field in a5 with defining polynomial x^2 + 2, Ring morphism:
      From: Number Field in a5 with defining polynomial x^2 + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a5 |--> 2*a^3 + 5*a, None),
    (Number Field in a6 with defining polynomial x^4 + 1, Ring morphism:
      From: Number Field in a6 with defining polynomial x^4 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a6 |--> a^3 + 1/2*a^2 + 5/2*a + 3/4, Ring morphism:
      From: Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      To:   Number Field in a6 with defining polynomial x^4 + 1
      Defn: a |--> -1/2*a6^3 + a6^2 - 1/2*a6)
    ]
```

I look into what determines the ordering.
It uses `_subfields_helper` which uses either `f.polred(2)` or
`f.nfsubfields(degree)`,
and there's no sorting going on.

Conclusion: marking as `random sort order` is fine. In fact it doesn't
even say which subfields
should be returned exactly, and other tests in that function are marked
as `# random` anyway,
so marking as `# random` is fine.

------

```
2024-12-18T08:35:49.0399180Z File
"src/sage/rings/number_field/number_field.py", line 8777, in
sage.rings.number_field.number_field.NumberField_absolute.subfields
2024-12-18T08:35:49.0500510Z Failed example:
2024-12-18T08:35:49.0601390Z     K.subfields()
2024-12-18T08:35:49.0707380Z Expected:
2024-12-18T08:35:49.0829700Z     [
2024-12-18T08:35:49.1013090Z     (Number Field in a0 with defining
polynomial x, Ring morphism:
2024-12-18T08:35:49.1114120Z       From: Number Field in a0 with
defining polynomial x
2024-12-18T08:35:49.1215190Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1319910Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.1426370Z     (Number Field in a1 with defining
polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.1528730Z       From: Number Field in a1 with
defining polynomial x^2 - 2
2024-12-18T08:35:49.1631010Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1659980Z       Defn: a1 |--> a^2 + 3/2, None),
2024-12-18T08:35:49.1761220Z     (Number Field in a2 with defining
polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.1862420Z       From: Number Field in a2 with
defining polynomial x^2 + 4
2024-12-18T08:35:49.1970640Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2072220Z       Defn: a2 |--> 2*a^3 + 7*a, None),
2024-12-18T08:35:49.2173950Z     (Number Field in a3 with defining
polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.2275370Z       From: Number Field in a3 with
defining polynomial x^2 + 2
2024-12-18T08:35:49.2368240Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2476650Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.2570570Z     (Number Field in a4 with defining
polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.2672100Z       From: Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.2774030Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2875400Z       Defn: a4 |--> a^3 + 1/2*a^2 + 5/2*a +
3/4, Ring morphism:
2024-12-18T08:35:49.2977450Z       From: Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3080080Z       To:   Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.3179890Z       Defn: a |--> -1/2*a4^3 + a4^2 -
1/2*a4)
2024-12-18T08:35:49.3281410Z     ]
2024-12-18T08:35:49.3382370Z Got:
2024-12-18T08:35:49.3483260Z     [
2024-12-18T08:35:49.3584610Z     (Number Field in a0 with defining
polynomial x, Ring morphism:
2024-12-18T08:35:49.3643330Z       From: Number Field in a0 with
defining polynomial x
2024-12-18T08:35:49.3714430Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3816090Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.3923670Z     (Number Field in a1 with defining
polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.4037810Z       From: Number Field in a1 with
defining polynomial x^2 - 2
2024-12-18T08:35:49.4142230Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4289560Z       Defn: a1 |--> -a^2 - 3/2, None),
2024-12-18T08:35:49.4391330Z     (Number Field in a2 with defining
polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.4492300Z       From: Number Field in a2 with
defining polynomial x^2 + 4
2024-12-18T08:35:49.4602960Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4705310Z       Defn: a2 |--> -2*a^3 - 7*a, None),
2024-12-18T08:35:49.4793770Z     (Number Field in a3 with defining
polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.4794540Z       From: Number Field in a3 with
defining polynomial x^2 + 2
2024-12-18T08:35:49.4795030Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4795830Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.4796320Z     (Number Field in a4 with defining
polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.4796780Z       From: Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.4797230Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4797760Z       Defn: a4 |--> a^3 - 1/2*a^2 + 5/2*a -
3/4, Ring morphism:
2024-12-18T08:35:49.4798180Z       From: Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4852940Z       To:   Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.4987040Z       Defn: a |--> -1/2*a4^3 - a4^2 -
1/2*a4)
2024-12-18T08:35:49.5088200Z     ]
```

Uses https://pari.math.u-
bordeaux.fr/dochtml/html/General_number_fields.html#se:nfsubfields
internally. It doesn't state any resulting sort order, so I just reorder
them (the discriminants are all distincts so it's fine).

Alternatively it looks like just doctest against the `set()` of it might
work.

------
    
URL: sagemath#39153
Reported by: user202729
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 9, 2025
    
This fails sometimes in e.g. https://github.com/sagemath/sage/actions/ru
ns/12388661556/job/34580166155?pr=39152#step:10:9714

Marking this as random looks reasonable because one of the test above
(specifying the exact embedding) is also marked as random, and if the
embedding is random then of course the element representation in terms
of the generator `a` should also be random.


More context:

* the first `# random` is added first in https://github.com/sagemath/sag
e/commit/37fc8e88689a0197c5513161b85b8bbadd5630ab#diff-
c63508ebde0716605e6cdac05e43c8945616c2245158d30ff5ae39936ff4d9a0R1892
* then the note that `number_field_elements_from_algebraics` is OS-
dependent ("32 versus 64 bit") is removed at https://github.com/sagemath
/sage/commit/61e4df9fabf9e06a21d75eb6320ab3179bc28096 for reasons I
can't figure out. (how to find out the discussion around a commit? it
was before trac to GitHub migration)

------

Should the entry in `/.github/workflows/ci-conda-known-test-
failures.json` be removed?

```
    "sage.rings.qqbar": {
        "failed": "unreported failure on macOS seen in https://github.co
m/sagemath/sage/actions/runs/9525536510/job/26259809272?pr=37998"
    },
```

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->


------


Other failing tests:

```
TESTS:

Number fields defined by non-monic and non-integral
polynomials are supported (:issue:`252`)::

    sage: K.<a> = NumberField(2*x^4 + 6*x^2 + 1/2)
    sage: K.optimized_subfields()
    [
    (Number Field in a0 with defining polynomial x, Ring morphism:
      From: Number Field in a0 with defining polynomial x
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: 0 |--> 0, None),
    (Number Field in a1 with defining polynomial x^2 - 2*x + 2, Ring
morphism:
      From: Number Field in a1 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a1 |--> a^3 + 7/2*a + 1, None),
    (Number Field in a2 with defining polynomial x^2 - 2*x + 2, Ring
morphism:
      From: Number Field in a2 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a2 |--> -a^3 - 7/2*a + 1, None),
    (Number Field in a3 with defining polynomial x^2 - 2, Ring morphism:
      From: Number Field in a3 with defining polynomial x^2 - 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a3 |--> a^2 + 3/2, None),
    (Number Field in a4 with defining polynomial x^2 + 1, Ring morphism:
      From: Number Field in a4 with defining polynomial x^2 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a4 |--> a^3 + 7/2*a, None),
    (Number Field in a5 with defining polynomial x^2 + 2, Ring morphism:
      From: Number Field in a5 with defining polynomial x^2 + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a5 |--> 2*a^3 + 5*a, None),
    (Number Field in a6 with defining polynomial x^4 + 1, Ring morphism:
      From: Number Field in a6 with defining polynomial x^4 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a6 |--> a^3 + 1/2*a^2 + 5/2*a + 3/4, Ring morphism:
      From: Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      To:   Number Field in a6 with defining polynomial x^4 + 1
      Defn: a |--> -1/2*a6^3 + a6^2 - 1/2*a6)
    ]
```

I look into what determines the ordering.
It uses `_subfields_helper` which uses either `f.polred(2)` or
`f.nfsubfields(degree)`,
and there's no sorting going on.

Conclusion: marking as `random sort order` is fine. In fact it doesn't
even say which subfields
should be returned exactly, and other tests in that function are marked
as `# random` anyway,
so marking as `# random` is fine.

------

```
2024-12-18T08:35:49.0399180Z File
"src/sage/rings/number_field/number_field.py", line 8777, in
sage.rings.number_field.number_field.NumberField_absolute.subfields
2024-12-18T08:35:49.0500510Z Failed example:
2024-12-18T08:35:49.0601390Z     K.subfields()
2024-12-18T08:35:49.0707380Z Expected:
2024-12-18T08:35:49.0829700Z     [
2024-12-18T08:35:49.1013090Z     (Number Field in a0 with defining
polynomial x, Ring morphism:
2024-12-18T08:35:49.1114120Z       From: Number Field in a0 with
defining polynomial x
2024-12-18T08:35:49.1215190Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1319910Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.1426370Z     (Number Field in a1 with defining
polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.1528730Z       From: Number Field in a1 with
defining polynomial x^2 - 2
2024-12-18T08:35:49.1631010Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1659980Z       Defn: a1 |--> a^2 + 3/2, None),
2024-12-18T08:35:49.1761220Z     (Number Field in a2 with defining
polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.1862420Z       From: Number Field in a2 with
defining polynomial x^2 + 4
2024-12-18T08:35:49.1970640Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2072220Z       Defn: a2 |--> 2*a^3 + 7*a, None),
2024-12-18T08:35:49.2173950Z     (Number Field in a3 with defining
polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.2275370Z       From: Number Field in a3 with
defining polynomial x^2 + 2
2024-12-18T08:35:49.2368240Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2476650Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.2570570Z     (Number Field in a4 with defining
polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.2672100Z       From: Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.2774030Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2875400Z       Defn: a4 |--> a^3 + 1/2*a^2 + 5/2*a +
3/4, Ring morphism:
2024-12-18T08:35:49.2977450Z       From: Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3080080Z       To:   Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.3179890Z       Defn: a |--> -1/2*a4^3 + a4^2 -
1/2*a4)
2024-12-18T08:35:49.3281410Z     ]
2024-12-18T08:35:49.3382370Z Got:
2024-12-18T08:35:49.3483260Z     [
2024-12-18T08:35:49.3584610Z     (Number Field in a0 with defining
polynomial x, Ring morphism:
2024-12-18T08:35:49.3643330Z       From: Number Field in a0 with
defining polynomial x
2024-12-18T08:35:49.3714430Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3816090Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.3923670Z     (Number Field in a1 with defining
polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.4037810Z       From: Number Field in a1 with
defining polynomial x^2 - 2
2024-12-18T08:35:49.4142230Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4289560Z       Defn: a1 |--> -a^2 - 3/2, None),
2024-12-18T08:35:49.4391330Z     (Number Field in a2 with defining
polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.4492300Z       From: Number Field in a2 with
defining polynomial x^2 + 4
2024-12-18T08:35:49.4602960Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4705310Z       Defn: a2 |--> -2*a^3 - 7*a, None),
2024-12-18T08:35:49.4793770Z     (Number Field in a3 with defining
polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.4794540Z       From: Number Field in a3 with
defining polynomial x^2 + 2
2024-12-18T08:35:49.4795030Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4795830Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.4796320Z     (Number Field in a4 with defining
polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.4796780Z       From: Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.4797230Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4797760Z       Defn: a4 |--> a^3 - 1/2*a^2 + 5/2*a -
3/4, Ring morphism:
2024-12-18T08:35:49.4798180Z       From: Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4852940Z       To:   Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.4987040Z       Defn: a |--> -1/2*a4^3 - a4^2 -
1/2*a4)
2024-12-18T08:35:49.5088200Z     ]
```

Uses https://pari.math.u-
bordeaux.fr/dochtml/html/General_number_fields.html#se:nfsubfields
internally. It doesn't state any resulting sort order, so I just reorder
them (the discriminants are all distincts so it's fine).

Alternatively it looks like just doctest against the `set()` of it might
work.

------
    
URL: sagemath#39153
Reported by: user202729
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 10, 2025
    
This fails sometimes in e.g. https://github.com/sagemath/sage/actions/ru
ns/12388661556/job/34580166155?pr=39152#step:10:9714

Marking this as random looks reasonable because one of the test above
(specifying the exact embedding) is also marked as random, and if the
embedding is random then of course the element representation in terms
of the generator `a` should also be random.


More context:

* the first `# random` is added first in https://github.com/sagemath/sag
e/commit/37fc8e88689a0197c5513161b85b8bbadd5630ab#diff-
c63508ebde0716605e6cdac05e43c8945616c2245158d30ff5ae39936ff4d9a0R1892
* then the note that `number_field_elements_from_algebraics` is OS-
dependent ("32 versus 64 bit") is removed at https://github.com/sagemath
/sage/commit/61e4df9fabf9e06a21d75eb6320ab3179bc28096 for reasons I
can't figure out. (how to find out the discussion around a commit? it
was before trac to GitHub migration)

------

Should the entry in `/.github/workflows/ci-conda-known-test-
failures.json` be removed?

```
    "sage.rings.qqbar": {
        "failed": "unreported failure on macOS seen in https://github.co
m/sagemath/sage/actions/runs/9525536510/job/26259809272?pr=37998"
    },
```

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->


------


Other failing tests:

```
TESTS:

Number fields defined by non-monic and non-integral
polynomials are supported (:issue:`252`)::

    sage: K.<a> = NumberField(2*x^4 + 6*x^2 + 1/2)
    sage: K.optimized_subfields()
    [
    (Number Field in a0 with defining polynomial x, Ring morphism:
      From: Number Field in a0 with defining polynomial x
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: 0 |--> 0, None),
    (Number Field in a1 with defining polynomial x^2 - 2*x + 2, Ring
morphism:
      From: Number Field in a1 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a1 |--> a^3 + 7/2*a + 1, None),
    (Number Field in a2 with defining polynomial x^2 - 2*x + 2, Ring
morphism:
      From: Number Field in a2 with defining polynomial x^2 - 2*x + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a2 |--> -a^3 - 7/2*a + 1, None),
    (Number Field in a3 with defining polynomial x^2 - 2, Ring morphism:
      From: Number Field in a3 with defining polynomial x^2 - 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a3 |--> a^2 + 3/2, None),
    (Number Field in a4 with defining polynomial x^2 + 1, Ring morphism:
      From: Number Field in a4 with defining polynomial x^2 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a4 |--> a^3 + 7/2*a, None),
    (Number Field in a5 with defining polynomial x^2 + 2, Ring morphism:
      From: Number Field in a5 with defining polynomial x^2 + 2
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a5 |--> 2*a^3 + 5*a, None),
    (Number Field in a6 with defining polynomial x^4 + 1, Ring morphism:
      From: Number Field in a6 with defining polynomial x^4 + 1
      To:   Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      Defn: a6 |--> a^3 + 1/2*a^2 + 5/2*a + 3/4, Ring morphism:
      From: Number Field in a with defining polynomial 2*x^4 + 6*x^2 +
1/2
      To:   Number Field in a6 with defining polynomial x^4 + 1
      Defn: a |--> -1/2*a6^3 + a6^2 - 1/2*a6)
    ]
```

I look into what determines the ordering.
It uses `_subfields_helper` which uses either `f.polred(2)` or
`f.nfsubfields(degree)`,
and there's no sorting going on.

Conclusion: marking as `random sort order` is fine. In fact it doesn't
even say which subfields
should be returned exactly, and other tests in that function are marked
as `# random` anyway,
so marking as `# random` is fine.

------

```
2024-12-18T08:35:49.0399180Z File
"src/sage/rings/number_field/number_field.py", line 8777, in
sage.rings.number_field.number_field.NumberField_absolute.subfields
2024-12-18T08:35:49.0500510Z Failed example:
2024-12-18T08:35:49.0601390Z     K.subfields()
2024-12-18T08:35:49.0707380Z Expected:
2024-12-18T08:35:49.0829700Z     [
2024-12-18T08:35:49.1013090Z     (Number Field in a0 with defining
polynomial x, Ring morphism:
2024-12-18T08:35:49.1114120Z       From: Number Field in a0 with
defining polynomial x
2024-12-18T08:35:49.1215190Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1319910Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.1426370Z     (Number Field in a1 with defining
polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.1528730Z       From: Number Field in a1 with
defining polynomial x^2 - 2
2024-12-18T08:35:49.1631010Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.1659980Z       Defn: a1 |--> a^2 + 3/2, None),
2024-12-18T08:35:49.1761220Z     (Number Field in a2 with defining
polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.1862420Z       From: Number Field in a2 with
defining polynomial x^2 + 4
2024-12-18T08:35:49.1970640Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2072220Z       Defn: a2 |--> 2*a^3 + 7*a, None),
2024-12-18T08:35:49.2173950Z     (Number Field in a3 with defining
polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.2275370Z       From: Number Field in a3 with
defining polynomial x^2 + 2
2024-12-18T08:35:49.2368240Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2476650Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.2570570Z     (Number Field in a4 with defining
polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.2672100Z       From: Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.2774030Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.2875400Z       Defn: a4 |--> a^3 + 1/2*a^2 + 5/2*a +
3/4, Ring morphism:
2024-12-18T08:35:49.2977450Z       From: Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3080080Z       To:   Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.3179890Z       Defn: a |--> -1/2*a4^3 + a4^2 -
1/2*a4)
2024-12-18T08:35:49.3281410Z     ]
2024-12-18T08:35:49.3382370Z Got:
2024-12-18T08:35:49.3483260Z     [
2024-12-18T08:35:49.3584610Z     (Number Field in a0 with defining
polynomial x, Ring morphism:
2024-12-18T08:35:49.3643330Z       From: Number Field in a0 with
defining polynomial x
2024-12-18T08:35:49.3714430Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.3816090Z       Defn: 0 |--> 0, None),
2024-12-18T08:35:49.3923670Z     (Number Field in a1 with defining
polynomial x^2 - 2, Ring morphism:
2024-12-18T08:35:49.4037810Z       From: Number Field in a1 with
defining polynomial x^2 - 2
2024-12-18T08:35:49.4142230Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4289560Z       Defn: a1 |--> -a^2 - 3/2, None),
2024-12-18T08:35:49.4391330Z     (Number Field in a2 with defining
polynomial x^2 + 4, Ring morphism:
2024-12-18T08:35:49.4492300Z       From: Number Field in a2 with
defining polynomial x^2 + 4
2024-12-18T08:35:49.4602960Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4705310Z       Defn: a2 |--> -2*a^3 - 7*a, None),
2024-12-18T08:35:49.4793770Z     (Number Field in a3 with defining
polynomial x^2 + 2, Ring morphism:
2024-12-18T08:35:49.4794540Z       From: Number Field in a3 with
defining polynomial x^2 + 2
2024-12-18T08:35:49.4795030Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4795830Z       Defn: a3 |--> 2*a^3 + 5*a, None),
2024-12-18T08:35:49.4796320Z     (Number Field in a4 with defining
polynomial x^4 + 1, Ring morphism:
2024-12-18T08:35:49.4796780Z       From: Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.4797230Z       To:   Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4797760Z       Defn: a4 |--> a^3 - 1/2*a^2 + 5/2*a -
3/4, Ring morphism:
2024-12-18T08:35:49.4798180Z       From: Number Field in a with defining
polynomial 2*x^4 + 6*x^2 + 1/2
2024-12-18T08:35:49.4852940Z       To:   Number Field in a4 with
defining polynomial x^4 + 1
2024-12-18T08:35:49.4987040Z       Defn: a |--> -1/2*a4^3 - a4^2 -
1/2*a4)
2024-12-18T08:35:49.5088200Z     ]
```

Uses https://pari.math.u-
bordeaux.fr/dochtml/html/General_number_fields.html#se:nfsubfields
internally. It doesn't state any resulting sort order, so I just reorder
them (the discriminants are all distincts so it's fine).

Alternatively it looks like just doctest against the `set()` of it might
work.

------
    
URL: sagemath#39153
Reported by: user202729
Reviewer(s): Tobias Diez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants