Fix NumPy 2.0 deprecations via running ruff (#2580)

* 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

* Use `numpy.any` instead of `any` because the latter does not work for multidimensional arrays.
This commit is contained in:
Randy Döring
2024-08-22 01:53:57 +02:00
committed by GitHub
parent 3901d05d40
commit f7d1d8188c
10 changed files with 22 additions and 22 deletions

View File

@@ -720,7 +720,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
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 BuildDrawFrame(): # this gets called when needed, rather than on import
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 BuildDrawFrame(): # this gets called when needed, rather than on import
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 BuildDrawFrame(): # this gets called when needed, rather than on import
)
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 BuildDrawFrame(): # this gets called when needed, rather than on import
)
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 BuildDrawFrame(): # this gets called when needed, rather than on import
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 BuildDrawFrame(): # this gets called when needed, rather than on import
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,

View File

@@ -160,7 +160,7 @@ class TriangleShape1(FC.Polygon, MovingObjectMixin):
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

View File

@@ -64,7 +64,7 @@ class TriangleShape1(FC.Polygon, ShapeMixin):
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 @@ class DrawFrame(wx.Frame):
Points = N.array(((0,0),
(1,0),
(0.5, 1)),
N.float_)
N.float64)
data = (( (0,0), 1),
( (3,3), 2),

View File

@@ -112,7 +112,7 @@ class DrawFrame(wx.Frame):
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]

View File

@@ -212,7 +212,7 @@ class TriangleShape1(FC.Polygon, MovingObjectMixin):
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

View File

@@ -188,7 +188,7 @@ class DrawFrame(wx.Frame):
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 @@ class DrawFrame(wx.Frame):
)
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 @@ class DrawFrame(wx.Frame):
)
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 @@ class DrawFrame(wx.Frame):
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 @@ class DrawFrame(wx.Frame):
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,

View File

@@ -204,7 +204,7 @@ class TriangleShape1(FC.Polygon, MovingObjectMixin):
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

View File

@@ -601,7 +601,7 @@ class FloatCanvas(wx.Panel):
"""
if N.sometrue(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()
@@ -779,7 +779,7 @@ class FloatCanvas(wx.Panel):
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!

View File

@@ -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])

View File

@@ -2044,7 +2044,7 @@ class PlotCanvas(wx.Panel):
"""
if self.last_PointLabel is not None:
# compare pointXY
if np.sometrue(
if np.any(
mDataDict["pointXY"] != self.last_PointLabel["pointXY"]):
# closest changed
self._drawPointLabel(self.last_PointLabel) # erase old