Skip to content

Commit

Permalink
sagemath: update to 9.8.
Browse files Browse the repository at this point in the history
Also:
 - fix edge case of python 3.11 integer conversion on 32 bit
 - support tachyon 0.99.5
 - support singular 4.3.1p3
 - fix tests for giac 1.9.0.35
 - fix tests for numpy 1.24
 - skip unstable tests in klyachko.py
 - remove zn_poly dependency
 - fix very slow test in stream.py
  • Loading branch information
tornaria authored and leahneukirchen committed Feb 15, 2023
1 parent e117382 commit a59f11f
Show file tree
Hide file tree
Showing 26 changed files with 1,854 additions and 4,662 deletions.
3 changes: 2 additions & 1 deletion srcpkgs/sagemath/files/sage_conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# configuration for sage on void linux
SAGE_SHARE = "/usr/share/sagemath"
GAP_ROOT_DIR = "/usr/share/gap"
GAP_SHARE_DIR = "/usr/share/gap"
GAP_LIB_DIR = "/usr/lib/gap"
14 changes: 0 additions & 14 deletions srcpkgs/sagemath/patches/09-doctest_numerical_fix.patch

This file was deleted.

47 changes: 47 additions & 0 deletions srcpkgs/sagemath/patches/34980-avoid_factoring_in_is_prime.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
index d5f7157217f..1a9d11aec68 100644
--- a/src/sage/rings/number_field/number_field_ideal.py
+++ b/src/sage/rings/number_field/number_field_ideal.py
@@ -996,16 +996,36 @@ def is_prime(self):
False
sage: K.ideal(17).is_prime() # ramified
False
+
+ TESTS:
+
+ Check that we do not factor the norm of the ideal, this used
+ to take half an hour, see :trac:`33360`::
+
+ sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
+ sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
+ ....: + 10130950)*a + (1343014/7653*c - 8349770)*b
+ ....: + 6477058*c - 2801449990/4002519)
+ sage: t.is_prime()
+ False
"""
try:
return self._pari_prime is not None
except AttributeError:
- F = self.factor() # factorization with caching
- if len(F) != 1 or F[0][1] != 1:
- self._pari_prime = None
- else:
- self._pari_prime = F[0][0]._pari_prime
- return self._pari_prime is not None
+ pass
+
+ K = self.number_field().pari_nf()
+ I = self.pari_hnf()
+
+ self._pari_prime = K.idealismaximal(I) or None
+
+ # PARI uses probabilistic primality testing inside idealismaximal().
+ if self._pari_prime \
+ and get_flag(None, 'arithmetic') \
+ and not self._pari_prime[0].isprime():
+ self._pari_prime = None
+
+ return self._pari_prime is not None

def pari_prime(self):
r"""
58 changes: 58 additions & 0 deletions srcpkgs/sagemath/patches/34994-fix_tests_numpy_1.24.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
diff --git a/src/sage/misc/persist.pyx b/src/sage/misc/persist.pyx
index 3ac5f1cc2b0..cb1f327c199 100644
--- a/src/sage/misc/persist.pyx
+++ b/src/sage/misc/persist.pyx
@@ -157,7 +157,7 @@ def load(*filename, compress=True, verbose=True, **kwargs):
....: _ = f.write(code)
sage: load(t)
sage: hello
- <fortran object>
+ <fortran ...>
"""
import sage.repl.load
if len(filename) != 1:
diff --git a/src/sage/plot/complex_plot.pyx b/src/sage/plot/complex_plot.pyx
index 6f0aeab87ae..b77c69b2f77 100644
--- a/src/sage/plot/complex_plot.pyx
+++ b/src/sage/plot/complex_plot.pyx
@@ -461,6 +461,8 @@ def complex_to_rgb(z_values, contoured=False, tiled=False,
rgb[i, j, 2] = b

sig_off()
+ nan_indices = np.isnan(rgb).any(-1) # Mask for undefined points
+ rgb[nan_indices] = 1 # Make nan_indices white
return rgb


diff --git a/src/sage/plot/histogram.py b/src/sage/plot/histogram.py
index 3bc2b76b58e..388c2d1391d 100644
--- a/src/sage/plot/histogram.py
+++ b/src/sage/plot/histogram.py
@@ -87,13 +87,8 @@ def get_minmax_data(self):

TESTS::

- sage: h = histogram([10,3,5], normed=True)[0]
- doctest:warning...:
- DeprecationWarning: the 'normed' option is deprecated. Use 'density' instead.
- See https://trac.sagemath.org/25260 for details.
+ sage: h = histogram([10,3,5], density=True)[0]
sage: h.get_minmax_data()
- doctest:warning ...
- ...VisibleDeprecationWarning: Passing `normed=True` on non-uniform bins has always been broken, and computes neither the probability density function nor the probability mass function. The result is only correct if the bins are uniform, when density=True will produce the same result anyway. The argument will be removed in a future version of numpy.
{'xmax': 10.0, 'xmin': 3.0, 'ymax': 0.476190476190..., 'ymin': 0}
"""
import numpy
diff --git a/src/sage/repl/ipython_extension.py b/src/sage/repl/ipython_extension.py
index 798671aab42..cad6a47ca8b 100644
--- a/src/sage/repl/ipython_extension.py
+++ b/src/sage/repl/ipython_extension.py
@@ -405,7 +405,7 @@ def fortran(self, line, cell):
....: C END FILE FIB1.F
....: ''')
sage: fib
- <fortran object>
+ <fortran ...>
sage: from numpy import array
sage: a = array(range(10), dtype=float)
sage: fib(a, 10)
57 changes: 57 additions & 0 deletions srcpkgs/sagemath/patches/34995-support_tachyon_0.99.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
diff --git a/src/sage/interfaces/tachyon.py b/src/sage/interfaces/tachyon.py
index 23671e50892..ce1d50f71bc 100644
--- a/src/sage/interfaces/tachyon.py
+++ b/src/sage/interfaces/tachyon.py
@@ -683,12 +683,14 @@
#*****************************************************************************

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 @@ def __call__(self, model, outfile='sage.png', verbose=1, extra_opts=''):
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,25 @@ def usage(self, use_pager=True):
else:
print(r)

+ @cached_method
+ def version(self):
+ """
+ Returns the version of the Tachyon raytracer being used.
+
+ TESTS::
+
+ sage: tachyon_rt.version() # random
+ 0.98.9
+ sage: tachyon_rt.version() >= '0.98.9'
+ True
+ """
+ with os.popen('tachyon') as f:
+ r = f.readline()
+ res = re.search(r"Version ([\d.]*)", r)
+ # debian patches tachyon so it won't report the version
+ # we hardcode '0.99' since that's indeed the version they ship
+ return res[1] if res else '0.99'
+
def help(self, use_pager=True):
"""
Deprecated: type 'sage.interfaces.tachyon?' for help
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
index 1c9a53387a0..d96b98f247c 100644
--- a/src/sage/arith/long.pxd
+++ b/src/sage/arith/long.pxd
@@ -270,6 +270,17 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
sage: L += [-x for x in L] + [0, long_min()]
sage: for v in L:
....: assert check_long_py(int(v)) == v
+ sage: check_long_py(int(2^60))
+ 1152921504606846976 # 64-bit
+ 'Overflow (...)' # 32-bit
+ sage: check_long_py(int(2^61))
+ 2305843009213693952 # 64-bit
+ 'Overflow (...)' # 32-bit
+ sage: check_long_py(int(2^62))
+ 4611686018427387904 # 64-bit
+ 'Overflow (...)' # 32-bit
+ sage: check_long_py(int(2^63))
+ 'Overflow (...)'
sage: check_long_py(int(2^100))
'Overflow (...)'
sage: check_long_py(int(long_max() + 1))
@@ -309,7 +320,12 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):

cdef long lead
cdef long lead_2_overflow = (<long>1) << (BITS_IN_LONG - PyLong_SHIFT)
- cdef long lead_3_overflow = (<long>1) << (BITS_IN_LONG - 2 * PyLong_SHIFT)
+ cdef long lead_3_overflow
+ if BITS_IN_LONG < 2 * PyLong_SHIFT:
+ # in this case 3 digit is always overflow
+ lead_3_overflow = 0
+ else:
+ lead_3_overflow = (<long>1) << (BITS_IN_LONG - 2 * PyLong_SHIFT)
if size == 0:
value[0] = 0
err[0] = 0
22 changes: 22 additions & 0 deletions srcpkgs/sagemath/patches/35058-skip_unstable_tests_klyachko.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/src/sage/schemes/toric/sheaf/klyachko.py b/src/sage/schemes/toric/sheaf/klyachko.py
index b1304a16913..77fae4b7545 100644
--- a/src/sage/schemes/toric/sheaf/klyachko.py
+++ b/src/sage/schemes/toric/sheaf/klyachko.py
@@ -26,7 +26,7 @@
(0, 0, 18, 16, 1)
sage: Gtilde = G_sum.random_deformation()
sage: V = Gtilde.wedge(2) * K # long time
- sage: V.cohomology(dim=True, weight=(0,0,0,0)) # long time
+ sage: V.cohomology(dim=True, weight=(0,0,0,0)) # long time # random failure (see #32773)
(0, 0, 3, 0, 0)

REFERENCES:
@@ -948,7 +948,7 @@ def random_deformation(self, epsilon=None):
sage: V.cohomology(dim=True, weight=(0,))
(1, 0)
sage: Vtilde = V.random_deformation()
- sage: Vtilde.cohomology(dim=True, weight=(0,))
+ sage: Vtilde.cohomology(dim=True, weight=(0,)) # random failure (see #32773)
(1, 0)
"""
filt = self._filt.random_deformation(epsilon)
62 changes: 62 additions & 0 deletions srcpkgs/sagemath/patches/35068-fix_tests_giac_1.9.0.35.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
From 9ac7840134054155545e24fa3e66402d42b91c0f Mon Sep 17 00:00:00 2001
From: Antonio Rojas <arojas@archlinux.org>
Date: Fri, 20 Jan 2023 21:36:27 +0100
Subject: [PATCH] Fix tests with giac 1.9.0.35

---
src/sage/libs/giac/giac.pyx | 3 +--
src/sage/symbolic/relation.py | 15 +++++----------
2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/sage/libs/giac/giac.pyx b/src/sage/libs/giac/giac.pyx
index 4e451dba5e7..ccad5169836 100644
--- a/src/sage/libs/giac/giac.pyx
+++ b/src/sage/libs/giac/giac.pyx
@@ -374,8 +374,7 @@ def _giac(s):

sage: x = libgiac('x')
sage: (1+2*sin(3*x)).solve(x).simplify()
- Warning, argument is not an equation, solving 1+2*sin(3*x)=0
- list[-pi/18,7*pi/18]
+ ...list[-pi/18,7*pi/18]

sage: libgiac.solve('sin(3*x)>2*sin(x)',x)
Traceback (most recent call last):
diff --git a/src/sage/symbolic/relation.py b/src/sage/symbolic/relation.py
index e9dbc0fea30..b8896a94be9 100644
--- a/src/sage/symbolic/relation.py
+++ b/src/sage/symbolic/relation.py
@@ -935,8 +935,7 @@ def solve(f, *args, **kwds):

sage: f = (sin(x) - 8*cos(x)*sin(x))*(sin(x)^2 + cos(x)) - (2*cos(x)*sin(x) - sin(x))*(-2*sin(x)^2 + 2*cos(x)^2 - cos(x))
sage: solve(f, x, algorithm='giac')
- ...
- [-2*arctan(sqrt(2)), 0, 2*arctan(sqrt(2)), pi]
+ ...[-2*arctan(sqrt(2)), 0, 2*arctan(sqrt(2)), pi]

sage: x, y = SR.var('x,y')
sage: solve([x+y-4,x*y-3],[x,y],algorithm='giac')
@@ -1440,19 +1439,15 @@ def _giac_solver(f, x, solution_dict=False):
EXAMPLES::

sage: solve([(2/3)^x-2], [x], algorithm='giac')
- ...
- [[-log(2)/(log(3) - log(2))]]
+ ...[[-log(2)/(log(3) - log(2))]]
sage: solve([(2/3)^x-2], [x], algorithm='giac', solution_dict=True)
- ...
- [{x: -log(2)/(log(3) - log(2))}]
+ ...[{x: -log(2)/(log(3) - log(2))}]

sage: f = (sin(x) - 8*cos(x)*sin(x))*(sin(x)^2 + cos(x)) - (2*cos(x)*sin(x) - sin(x))*(-2*sin(x)^2 + 2*cos(x)^2 - cos(x))
sage: solve(f, x, algorithm='giac')
- ...
- [-2*arctan(sqrt(2)), 0, 2*arctan(sqrt(2)), pi]
+ ...[-2*arctan(sqrt(2)), 0, 2*arctan(sqrt(2)), pi]
sage: solve(f, x, algorithm='giac', solution_dict=True)
- ...
- [{x: -2*arctan(sqrt(2))}, {x: 0}, {x: 2*arctan(sqrt(2))}, {x: pi}]
+ ...[{x: -2*arctan(sqrt(2))}, {x: 0}, {x: 2*arctan(sqrt(2))}, {x: pi}]

sage: x, y = SR.var('x,y')
sage: solve([x+y-7,x*y-10],[x,y],algorithm='giac')
Loading

0 comments on commit a59f11f

Please sign in to comment.