Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit e2efadf

Browse files
committed
31558: choose coerce embedding for the base when it exists
1 parent 2c25f07 commit e2efadf

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/sage/rings/number_field/homset.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,33 @@ def default_base_hom(self):
432432
From: Number Field in b with defining polynomial x^2 + 23
433433
To: Number Field in c with defining polynomial x^4 + 80*x^2 + 36
434434
Defn: b |--> 1/12*c^3 + 43/6*c
435+
436+
TESTS:
437+
438+
Check that :trac:`30518` is fixed::
439+
440+
sage: K.<i> = QuadraticField(-1, embedding=QQbar.gen())
441+
sage: L.<a> = K.extension(x^2 - 6*x - 4)
442+
sage: a0, a1 = a.galois_conjugates(QQbar)
443+
sage: f0 = hom(L, QQbar, a0)
444+
sage: assert f0(i) == QQbar.gen()
445+
sage: f1 = hom(L, QQbar, a1)
446+
sage: assert f1(i) == QQbar.gen()
447+
448+
sage: K.<i> = QuadraticField(-1, embedding=-QQbar.gen())
449+
sage: L.<a> = K.extension(x^2 - 6*x - 4)
450+
sage: a0, a1 = a.galois_conjugates(QQbar)
451+
sage: f0 = hom(L, QQbar, a0)
452+
sage: assert f0(i) == -QQbar.gen()
453+
sage: f1 = hom(L, QQbar, a1)
454+
sage: assert f1(i) == -QQbar.gen()
435455
"""
436-
v = self.domain().base_field().embeddings(self.codomain())
456+
K = self.domain().base_field()
457+
C = self.codomain()
458+
f = C.coerce_map_from(K)
459+
if f is not None:
460+
return f
461+
v = K.embeddings(C)
437462
if len(v) == 0:
438463
raise ValueError("no way to map base field to codomain.")
439464
return v[0]

0 commit comments

Comments
 (0)