1
0
python-wxPython/Phoenix-pr2580+2591+2592-numpy2.patch
Jan Engelhardt 1f059e8999 - Add Phoenix-pr2580+2591+2592-numpy2.patch
* gh#wxWidgets/Phoenix#2580
  * gh#wxWidgets/Phoenix#2591
- Update multibuild
  * Finalize preparation for python313
  * Drop obsolete python39

OBS-URL: https://build.opensuse.org/package/show/X11:wxWidgets/python-wxPython?expand=0&rev=57
2024-08-30 00:55:16 +00:00

383 lines
17 KiB
Diff

From fa9050f865855392e8fa2bc95d53ade24d06e049 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Randy=20D=C3=B6ring?=
<30527984+radoering@users.noreply.github.com>
Date: Fri, 19 Jul 2024 18:00:02 +0200
Subject: [PATCH 1/2] Fix NumPy 2.0 deprecations via running `ruff check
--select NPY201 --fix --exclude
docs/sphinx/rest_substitutions/snippets/python/converted`
See https://numpy.org/devdocs/numpy_2_0_migration_guide.html#numpy-2-0-migration-guide
---
demo/FloatCanvas.py | 14 +++++++-------
samples/floatcanvas/MovingElements.py | 2 +-
samples/floatcanvas/MovingTriangle.py | 4 ++--
samples/floatcanvas/PolyEditor.py | 2 +-
samples/floatcanvas/ProcessDiagram.py | 2 +-
samples/floatcanvas/TextBox.py | 10 +++++-----
samples/floatcanvas/Tree.py | 2 +-
wx/lib/floatcanvas/FloatCanvas.py | 4 ++--
wx/lib/plot/examples/demo.py | 2 +-
wx/lib/plot/plotcanvas.py | 2 +-
10 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/demo/FloatCanvas.py b/demo/FloatCanvas.py
index 48d971cf3..f797340de 100644
--- a/demo/FloatCanvas.py
+++ b/demo/FloatCanvas.py
@@ -720,7 +720,7 @@ def TestHitTest(self, event=None):
x += dx
color = "SEA GREEN"
- Points = N.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), N.float_)
+ Points = N.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), N.float64)
R = Canvas.AddPolygon(Points, LineWidth = 2, FillColor = color)
R.Name = color + " Polygon"
R.Bind(FloatCanvas.EVT_FC_RIGHT_DOWN, self.RectGotHitRight)
@@ -729,7 +729,7 @@ def TestHitTest(self, event=None):
x += dx
color = "Red"
- Points = N.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), N.float_)
+ Points = N.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), N.float64)
R = Canvas.AddPointSet(Points, Diameter = 4, Color = color)
R.Name = "PointSet"
R.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.PointSetGotHit)
@@ -1139,7 +1139,7 @@ def TestScaledTextBox(self, event= None):
Family = wx.FONTFAMILY_ROMAN,
Alignment = "right"
)
- Point = N.array((100, -20), N.float_)
+ Point = N.array((100, -20), N.float64)
Box = Canvas.AddScaledTextBox("Here is even more auto wrapped text. This time the line spacing is set to 0.8. \n\nThe Padding is set to 0.",
Point,
Size = 3,
@@ -1153,7 +1153,7 @@ def TestScaledTextBox(self, event= None):
)
Canvas.AddPoint(Point, "Red", 2)
- Point = N.array((0, -40), N.float_)
+ Point = N.array((0, -40), N.float64)
# Point = N.array((0, 0), N.float_)
for Position in ["tl", "bl", "tr", "br"]:
# for Position in ["br"]:
@@ -1172,7 +1172,7 @@ def TestScaledTextBox(self, event= None):
)
Canvas.AddPoint(Point, "Red", 4)
- Point = N.array((-20, 60), N.float_)
+ Point = N.array((-20, 60), N.float64)
Box = Canvas.AddScaledTextBox("Here is some\ncentered\ntext",
Point,
Size = 4,
@@ -1188,7 +1188,7 @@ def TestScaledTextBox(self, event= None):
LineSpacing = 0.8
)
- Point = N.array((-20, 20), N.float_)
+ Point = N.array((-20, 20), N.float64)
Box = Canvas.AddScaledTextBox("Here is some\nright aligned\ntext",
Point,
Size = 4,
@@ -1203,7 +1203,7 @@ def TestScaledTextBox(self, event= None):
LineSpacing = 0.8
)
- Point = N.array((100, -60), N.float_)
+ Point = N.array((100, -60), N.float64)
Box = Canvas.AddScaledTextBox("Here is some auto wrapped text. This time it is centered, rather than right aligned.\n\nThe Padding is set to 2.",
Point,
Size = 3,
diff --git a/samples/floatcanvas/MovingElements.py b/samples/floatcanvas/MovingElements.py
index 40db28585..75229c07d 100644
--- a/samples/floatcanvas/MovingElements.py
+++ b/samples/floatcanvas/MovingElements.py
@@ -160,7 +160,7 @@ def CompPoints(self, XY, L):
Points = N.array(((0, c),
( L/2.0, -c/2.0),
(-L/2.0, -c/2.0)),
- N.float_)
+ N.float64)
Points += XY
return Points
diff --git a/samples/floatcanvas/MovingTriangle.py b/samples/floatcanvas/MovingTriangle.py
index f3277f212..822662467 100644
--- a/samples/floatcanvas/MovingTriangle.py
+++ b/samples/floatcanvas/MovingTriangle.py
@@ -64,7 +64,7 @@ def CompPoints(self, XY, L):
Points = N.array(((0, c),
( L/2.0, -c/2.0),
(-L/2.0, -c/2.0)),
- N.float_)
+ N.float64)
Points += XY
return Points
@@ -104,7 +104,7 @@ def __init__(self,parent, id,title,position,size):
Points = N.array(((0,0),
(1,0),
(0.5, 1)),
- N.float_)
+ N.float64)
data = (( (0,0), 1),
( (3,3), 2),
diff --git a/samples/floatcanvas/PolyEditor.py b/samples/floatcanvas/PolyEditor.py
index 55b1af429..270daa835 100644
--- a/samples/floatcanvas/PolyEditor.py
+++ b/samples/floatcanvas/PolyEditor.py
@@ -112,7 +112,7 @@ def OnMove(self, event):
dc.SetPen(wx.Pen('WHITE', 2, wx.SHORT_DASH))
dc.SetLogicalFunction(wx.XOR)
if self.SelectedPointNeighbors is None:
- self.SelectedPointNeighbors = N.zeros((3,2), N.float_)
+ self.SelectedPointNeighbors = N.zeros((3,2), N.float64)
#fixme: This feels very inelegant!
if Index == 0:
self.SelectedPointNeighbors[0] = self.SelectedPoly.Points[-1]
diff --git a/samples/floatcanvas/ProcessDiagram.py b/samples/floatcanvas/ProcessDiagram.py
index cf8609055..f67f89550 100644
--- a/samples/floatcanvas/ProcessDiagram.py
+++ b/samples/floatcanvas/ProcessDiagram.py
@@ -212,7 +212,7 @@ def CompPoints(self, XY, L):
Points = N.array(((0, c),
( L/2.0, -c/2.0),
(-L/2.0, -c/2.0)),
- N.float_)
+ N.float64)
Points += XY
return Points
diff --git a/samples/floatcanvas/TextBox.py b/samples/floatcanvas/TextBox.py
index 5badeb1d0..29db917c9 100644
--- a/samples/floatcanvas/TextBox.py
+++ b/samples/floatcanvas/TextBox.py
@@ -188,7 +188,7 @@ def __init__(self,parent, id,title,position,size):
Family = wx.ROMAN,
Alignment = "right"
)
- Point = N.array((100, -20), N.float_)
+ Point = N.array((100, -20), N.float64)
Box = Canvas.AddScaledTextBox("Here is even more auto wrapped text. This time the line spacing is set to 0.8. \n\nThe Padding is set to 0.",
Point,
Size = 3,
@@ -202,7 +202,7 @@ def __init__(self,parent, id,title,position,size):
)
Canvas.AddPoint(Point, "Red", 2)
- Point = N.array((0, -40), N.float_)
+ Point = N.array((0, -40), N.float64)
# Point = N.array((0, 0), N.float_)
for Position in ["tl", "bl", "tr", "br"]:
# for Position in ["br"]:
@@ -221,7 +221,7 @@ def __init__(self,parent, id,title,position,size):
)
Canvas.AddPoint(Point, "Red", 4)
- Point = N.array((-20, 60), N.float_)
+ Point = N.array((-20, 60), N.float64)
Box = Canvas.AddScaledTextBox("Here is some\ncentered\ntext",
Point,
Size = 4,
@@ -237,7 +237,7 @@ def __init__(self,parent, id,title,position,size):
LineSpacing = 0.8
)
- Point = N.array((-20, 20), N.float_)
+ Point = N.array((-20, 20), N.float64)
Box = Canvas.AddScaledTextBox("Here is some\nright aligned\ntext",
Point,
Size = 4,
@@ -252,7 +252,7 @@ def __init__(self,parent, id,title,position,size):
LineSpacing = 0.8
)
- Point = N.array((100, -60), N.float_)
+ Point = N.array((100, -60), N.float64)
Box = Canvas.AddScaledTextBox("Here is some auto wrapped text. This time it is centered, rather than right aligned.\n\nThe Padding is set to 2.",
Point,
Size = 3,
diff --git a/samples/floatcanvas/Tree.py b/samples/floatcanvas/Tree.py
index 7757651f5..4c75ac6af 100644
--- a/samples/floatcanvas/Tree.py
+++ b/samples/floatcanvas/Tree.py
@@ -204,7 +204,7 @@ def CompPoints(self, XY, L):
Points = N.array(((0, c),
( L/2.0, -c/2.0),
(-L/2.0, -c/2.0)),
- N.float_)
+ N.float64)
Points += XY
return Points
diff --git a/wx/lib/floatcanvas/FloatCanvas.py b/wx/lib/floatcanvas/FloatCanvas.py
index a0c316cd3..7e0d5a4b3 100644
--- a/wx/lib/floatcanvas/FloatCanvas.py
+++ b/wx/lib/floatcanvas/FloatCanvas.py
@@ -601,7 +601,7 @@ def Draw(self, Force=False):
"""
- if N.sometrue(self.PanelSize <= 2 ):
+ if any(self.PanelSize <= 2 ):
# it's possible for this to get called before being properly initialized.
return
if self.Debug: start = clock()
@@ -779,7 +779,7 @@ def ZoomToBB(self, NewBB=None, DrawFlag=True):
BoundingBox = self.BoundingBox
if (BoundingBox is not None) and (not BoundingBox.IsNull()):
self.ViewPortCenter = N.array(((BoundingBox[0,0]+BoundingBox[1,0])/2,
- (BoundingBox[0,1]+BoundingBox[1,1])/2 ),N.float_)
+ (BoundingBox[0,1]+BoundingBox[1,1])/2 ),N.float64)
self.MapProjectionVector = self.ProjectionFun(self.ViewPortCenter)
# Compute the new Scale
BoundingBox = BoundingBox*self.MapProjectionVector # this does need to make a copy!
diff --git a/wx/lib/plot/examples/demo.py b/wx/lib/plot/examples/demo.py
index 74312b772..ce1767b19 100644
--- a/wx/lib/plot/examples/demo.py
+++ b/wx/lib/plot/examples/demo.py
@@ -231,7 +231,7 @@ def _draw8Objects():
"""
Box plot
"""
- data1 = np.array([np.NaN, 337, 607, 583, 512, 531, 558, 381, 621, 574,
+ data1 = np.array([np.nan, 337, 607, 583, 512, 531, 558, 381, 621, 574,
538, 577, 679, 415, 454, 417, 635, 319, 350, 183,
863, 337, 607, 583, 512, 531, 558, 381, 621, 574,
538, 577, 679, 415, 454, 417, 635, 319, 350, 97])
diff --git a/wx/lib/plot/plotcanvas.py b/wx/lib/plot/plotcanvas.py
index 0e1e8a0e2..34ef5f02b 100644
--- a/wx/lib/plot/plotcanvas.py
+++ b/wx/lib/plot/plotcanvas.py
@@ -2044,7 +2044,7 @@ def UpdatePointLabel(self, mDataDict):
"""
if self.last_PointLabel is not None:
# compare pointXY
- if np.sometrue(
+ if any(
mDataDict["pointXY"] != self.last_PointLabel["pointXY"]):
# closest changed
self._drawPointLabel(self.last_PointLabel) # erase old
From 4e09cda937140d3c41b39830c55a272943f36aea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Randy=20D=C3=B6ring?=
<30527984+radoering@users.noreply.github.com>
Date: Sat, 20 Jul 2024 07:46:26 +0200
Subject: [PATCH 2/2] Use `numpy.any` instead of `any` because the latter does
not work for multidimensional arrays.
---
wx/lib/floatcanvas/FloatCanvas.py | 2 +-
wx/lib/plot/plotcanvas.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/wx/lib/floatcanvas/FloatCanvas.py b/wx/lib/floatcanvas/FloatCanvas.py
index 7e0d5a4b3..ebdd689fb 100644
--- a/wx/lib/floatcanvas/FloatCanvas.py
+++ b/wx/lib/floatcanvas/FloatCanvas.py
@@ -601,7 +601,7 @@ def Draw(self, Force=False):
"""
- if any(self.PanelSize <= 2 ):
+ if N.any(self.PanelSize <= 2 ):
# it's possible for this to get called before being properly initialized.
return
if self.Debug: start = clock()
diff --git a/wx/lib/plot/plotcanvas.py b/wx/lib/plot/plotcanvas.py
index 34ef5f02b..b9f65d8db 100644
--- a/wx/lib/plot/plotcanvas.py
+++ b/wx/lib/plot/plotcanvas.py
@@ -2044,7 +2044,7 @@ def UpdatePointLabel(self, mDataDict):
"""
if self.last_PointLabel is not None:
# compare pointXY
- if any(
+ if np.any(
mDataDict["pointXY"] != self.last_PointLabel["pointXY"]):
# closest changed
self._drawPointLabel(self.last_PointLabel) # erase old
From 3871204fd00e821c0ab3a67ec48afde6155b5222 Mon Sep 17 00:00:00 2001
From: Steve Kowalik <steven@wedontsleep.org>
Date: Thu, 29 Aug 2024 15:05:41 +1000
Subject: [PATCH] Replace N.alltrue() with N.all()
Building on the excellent work in f7d1d818, replace the two uses of
N.alltrue() with N.all(), since the former has been removed in numpy
2.0.
---
unittests/test_lib_floatcanvas_bbox.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/unittests/test_lib_floatcanvas_bbox.py b/unittests/test_lib_floatcanvas_bbox.py
index 42ced9c83..11d159534 100644
--- a/unittests/test_lib_floatcanvas_bbox.py
+++ b/unittests/test_lib_floatcanvas_bbox.py
@@ -460,7 +460,7 @@ class testNullBBox(wtc.WidgetTestCase):
B3 = BBox( ( (1.0, 2.0), (5.0, 10.0) ) )
def testValues(self):
- self.assertTrue( N.alltrue(N.isnan(self.B1)) )
+ self.assertTrue( N.all(N.isnan(self.B1)) )
def testIsNull(self):
self.assertTrue( self.B1.IsNull )
@@ -496,7 +496,7 @@ class testInfBBox(wtc.WidgetTestCase):
NB = NullBBox()
def testValues(self):
- self.assertTrue( N.alltrue(N.isinf(self.B1)) )
+ self.assertTrue( N.all(N.isinf(self.B1)) )
# def testIsNull(self):
# self.assertTrue( self.B1.IsNull )
From ad8135462c7d140590e28fc37f9e6cbc263e5b0c Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
Date: Thu, 29 Aug 2024 12:27:09 +0200
Subject: [PATCH] replace old numpy types no longer valid in numpy 2
---
unittests/test_lib_floatcanvas_bbox.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/unittests/test_lib_floatcanvas_bbox.py b/unittests/test_lib_floatcanvas_bbox.py
index 42ced9c83..35630a452 100644
--- a/unittests/test_lib_floatcanvas_bbox.py
+++ b/unittests/test_lib_floatcanvas_bbox.py
@@ -30,7 +30,7 @@ def testShape3(self):
self.assertRaises(ValueError, BBox, (0,0,5,6,7) )
def testArrayConstruction(self):
- A = N.array(((4,5),(10,12)), N.float_)
+ A = N.array(((4,5),(10,12)), N.float64)
B = BBox(A)
self.assertTrue(isinstance(B, BBox))
@@ -79,7 +79,7 @@ def testPassArray(self):
def testPassArray2(self):
# same data type -- should be a view
- A = N.array( (((0,0),(5,5))), N.float_ )
+ A = N.array( (((0,0),(5,5))), N.float64 )
C = asBBox(A)
A[0,0] = -10
self.assertTrue(C[0,0] == A[0,0])
@@ -341,7 +341,7 @@ def testCreate(self):
Pts = N.array( ((5,2),
(3,4),
(1,6),
- ), N.float_ )
+ ), N.float64 )
B = fromPoints(Pts)
#B = BBox( ( (1.0, 2.0), (5.0, 10.0) ) )
self.assertTrue(B[0,0] == 1.0 and
@@ -362,7 +362,7 @@ def testCreateInts(self):
)
def testSinglePoint(self):
- Pts = N.array( (5,2), N.float_ )
+ Pts = N.array( (5,2), N.float64 )
B = fromPoints(Pts)
self.assertTrue(B[0,0] == 5.0 and
B[0,1] == 2.0 and