From ac1d86163e41bd36d43011edcf92d73d2c20c520 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:23:37 +0700 Subject: [PATCH 1/2] Mark test in qqbar.py as random to avoid test failure --- src/sage/rings/qqbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index 3806663eaf0..4c7397ce7e4 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -2711,7 +2711,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, -1 sage: nfI^2 -1 - sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum + sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum # random a^5 + a^4 - a^3 + 2*a^2 - a - 1 sage: hom(sum) 2.646264369941973? + 1.866025403784439?*I From 8f584400693927a490775593e40922fba988650c Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Wed, 18 Dec 2024 18:39:04 +0700 Subject: [PATCH 2/2] Make a few more tests deterministic --- src/sage/rings/number_field/number_field.py | 62 ++++++++++++--------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 2559771ae62..59653381572 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -8662,7 +8662,7 @@ def optimized_subfields(self, degree=0, name=None, both_maps=True): polynomials are supported (:issue:`252`):: sage: K. = NumberField(2*x^4 + 6*x^2 + 1/2) - sage: K.optimized_subfields() + sage: K.optimized_subfields() # random [ (Number Field in a0 with defining polynomial x, Ring morphism: From: Number Field in a0 with defining polynomial x @@ -8774,32 +8774,40 @@ def subfields(self, degree=0, name=None): polynomials are supported (:issue:`252`):: sage: K. = NumberField(2*x^4 + 6*x^2 + 1/2) - sage: K.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, Ring morphism: - From: Number Field in a1 with defining polynomial x^2 - 2 - To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2 - Defn: a1 |--> a^2 + 3/2, None), - (Number Field in a2 with defining polynomial x^2 + 4, Ring morphism: - From: Number Field in a2 with defining polynomial x^2 + 4 - To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2 - Defn: a2 |--> 2*a^3 + 7*a, 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 |--> 2*a^3 + 5*a, None), - (Number Field in a4 with defining polynomial x^4 + 1, Ring morphism: - From: Number Field in a4 with defining polynomial x^4 + 1 - To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2 - Defn: a4 |--> 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 a4 with defining polynomial x^4 + 1 - Defn: a |--> -1/2*a4^3 + a4^2 - 1/2*a4) - ] + sage: sorted(K.subfields(), key=lambda x: x[0].discriminant()) + [(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 |--> 2*a^3 + 5*a, + None), + (Number Field in a2 with defining polynomial x^2 + 4, + Ring morphism: + From: Number Field in a2 with defining polynomial x^2 + 4 + To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2 + Defn: a2 |--> 2*a^3 + 7*a, + None), + (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, + Ring morphism: + From: Number Field in a1 with defining polynomial x^2 - 2 + To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2 + Defn: a1 |--> a^2 + 3/2, + None), + (Number Field in a4 with defining polynomial x^4 + 1, + Ring morphism: + From: Number Field in a4 with defining polynomial x^4 + 1 + To: Number Field in a with defining polynomial 2*x^4 + 6*x^2 + 1/2 + Defn: a4 |--> 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 a4 with defining polynomial x^4 + 1 + Defn: a |--> -1/2*a4^3 + a4^2 - 1/2*a4)] """ return self._subfields_helper(degree=degree, name=name, both_maps=True, optimize=False)