Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Dec 4, 2022
2 parents 8572f15 + e99db3a commit b802415
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/sage/interfaces/gap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1635,18 +1635,26 @@ def _instancedoc_(self):

def is_GapElement(x):
"""
Returns True if x is a GapElement.
Return True if ``x`` is a :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
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")
return isinstance(x, GapElement)


def gfq_gap_to_sage(x, F):
"""
INPUT:
Expand Down
7 changes: 4 additions & 3 deletions src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b802415

Please sign in to comment.