Skip to content

Commit 30c3116

Browse files
author
Release Manager
committed
sagemathgh-39153: Mark several tests as random to avoid test failure 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
2 parents 51e04e1 + 7e0ebbe commit 30c3116

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/sage/rings/number_field/number_field.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8656,7 +8656,7 @@ def optimized_subfields(self, degree=0, name=None, both_maps=True):
86568656
polynomials are supported (:issue:`252`)::
86578657
86588658
sage: K.<a> = NumberField(2*x^4 + 6*x^2 + 1/2)
8659-
sage: K.optimized_subfields()
8659+
sage: K.optimized_subfields() # random
86608660
[(Number Field in a0 with defining polynomial x,
86618661
Ring morphism:
86628662
From: Number Field in a0 with defining polynomial x
@@ -8780,30 +8780,30 @@ def subfields(self, degree=0, name=None):
87808780
polynomials are supported (:issue:`252`)::
87818781
87828782
sage: K.<a> = NumberField(2*x^4 + 6*x^2 + 1/2)
8783-
sage: K.subfields()
8784-
[(Number Field in a0 with defining polynomial x,
8783+
sage: sorted(K.subfields(), key=lambda x: x[0].discriminant())
8784+
[(Number Field in a3 with defining polynomial x^2 + 2,
87858785
Ring morphism:
8786-
From: Number Field in a0 with defining polynomial x
8787-
To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
8788-
Defn: 0 |--> 0,
8789-
None),
8790-
(Number Field in a1 with defining polynomial x^2 - 2,
8791-
Ring morphism:
8792-
From: Number Field in a1 with defining polynomial x^2 - 2
8786+
From: Number Field in a3 with defining polynomial x^2 + 2
87938787
To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
8794-
Defn: a1 |--> a^2 + 3/2,
8788+
Defn: a3 |--> 2*a^3 + 5*a,
87958789
None),
87968790
(Number Field in a2 with defining polynomial x^2 + 4,
87978791
Ring morphism:
87988792
From: Number Field in a2 with defining polynomial x^2 + 4
87998793
To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
88008794
Defn: a2 |--> 2*a^3 + 7*a,
88018795
None),
8802-
(Number Field in a3 with defining polynomial x^2 + 2,
8796+
(Number Field in a0 with defining polynomial x,
88038797
Ring morphism:
8804-
From: Number Field in a3 with defining polynomial x^2 + 2
8798+
From: Number Field in a0 with defining polynomial x
88058799
To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
8806-
Defn: a3 |--> 2*a^3 + 5*a,
8800+
Defn: 0 |--> 0,
8801+
None),
8802+
(Number Field in a1 with defining polynomial x^2 - 2,
8803+
Ring morphism:
8804+
From: Number Field in a1 with defining polynomial x^2 - 2
8805+
To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2
8806+
Defn: a1 |--> a^2 + 3/2,
88078807
None),
88088808
(Number Field in a4 with defining polynomial x^4 + 1,
88098809
Ring morphism:

src/sage/rings/qqbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2711,7 +2711,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False,
27112711
-1
27122712
sage: nfI^2
27132713
-1
2714-
sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
2714+
sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum # random
27152715
a^5 + a^4 - a^3 + 2*a^2 - a - 1
27162716
sage: hom(sum)
27172717
2.646264369941973? + 1.866025403784439?*I

0 commit comments

Comments
 (0)