230 lines
13 KiB
Diff
230 lines
13 KiB
Diff
commit 8b32fdb87725c1d67ffb51dadec1c331c7c35f3c
|
|
Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
|
|
Date: Tue Aug 20 00:05:33 2024 -0300
|
|
|
|
silence np.set_printoptions (for numpy 2.1)
|
|
|
|
diff --git a/src/sage/combinat/fully_packed_loop.py b/src/sage/combinat/fully_packed_loop.py
|
|
index b3ebd206cd2..48866824224 100644
|
|
--- a/src/sage/combinat/fully_packed_loop.py
|
|
+++ b/src/sage/combinat/fully_packed_loop.py
|
|
@@ -68,7 +68,7 @@ def _make_color_list(n, colors=None, color_map=None, randomize=False):
|
|
|
|
sage: import numpy as np
|
|
sage: if int(np.version.short_version[0]) > 1:
|
|
- ....: np.set_printoptions(legacy="1.25")
|
|
+ ....: _token = np.set_printoptions(legacy="1.25")
|
|
sage: from sage.combinat.fully_packed_loop import _make_color_list
|
|
sage: _make_color_list(5)
|
|
sage: _make_color_list(5, ['blue', 'red'])
|
|
diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
|
|
index 2a03bb68f67..30b56722e66 100644
|
|
--- a/src/sage/functions/special.py
|
|
+++ b/src/sage/functions/special.py
|
|
@@ -219,7 +219,7 @@ class SphericalHarmonic(BuiltinFunction):
|
|
sage: from scipy.special import sph_harm # NB: arguments x and y are swapped # needs scipy
|
|
sage: import numpy as np # needs scipy
|
|
sage: if int(np.version.short_version[0]) > 1: # needs scipy
|
|
- ....: np.set_printoptions(legacy="1.25") # needs scipy
|
|
+ ....: _token = np.set_printoptions(legacy="1.25") # needs scipy
|
|
sage: sph_harm(1, 1, pi.n(), (pi/2).n()) # abs tol 1e-14 # needs scipy sage.symbolic
|
|
(0.3454941494713355-4.231083042742082e-17j)
|
|
|
|
diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py
|
|
index 7ae8ca4966f..4cba22efdba 100644
|
|
--- a/src/sage/numerical/optimize.py
|
|
+++ b/src/sage/numerical/optimize.py
|
|
@@ -385,7 +385,7 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default",
|
|
....: return sum(100.0r*(x[1r:]-x[:-1r]**2.0r)**2.0r + (1r-x[:-1r])**2.0r)
|
|
sage: import numpy
|
|
sage: if int(numpy.version.short_version[0]) > 1:
|
|
- ....: numpy.set_printoptions(legacy="1.25")
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25")
|
|
sage: from numpy import zeros
|
|
sage: def rosen_der(x):
|
|
....: xm = x[1r:-1r]
|
|
diff --git a/src/sage/plot/arrow.py b/src/sage/plot/arrow.py
|
|
index 23e2517ca56..7375dcd5d1c 100644
|
|
--- a/src/sage/plot/arrow.py
|
|
+++ b/src/sage/plot/arrow.py
|
|
@@ -55,7 +55,7 @@ class CurveArrow(GraphicPrimitive):
|
|
|
|
sage: import numpy # to ensure numpy 2.0 compatibility
|
|
sage: if int(numpy.version.short_version[0]) > 1:
|
|
- ....: numpy.set_printoptions(legacy="1.25")
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25")
|
|
sage: from sage.plot.arrow import CurveArrow
|
|
sage: b = CurveArrow(path=[[(0,0),(.5,.5),(1,0)],[(.5,1),(0,0)]],
|
|
....: options={})
|
|
diff --git a/src/sage/plot/multigraphics.py b/src/sage/plot/multigraphics.py
|
|
index 6be448f1e04..004594b77c4 100644
|
|
--- a/src/sage/plot/multigraphics.py
|
|
+++ b/src/sage/plot/multigraphics.py
|
|
@@ -786,7 +786,7 @@ class MultiGraphics(WithEqualityById, SageObject):
|
|
(0.2, 0.3, 0.4, 0.1)
|
|
sage: import numpy # to ensure numpy 2.0 compatibility
|
|
sage: if int(numpy.version.short_version[0]) > 1:
|
|
- ....: numpy.set_printoptions(legacy="1.25")
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25")
|
|
sage: ax1.get_position().bounds # tol 1.0e-13
|
|
(0.2, 0.3, 0.4000000000000001, 0.10000000000000003)
|
|
|
|
@@ -1300,7 +1300,7 @@ class GraphicsArray(MultiGraphics):
|
|
sage: G = graphics_array([g1, g2])
|
|
sage: import numpy # to ensure numpy 2.0 compatibility
|
|
sage: if int(numpy.version.short_version[0]) > 1:
|
|
- ....: numpy.set_printoptions(legacy="1.25")
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25")
|
|
sage: G.position(0) # tol 5.0e-3
|
|
(0.025045451349937315,
|
|
0.03415488992713045,
|
|
diff --git a/src/sage/plot/streamline_plot.py b/src/sage/plot/streamline_plot.py
|
|
index d2cb11088c7..6d88517cc15 100644
|
|
--- a/src/sage/plot/streamline_plot.py
|
|
+++ b/src/sage/plot/streamline_plot.py
|
|
@@ -73,7 +73,7 @@ class StreamlinePlot(GraphicPrimitive):
|
|
sage: x, y = var('x y')
|
|
sage: import numpy # to ensure numpy 2.0 compatibility
|
|
sage: if int(numpy.version.short_version[0]) > 1:
|
|
- ....: numpy.set_printoptions(legacy="1.25")
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25")
|
|
sage: d = streamline_plot((.01*x, x+y), (x,10,20), (y,10,20))[0].get_minmax_data()
|
|
sage: d['xmin']
|
|
10.0
|
|
diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
|
|
index 38c30f7627b..cfb8a5ff5f7 100644
|
|
--- a/src/sage/rings/integer.pyx
|
|
+++ b/src/sage/rings/integer.pyx
|
|
@@ -594,7 +594,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
|
|
|
|
sage: import numpy # needs numpy
|
|
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
|
|
- ....: numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
sage: numpy.int8('12') == 12 # needs numpy
|
|
True
|
|
sage: 12 == numpy.int8('12') # needs numpy
|
|
diff --git a/src/sage/rings/real_mpfi.pyx b/src/sage/rings/real_mpfi.pyx
|
|
index 76fbfedab95..57de30c9d18 100644
|
|
--- a/src/sage/rings/real_mpfi.pyx
|
|
+++ b/src/sage/rings/real_mpfi.pyx
|
|
@@ -232,7 +232,7 @@ TESTS::
|
|
|
|
sage: import numpy # needs numpy
|
|
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
|
|
- ....: numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
sage: RIF(2) == numpy.int8('2') # needs numpy
|
|
True
|
|
sage: numpy.int8('2') == RIF(2) # needs numpy
|
|
diff --git a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx
|
|
index 70ce616f92f..f604c6d3785 100644
|
|
--- a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx
|
|
+++ b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx
|
|
@@ -78,7 +78,7 @@ cdef class PeriodicRegion:
|
|
|
|
sage: import numpy as np
|
|
sage: if int(np.version.short_version[0]) > 1:
|
|
- ....: np.set_printoptions(legacy="1.25")
|
|
+ ....: _token = np.set_printoptions(legacy="1.25")
|
|
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
|
|
sage: data = np.zeros((4, 4))
|
|
sage: PeriodicRegion(CDF(2), CDF(2*I), data).is_empty()
|
|
@@ -298,7 +298,7 @@ cdef class PeriodicRegion:
|
|
|
|
sage: import numpy as np
|
|
sage: if int(np.version.short_version[0]) > 1:
|
|
- ....: np.set_printoptions(legacy="1.25")
|
|
+ ....: _token = np.set_printoptions(legacy="1.25")
|
|
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
|
|
sage: data = np.zeros((10, 10))
|
|
sage: data[1:4,1:4] = True
|
|
@@ -322,7 +322,7 @@ cdef class PeriodicRegion:
|
|
|
|
sage: import numpy as np
|
|
sage: if int(np.version.short_version[0]) > 1:
|
|
- ....: np.set_printoptions(legacy="1.25")
|
|
+ ....: _token = np.set_printoptions(legacy="1.25")
|
|
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
|
|
sage: data = np.zeros((4, 4))
|
|
sage: data[1,1] = True
|
|
@@ -377,7 +377,7 @@ cdef class PeriodicRegion:
|
|
|
|
sage: import numpy as np
|
|
sage: if int(np.version.short_version[0]) > 1:
|
|
- ....: np.set_printoptions(legacy="1.25")
|
|
+ ....: _token = np.set_printoptions(legacy="1.25")
|
|
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
|
|
|
|
sage: data = np.zeros((20, 20))
|
|
@@ -529,7 +529,7 @@ cdef class PeriodicRegion:
|
|
|
|
sage: import numpy as np
|
|
sage: if int(np.version.short_version[0]) > 1:
|
|
- ....: np.set_printoptions(legacy="1.25")
|
|
+ ....: _token = np.set_printoptions(legacy="1.25")
|
|
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
|
|
sage: data = np.zeros((4, 4))
|
|
sage: data[1, 1] = True
|
|
diff --git a/src/sage/stats/basic_stats.py b/src/sage/stats/basic_stats.py
|
|
index 6937f6cb410..fb296e00fb6 100644
|
|
--- a/src/sage/stats/basic_stats.py
|
|
+++ b/src/sage/stats/basic_stats.py
|
|
@@ -228,7 +228,7 @@ def std(v, bias=False):
|
|
sage: # needs numpy
|
|
sage: import numpy
|
|
sage: if int(numpy.version.short_version[0]) > 1:
|
|
- ....: numpy.set_printoptions(legacy="1.25")
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25")
|
|
sage: x = numpy.array([1,2,3,4,5])
|
|
sage: std(x, bias=False)
|
|
1.5811388300841898
|
|
@@ -307,7 +307,7 @@ def variance(v, bias=False):
|
|
0.4897530450000000?
|
|
sage: import numpy # needs numpy
|
|
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
|
|
- ....: numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
sage: x = numpy.array([1,2,3,4,5]) # needs numpy
|
|
sage: variance(x, bias=False) # needs numpy
|
|
2.5
|
|
diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx
|
|
index 955a256e9b4..e5ed6160b79 100644
|
|
--- a/src/sage/structure/coerce.pyx
|
|
+++ b/src/sage/structure/coerce.pyx
|
|
@@ -521,7 +521,7 @@ cdef class CoercionModel:
|
|
|
|
sage: import numpy # needs numpy
|
|
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
|
|
- ....: numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
|
|
sage: # needs sage.rings.real_mpfr
|
|
sage: x = polygen(RR)
|
|
diff --git a/src/sage/symbolic/function.pyx b/src/sage/symbolic/function.pyx
|
|
index cd89ad2a256..6fdf6d8ef23 100644
|
|
--- a/src/sage/symbolic/function.pyx
|
|
+++ b/src/sage/symbolic/function.pyx
|
|
@@ -965,7 +965,7 @@ cdef class BuiltinFunction(Function):
|
|
|
|
sage: import numpy # needs numpy
|
|
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
|
|
- ....: numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
|
|
sage: sin(numpy.int32(0)) # needs numpy
|
|
0.0
|
|
diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx
|
|
index 5b007d9e5fd..4a096d317e7 100644
|
|
--- a/src/sage/symbolic/ring.pyx
|
|
+++ b/src/sage/symbolic/ring.pyx
|
|
@@ -1163,7 +1163,7 @@ cdef class NumpyToSRMorphism(Morphism):
|
|
|
|
sage: import numpy # needs numpy
|
|
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
|
|
- ....: numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
+ ....: _token = numpy.set_printoptions(legacy="1.25") # needs numpy
|
|
sage: f(x) = x^2
|
|
sage: f(numpy.int8('2')) # needs numpy
|
|
4
|