Skip to content

Commit

Permalink
sagemath: rebuild for updates
Browse files Browse the repository at this point in the history
Also:
 - rebuild for boost update in sync with brial (same PR)
 - fixes for numpy 1.24 (already updated)
 - fixes to support updating giac to 1.9.0.37
 - fixes to support updating tachyon 0.99.5
 - fixes to doctest failures in 32 bit after upgrade of pari to 2.15.2
 - fix an edge case of python 3.11 integer conversion on 32 bit
 - fix singular interface bug that triggers under very heavy load (e.g. on CI)
 - tarball was moved; sha256 changed only b/c of main dirname change
  • Loading branch information
tornaria committed Feb 5, 2023
1 parent 5d15251 commit d1ea2ee
Show file tree
Hide file tree
Showing 8 changed files with 768 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
From 55c04623a4b7404f5e4f9d152366d53e9c21cfa6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 21 Dec 2022 19:43:02 -0300
Subject: Trac #23712: support tachyon >= 0.99.2

In tachyon 0.99.2 the keyword `focallength` was changed to `focaldist`.
To support it, when running on version >= 0.99.2 we "patch" the model as
constructed by class `sage.plot.plot3d.tachyon.Tachyon`.

In the future (possibly when tachyon in sage gets upgraded), all the
focallength occurences in sage.plot.plot3d.tachyon can be replaced by
focaldist for consistency with new tachyon, and the logic here can be
reversed (i.e. patch the model when self.version() < '0.99.2') or just
drop support for old versions.
---
src/sage/interfaces/tachyon.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/src/sage/interfaces/tachyon.py b/src/sage/interfaces/tachyon.py
index 23671e5..21cc1db 100644
--- a/src/sage/interfaces/tachyon.py
+++ b/src/sage/interfaces/tachyon.py
@@ -683,12 +683,14 @@ properly.
#*****************************************************************************

import os
+import re

from sage.cpython.string import bytes_to_str
from sage.misc.pager import pager
from sage.misc.superseded import deprecation
from sage.misc.temporary_file import tmp_filename
from sage.structure.sage_object import SageObject
+from sage.misc.cachefunc import cached_method


class TachyonRT(SageObject):
@@ -799,6 +801,11 @@ class TachyonRT(SageObject):
Parser failed due to an input file syntax error.
Aborting render.
"""
+ if self.version() >= '0.99.2':
+ # this keyword was changed in 0.99.2
+ model = model.replace(
+ " focallength ",
+ " focaldist ")
modelfile = tmp_filename(ext='.dat')
with open(modelfile, 'w') as file:
file.write(model)
@@ -851,6 +858,22 @@ class TachyonRT(SageObject):
else:
print(r)

+ @cached_method
+ def version(self):
+ """
+ Returns the version of the Tachyon raytracer being used.
+
+ TESTS::
+
+ sage: tachyon_rt.version() # not tested
+ 0.98.9
+ sage: tachyon_rt.version() >= '0.98.9'
+ True
+ """
+ with os.popen('tachyon') as f:
+ r = f.read()
+ return re.search(r"Version ([\d.]*)", r)[1]
+
def help(self, use_pager=True):
"""
Deprecated: type 'sage.interfaces.tachyon?' for help
--
cgit v1.0-1-gd88e

Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
From 6f5c1c2fc8bcfb5e6555716d05ce70511795ffa1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 16 Dec 2022 15:25:38 -0300
Subject: Trac 33907: fix singular interface

This essentially reverts 85f65bf and a10d19d from trac #31846.
It turns out this was originaly written for #30945, but that issue was
fixed by upgrading cysignals.

Singular really needs a custom `_send_interrupt()` method, because the
default one will quit singular. Moreover, this handles two quirks of
singular:

- a small delay before sending `chr(3)` works around a bug in singular.
- sometimes one needs to send `;` a few times after interrupt to get
back a prompt.

The original author of the custom `_send_interrupt()` is Jeroen Demeyer
in commit 17d23e9 (trac #10476). I changed the timeout for a smaller
one, and rewrote the doctest to call `interrupt()` explicitly instead of
using `alarm()` which introduces more noise.
---
src/sage/interfaces/expect.py | 1 -
src/sage/interfaces/singular.py | 47 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/src/sage/interfaces/expect.py b/src/sage/interfaces/expect.py
index c4dc2d4..eb25daf 100644
--- a/src/sage/interfaces/expect.py
+++ b/src/sage/interfaces/expect.py
@@ -941,7 +941,6 @@ If this all works, you can then make calls like:
The interface still works after this interrupt::

sage: singular('2+3')
- Singular crashed -- automatically restarting.
5

Last, we demonstrate that by default the execution of a command
diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
index 9c9586d..2c377f0 100644
--- a/src/sage/interfaces/singular.py
+++ b/src/sage/interfaces/singular.py
@@ -341,6 +341,7 @@ import re
import sys
import pexpect
import shlex
+import time

from .expect import Expect, ExpectElement, FunctionElement, ExpectFunction

@@ -508,6 +509,52 @@ class Singular(ExtraTabCompletion, Expect):
"""
return 'quit;'

+ def _send_interrupt(self):
+ """
+ Send an interrupt to Singular. If needed, additional
+ semi-colons are sent until we get back at the prompt.
+
+ TESTS:
+
+ The following works without restarting Singular::
+
+ sage: a = singular(1)
+ sage: _ = singular._expect.sendline('while(1){};')
+ sage: singular.interrupt()
+ True
+
+ We can still access a::
+
+ sage: 2*a
+ 2
+
+ Interrupting nothing or unfinished input also works::
+
+ sage: singular.interrupt()
+ True
+ sage: _ = singular._expect.sendline('1+')
+ sage: singular.interrupt()
+ True
+ sage: 3*a
+ 3
+
+ """
+ # Work around for Singular bug
+ # http://www.singular.uni-kl.de:8002/trac/ticket/727
+ time.sleep(0.1)
+
+ E = self._expect
+ E.sendline(chr(3))
+ # The following is needed so interrupt() works even when
+ # there is no computation going on.
+ for i in range(5):
+ try:
+ E.expect_upto(self._prompt, timeout=0.1)
+ return
+ except pexpect.TIMEOUT:
+ pass
+ E.sendline(";")
+
def _read_in_file_command(self, filename):
r"""
EXAMPLES::
--
cgit v1.0-1-gd88e

Loading

0 comments on commit d1ea2ee

Please sign in to comment.