Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 17 additions & 35 deletions src/sage/libs/gap/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,23 @@
- ``a`` -- list of :class:`GapElement`

OUTPUT: list of the elements in ``a`` as a Gap ``Obj``

TESTS::

sage: from sage.doctest.util import ensure_interruptible_after
sage: for i in range(10):

Check failure on line 51 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[1]>", line 2, in <module> with ensure_interruptible_after(RealNumber('0.2')): File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/contextlib.py", line 144, in __exit__ next(self.gen) File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/util.py", line 897, in ensure_interruptible_after raise RuntimeError( RuntimeError: Function is not interruptible within 0.2000 seconds, only after 1.6674 seconds (__exit__ called before interrupt check)

Check failure on line 51 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[1]>", line 2, in <module> with ensure_interruptible_after(RealNumber('0.2')): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/contextlib.py", line 144, in __exit__ next(self.gen) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/util.py", line 897, in ensure_interruptible_after raise RuntimeError( RuntimeError: Function is not interruptible within 0.2000 seconds, only after 1.5116 seconds (__exit__ called before interrupt check)

Check failure on line 51 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, all, editable)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/home/runner/work/sage/sage/src/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/home/runner/work/sage/sage/src/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[1]>", line 2, in <module> with ensure_interruptible_after(RealNumber('0.2')): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/contextlib.py", line 144, in __exit__ next(self.gen) File "/home/runner/work/sage/sage/src/sage/doctest/util.py", line 897, in ensure_interruptible_after raise RuntimeError( RuntimeError: Function is not interruptible within 0.2000 seconds, only after 1.4043 seconds (__exit__ called before interrupt check)

Check failure on line 51 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.11, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[1]>", line 2, in <module> with ensure_interruptible_after(RealNumber('0.2')): File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/contextlib.py", line 144, in __exit__ next(self.gen) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/util.py", line 897, in ensure_interruptible_after raise RuntimeError( RuntimeError: Function is not interruptible within 0.2000 seconds, only after 1.0593 seconds (__exit__ called before interrupt check)

Check failure on line 51 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.12, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[1]>", line 2, in <module> with ensure_interruptible_after(RealNumber('0.2')): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/contextlib.py", line 144, in __exit__ next(self.gen) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/util.py", line 897, in ensure_interruptible_after raise RuntimeError( RuntimeError: Function is not interruptible within 0.2000 seconds, only after 0.8079 seconds (__exit__ called before interrupt check)
....: with ensure_interruptible_after(0.2):
....: ignore = libgap([1000]*100000)
"""
cdef Obj l
cdef GapElement elem
cdef int i
cdef tuple gap_elements = tuple(x if isinstance(x, GapElement) else libgap(x) for x in sage_list)
cdef Py_ssize_t n = len(gap_elements), i

try:
GAP_Enter()
l = GAP_NewPlist(0)

for i, x in enumerate(sage_list):
if not isinstance(x, GapElement):
elem = <GapElement>libgap(x)
else:
elem = <GapElement>x

GAP_AssList(l, i + 1, elem.value)
l = GAP_NewPlist(n)
for i in range(n):
GAP_AssList(l, i + 1, (<GapElement> gap_elements[i]).value)
return l
finally:
GAP_Leave()
Expand All @@ -82,30 +84,10 @@

The list of the elements in ``sage_list`` as a Gap ``Obj``.
"""
cdef Obj l
cdef GapElement elem
cdef GapElement one
cdef int i
if gap_ring is not None:
one = <GapElement>gap_ring.One()
else:
one = <GapElement>libgap(1)

try:
GAP_Enter()
l = GAP_NewPlist(0)

for i, x in enumerate(sage_list):
if not isinstance(x, GapElement):
elem = <GapElement>libgap(x)
elem = elem * one
else:
elem = <GapElement>x

GAP_AssList(l, i + 1, elem.value)
return l
finally:
GAP_Leave()
cdef GapElement one = gap_ring.One() if gap_ring is not None else libgap(1)
return make_gap_list([
x if isinstance(x, GapElement) else <GapElement>libgap(x) * one
for x in sage_list])


cdef char *capture_stdout(Obj func, Obj obj) noexcept:
Expand Down Expand Up @@ -190,7 +172,7 @@

TESTS::

sage: libgap({'a': 1, 'b':123}) # indirect doctest

Check failure on line 175 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[0]>", line 1, in <module> libgap({'a': Integer(1), 'b':Integer(123)}) # indirect doctest ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/repl/rich_output/display_manager.py", line 802, in displayhook plain_text, rich_output = self._rich_output_formatter(obj, dict()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/repl/rich_output/display_manager.py", line 622, in _rich_output_formatter has_rich_repr = isinstance(obj, SageObject) and hasattr(obj, '_rich_repr_') ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/libs/gap/element.pyx", line 763, in sage.libs.gap.element.GapElement.__getattr__ (self.parent(), gap_eval(name), self) File "sage/libs/gap/util.pyx", line 412, in sage.libs.gap.util.gap_eval result = GAP_EvalString(cmd) cysignals.signals.AlarmInterrupt

Check failure on line 175 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[0]>", line 1, in <module> libgap({'a': Integer(1), 'b':Integer(123)}) # indirect doctest ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/repl/rich_output/display_manager.py", line 802, in displayhook plain_text, rich_output = self._rich_output_formatter(obj, dict()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/repl/rich_output/display_manager.py", line 622, in _rich_output_formatter has_rich_repr = isinstance(obj, SageObject) and hasattr(obj, '_rich_repr_') ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/libs/gap/element.pyx", line 763, in sage.libs.gap.element.GapElement.__getattr__ (self.parent(), gap_eval(name), self) File "sage/libs/gap/util.pyx", line 412, in sage.libs.gap.util.gap_eval result = GAP_EvalString(cmd) cysignals.signals.AlarmInterrupt

Check failure on line 175 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, all, editable)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/home/runner/work/sage/sage/src/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/home/runner/work/sage/sage/src/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[0]>", line 1, in <module> libgap({'a': Integer(1), 'b':Integer(123)}) # indirect doctest ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/work/sage/sage/src/sage/repl/rich_output/display_manager.py", line 802, in displayhook plain_text, rich_output = self._rich_output_formatter(obj, dict()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/work/sage/sage/src/sage/repl/rich_output/display_manager.py", line 622, in _rich_output_formatter has_rich_repr = isinstance(obj, SageObject) and hasattr(obj, '_rich_repr_') ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/libs/gap/element.pyx", line 763, in sage.libs.gap.element.GapElement.__getattr__ File "sage/libs/gap/util.pyx", line 412, in sage.libs.gap.util.gap_eval cysignals.signals.AlarmInterrupt

Check failure on line 175 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.11, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[0]>", line 1, in <module> libgap({'a': Integer(1), 'b':Integer(123)}) # indirect doctest ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/repl/rich_output/display_manager.py", line 802, in displayhook plain_text, rich_output = self._rich_output_formatter(obj, dict()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/repl/rich_output/display_manager.py", line 622, in _rich_output_formatter has_rich_repr = isinstance(obj, SageObject) and hasattr(obj, '_rich_repr_') ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/libs/gap/element.pyx", line 763, in sage.libs.gap.element.GapElement.__getattr__ (self.parent(), gap_eval(name), self) File "sage/libs/gap/util.pyx", line 412, in sage.libs.gap.util.gap_eval result = GAP_EvalString(cmd) cysignals.signals.AlarmInterrupt

Check failure on line 175 in src/sage/libs/gap/element.pyx

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.12, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.libs.gap.element.NULL[0]>", line 1, in <module> libgap({'a': Integer(1), 'b':Integer(123)}) # indirect doctest ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/repl/rich_output/display_manager.py", line 802, in displayhook plain_text, rich_output = self._rich_output_formatter(obj, dict()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/repl/rich_output/display_manager.py", line 622, in _rich_output_formatter has_rich_repr = isinstance(obj, SageObject) and hasattr(obj, '_rich_repr_') ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/libs/gap/element.pyx", line 763, in sage.libs.gap.element.GapElement.__getattr__ (self.parent(), gap_eval(name), self) File "sage/libs/gap/util.pyx", line 412, in sage.libs.gap.util.gap_eval result = GAP_EvalString(cmd) cysignals.signals.AlarmInterrupt
rec( a := 1, b := 123 )
"""
data = [ (str(key), libgap(value)) for key, value in sage_dict.iteritems() ]
Expand Down
Loading