From 1eff5e5c988bab27748bbd57112d0f4b76361e37 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Thu, 28 Nov 2024 15:12:29 +0700 Subject: [PATCH 1/2] Fix construct homset of elliptic curve in Sets() --- src/sage/schemes/elliptic_curves/ell_field.py | 21 ++++++++++++++----- src/sage/schemes/generic/homset.py | 19 ++++++++++++++++- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py index 4f694e0f252..f5d4d396291 100755 --- a/src/sage/schemes/elliptic_curves/ell_field.py +++ b/src/sage/schemes/elliptic_curves/ell_field.py @@ -1150,12 +1150,23 @@ def _Hom_(self, other, category=None): sage: E = EllipticCurve(GF(19), [1,0]) sage: type(E._Hom_(E)) + + TESTS:: + + sage: E.Hom(E, Sets()) + Set of Morphisms from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 19 to Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 19 in Category of sets + sage: E.Hom(E, Sets())(lambda x: x + E(3, 7))(E(4, 7)) + (12 : 12 : 1) """ - if isinstance(other, ell_generic.EllipticCurve_generic) and self.base_ring() == other.base_ring(): - from . import homset - return homset.EllipticCurveHomset(self, other, category=category) - from sage.schemes.generic.homset import SchemeHomset_generic - return SchemeHomset_generic(self, other, category=category) + from sage.categories.schemes import Schemes + if category is None or category.is_subcategory(Schemes()): + if isinstance(other, ell_generic.EllipticCurve_generic) and self.base_ring() == other.base_ring(): + from . import homset + return homset.EllipticCurveHomset(self, other, category=category) + from sage.schemes.generic.homset import SchemeHomset_generic + return SchemeHomset_generic(self, other, category=category) + from sage.categories.homset import Homset + return Homset(self, other, category=category) def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, algorithm=None, velu_sqrt_bound=None): r""" diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py index 370049d2238..bc0995470e1 100755 --- a/src/sage/schemes/generic/homset.py +++ b/src/sage/schemes/generic/homset.py @@ -249,15 +249,32 @@ class SchemeHomset_generic(HomsetWithBase): sage: from sage.schemes.generic.homset import SchemeHomset_generic sage: A2 = AffineSpace(QQ,2) - sage: Hom = SchemeHomset_generic(A2, A2); Hom + sage: Hom = A2.Hom(A2); Hom Set of morphisms From: Affine Space of dimension 2 over Rational Field To: Affine Space of dimension 2 over Rational Field sage: Hom.category() Category of endsets of schemes over Rational Field + + TESTS:: + + sage: Hom = SchemeHomset_generic(A2, A2); Hom + Set of morphisms + From: Affine Space of dimension 2 over Rational Field + To: Affine Space of dimension 2 over Rational Field + sage: Hom = SchemeHomset_generic(A2, A2, Sets()) + Traceback (most recent call last): + ... + ValueError: Cannot create SchemeHomset with category = Category of sets. Consider using Homset instead """ Element = SchemeMorphism + def __init__(self, X, Y, category=None, check=True, base=None): + super().__init__(X, Y, category, check, base) + from sage.categories.schemes import Schemes + if check and category is not None and not category.is_subcategory(Schemes()): + raise ValueError(f"Cannot create SchemeHomset with category = {category}. Consider using Homset instead") + def __reduce__(self): """ Used in pickling. From 60ad5f20ea391e2010e67b9743a50ba3f3a9e03d Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Thu, 28 Nov 2024 21:03:20 +0700 Subject: [PATCH 2/2] Fix category of GluedScheme --- src/sage/schemes/generic/glue.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sage/schemes/generic/glue.py b/src/sage/schemes/generic/glue.py index 7733030a2ab..a13aec6b982 100755 --- a/src/sage/schemes/generic/glue.py +++ b/src/sage/schemes/generic/glue.py @@ -44,6 +44,14 @@ class GluedScheme(Scheme): X: Spectrum of Univariate Polynomial Ring in x over Rational Field Y: Spectrum of Univariate Polynomial Ring in y over Rational Field U: Spectrum of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x*y - 1) + + TESTS:: + + sage: S = Sx.glue_along_domains(Sy) + sage: S.base_ring() + Integer Ring + sage: S.category() + Category of schemes """ def __init__(self, f, g, check=True): if check: @@ -55,6 +63,12 @@ def __init__(self, f, g, check=True): raise ValueError("f (=%s) and g (=%s) must have the same domain" % (f,g)) self.__f = f self.__g = g + category = f.codomain().category()._meet_(g.codomain().category()) + from sage.structure.element import get_coercion_model + base_ring = get_coercion_model().common_parent( + f.codomain().base_ring(), g.codomain().base_ring()) + Scheme.__init__(self, None, category) + self._base_ring = base_ring def gluing_maps(self): r"""