From adc231ef98032f86f42167a98dd86f3800f1ee9f Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Sun, 4 Dec 2022 15:59:28 +0000 Subject: [PATCH 1/4] remove is_GapElement from number fields code --- src/sage/rings/number_field/number_field.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index a24552a0c6f..4e2200dd41f 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -159,6 +159,8 @@ from sage.modules.free_module_element import vector from sage.rings.real_mpfr import RR +from sage.interfaces.abc import GapElement + _NumberFields = NumberFields() @@ -1819,7 +1821,7 @@ def _element_constructor_(self, x, check=True): raise TypeError("%s has unsupported PARI type %s" % (x, x.type())) x = self.absolute_polynomial().parent()(x) return self._element_class(self, x) - elif sage.interfaces.gap.is_GapElement(x): + elif isinstance(x, GapElement): s = x._sage_repr() if self.variable_name() in s: return self._convert_from_str(s) @@ -11143,8 +11145,7 @@ def _element_constructor_(self, x, check=True): return NumberField_absolute._element_constructor_(self, x) elif isinstance(x, pari_gen): return NumberField_absolute._element_constructor_(self, x, check=check) - elif (sage.interfaces.gap.is_GapElement(x) or - isinstance(x, sage.libs.gap.element.GapElement)): + elif isinstance(x, (sage.libs.gap.element.GapElement, GapElement)): return self._coerce_from_gap(x) elif isinstance(x, str): return self._convert_from_str(x) From 7c67a1089852beca7b5e0b80ad3cb2a319f0ceef Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Sun, 4 Dec 2022 16:22:31 +0000 Subject: [PATCH 2/4] deprecating is_GapElement --- src/sage/interfaces/gap.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py index 1f5fc58e9db..6e1c2355341 100644 --- a/src/sage/interfaces/gap.py +++ b/src/sage/interfaces/gap.py @@ -1635,16 +1635,24 @@ def _instancedoc_(self): def is_GapElement(x): """ + Deprecated function + + Use isinstance(x,GapElement) + Returns True if x is a GapElement. EXAMPLES:: sage: from sage.interfaces.gap import is_GapElement sage: is_GapElement(gap(2)) + doctest:...: DeprecationWarning: The function is_GapElement is deprecated. Use isinstance(x, GapElement) instead + See https://trac.sagemath.org/34823 for details. True sage: is_GapElement(2) False """ + from sage.misc.superseded import deprecation + deprecation(34823, "The function is_GapElement is deprecated. Use isinstance(x, GapElement) instead") return isinstance(x, GapElement) def gfq_gap_to_sage(x, F): From 6c75e9b0cc5679ee9ea5773ca1586eacf438e378 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Sun, 4 Dec 2022 21:56:40 +0000 Subject: [PATCH 3/4] better rst, point at sage.interfaces.abc to use --- src/sage/interfaces/gap.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py index 6e1c2355341..c2f8008171d 100644 --- a/src/sage/interfaces/gap.py +++ b/src/sage/interfaces/gap.py @@ -1637,22 +1637,22 @@ def is_GapElement(x): """ Deprecated function - Use isinstance(x,GapElement) + Use :func:`isinstance` (of :class:`sage.interfaces.abc.GapElement`) instead. - Returns True if x is a GapElement. + Returns True if ``x`` is :class:`GapElement` EXAMPLES:: sage: from sage.interfaces.gap import is_GapElement sage: is_GapElement(gap(2)) - doctest:...: DeprecationWarning: The function is_GapElement is deprecated. Use isinstance(x, GapElement) instead + doctest:...: DeprecationWarning: The function is_GapElement is deprecated. Use isinstance(x, sage.interfaces.abc.GapElement) instead See https://trac.sagemath.org/34823 for details. True sage: is_GapElement(2) False """ from sage.misc.superseded import deprecation - deprecation(34823, "The function is_GapElement is deprecated. Use isinstance(x, GapElement) instead") + deprecation(34823, "The function is_GapElement is deprecated. Use isinstance(x, sage.interfaces.abc.GapElement) instead") return isinstance(x, GapElement) def gfq_gap_to_sage(x, F): From e99db3af3a814e9accdd10a915f651aabe9faa91 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 4 Dec 2022 14:04:14 -0800 Subject: [PATCH 4/4] src/sage/interfaces/gap.py: Reviewer edits --- src/sage/interfaces/gap.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py index c2f8008171d..7ae1792e9de 100644 --- a/src/sage/interfaces/gap.py +++ b/src/sage/interfaces/gap.py @@ -1635,26 +1635,26 @@ def _instancedoc_(self): def is_GapElement(x): """ - Deprecated function + Return True if ``x`` is a :class:`GapElement` - Use :func:`isinstance` (of :class:`sage.interfaces.abc.GapElement`) instead. - - Returns True if ``x`` is :class:`GapElement` + This function is deprecated; use :func:`isinstance` + (of :class:`sage.interfaces.abc.GapElement`) instead. EXAMPLES:: sage: from sage.interfaces.gap import is_GapElement sage: is_GapElement(gap(2)) - doctest:...: DeprecationWarning: The function is_GapElement is deprecated. Use isinstance(x, sage.interfaces.abc.GapElement) instead + doctest:...: DeprecationWarning: the function is_GapElement is deprecated; use isinstance(x, sage.interfaces.abc.GapElement) instead See https://trac.sagemath.org/34823 for details. True sage: is_GapElement(2) False """ from sage.misc.superseded import deprecation - deprecation(34823, "The function is_GapElement is deprecated. Use isinstance(x, sage.interfaces.abc.GapElement) instead") + deprecation(34823, "the function is_GapElement is deprecated; use isinstance(x, sage.interfaces.abc.GapElement) instead") return isinstance(x, GapElement) + def gfq_gap_to_sage(x, F): """ INPUT: