Skip to content

Commit ecfe06b

Browse files
author
Release Manager
committed
gh-35826: Fixes to support numpy 1.25.0 ### 📚 Description Mostly due to a deprecation warning: `Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)`. Also fix: - a change of output in `numpy.linalg.eig()` - a change in an exception class See: #35081 <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> <!-- Describe your changes here in detail. --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35826 Reported by: Gonzalo Tornaría Reviewer(s):
2 parents ebc7130 + 941ca85 commit ecfe06b

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/sage/calculus/desolvers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ def desolve_odeint(des, ics, times, dvars, ivar=None, compute_jac=False, args=()
15981598
sage: ic=epsilon
15991599
sage: t=srange(0,2/epsilon,1)
16001600
sage: sol=desolve_odeint(f,ic,t,y,rtol=1e-9,atol=1e-10,compute_jac=True)
1601-
sage: p=points(zip(t,sol))
1601+
sage: p=points(zip(t,sol[:,0]))
16021602
sage: p.show()
16031603
16041604
Another stiff system with some optional parameters with no
@@ -1637,7 +1637,7 @@ def desolve_odeint_inner(ivar):
16371637
J = fast_float(J, dvar, ivar)
16381638

16391639
def Dfun(y, t):
1640-
return [J(y, t)]
1640+
return [J(y.item(), t)]
16411641

16421642
# n-dimensional systems:
16431643
else:

src/sage/matrix/matrix2.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,12 @@ cdef class Matrix(Matrix1):
430430
try:
431431
return self.transpose().solve_right(B, check=check)
432432
except ValueError as e:
433-
raise ValueError(str(e).replace('row', 'column'))
433+
raise e.__class__(str(e).replace('row', 'column'))
434434
else:
435435
try:
436436
return self.transpose().solve_right(B.transpose(), check=check).transpose()
437437
except ValueError as e:
438-
raise ValueError(str(e).replace('row', 'column'))
438+
raise e.__class__(str(e).replace('row', 'column'))
439439

440440
def solve_right(self, B, check=True):
441441
r"""

src/sage/matrix/matrix_numpy_dense.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,9 @@ cdef class Matrix_numpy_dense(Matrix_dense):
382382
sage: m = matrix(RDF,[[1,2],[3,4]])
383383
sage: n = m.numpy()
384384
sage: import numpy
385-
sage: numpy.linalg.eig(n)
386-
(array([-0.37228132, 5.37228132]), array([[-0.82456484, -0.41597356],
385+
sage: tuple(numpy.linalg.eig(n))
386+
(array([-0.37228132, 5.37228132]),
387+
array([[-0.82456484, -0.41597356],
387388
[ 0.56576746, -0.90937671]]))
388389
sage: m = matrix(RDF, 2, range(6)); m
389390
[0.0 1.0 2.0]

src/sage/plot/plot3d/list_plot3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ def g(x, y):
602602
from .parametric_surface import ParametricSurface
603603

604604
def g(x, y):
605-
z = f([x, y])
605+
z = f([x, y]).item()
606606
return (x, y, z)
607607
G = ParametricSurface(g, (list(numpy.r_[xmin:xmax:num_points * j]),
608608
list(numpy.r_[ymin:ymax:num_points * j])),

src/sage/plot/plot3d/plot3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def to_cartesian(self, func, params=None):
378378
....: [ 0.16763356, 0.19993708, 0.31403568, 0.47359696, 0.55282422],
379379
....: [ 0.16763356, 0.25683223, 0.16649297, 0.10594339, 0.55282422]])
380380
sage: import scipy.interpolate
381-
sage: f=scipy.interpolate.RectBivariateSpline(v_phi,v_theta,m_r)
381+
sage: f=scipy.interpolate.RectBivariateSpline(v_phi,v_theta,m_r).ev
382382
sage: spherical_plot3d(f,(0,2*pi),(0,pi))
383383
Graphics3d Object
384384

0 commit comments

Comments
 (0)