From 516539a7a0660a9a902e1415216eae3424f1ce8b Mon Sep 17 00:00:00 2001 From: Tim Riddermann Date: Tue, 28 Feb 2023 16:07:02 +0100 Subject: [PATCH] Since numpy 1.20 the aliases `np.int` and `np.float` are deprecated (see https://numpy.org/devdocs/release/1.20.0-notes.html#using-the-aliases-of-builtin-types-like-np-int-is-deprecated). The buildin types should be used instead. Since numpy 1.24 an AttributeError exception is thrown when `np.int` or `np.float` is used. --- samples/floatcanvas/BouncingBall.py | 4 ++-- samples/floatcanvas/PixelBitmap.py | 2 +- wx/lib/plot/polyobjects.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/floatcanvas/BouncingBall.py b/samples/floatcanvas/BouncingBall.py index 16d7a9ee..3cd90f26 100644 --- a/samples/floatcanvas/BouncingBall.py +++ b/samples/floatcanvas/BouncingBall.py @@ -21,7 +21,7 @@ if ver == 'installed': ## import the installed version from wx.lib.floatcanvas import FloatCanvas print("using installed version:", wx.lib.floatcanvas.__version__) elif ver == 'local': - ## import a local version + ## import a local version import sys sys.path.append("..") from floatcanvas import NavCanvas @@ -49,7 +49,7 @@ class MovingObjectMixin: # Borrowed from MovingElements.py class Ball(MovingObjectMixin, FloatCanvas.Circle): def __init__(self, XY, Velocity, Radius=2.0, **kwargs): - self.Velocity = np.asarray(Velocity, np.float).reshape((2,)) + self.Velocity = np.asarray(Velocity, float).reshape((2,)) self.Radius = Radius self.Moving = False FloatCanvas.Circle.__init__(self, XY, Diameter=Radius*2, FillColor="red", **kwargs) diff --git a/samples/floatcanvas/PixelBitmap.py b/samples/floatcanvas/PixelBitmap.py index 0e14cf03..9553caff 100644 --- a/samples/floatcanvas/PixelBitmap.py +++ b/samples/floatcanvas/PixelBitmap.py @@ -49,7 +49,7 @@ class PixelBitmap: else: raise FC.FloatCanvasError("PixelBitmap takes only a wx.Bitmap or a wx.Image as input") - self.XY = np.asarray(XY, dtype=np.int).reshape((2,)) + self.XY = np.asarray(XY, dtype=int).reshape((2,)) self.Position = Position (self.Width, self.Height) = self.Bitmap.GetWidth(), self.Bitmap.GetHeight() diff --git a/wx/lib/plot/polyobjects.py b/wx/lib/plot/polyobjects.py index 2937794a..be9ab831 100644 --- a/wx/lib/plot/polyobjects.py +++ b/wx/lib/plot/polyobjects.py @@ -616,7 +616,7 @@ class PolyMarker(PolyPoints): def _circle(self, dc, coords, size=1): fact = 2.5 * size wh = 5.0 * size - rect = np.zeros((len(coords), 4), np.float) + [0.0, 0.0, wh, wh] + rect = np.zeros((len(coords), 4), float) + [0.0, 0.0, wh, wh] rect[:, 0:2] = coords - [fact, fact] dc.DrawEllipseList(rect.astype(np.int32)) @@ -627,7 +627,7 @@ class PolyMarker(PolyPoints): def _square(self, dc, coords, size=1): fact = 2.5 * size wh = 5.0 * size - rect = np.zeros((len(coords), 4), np.float) + [0.0, 0.0, wh, wh] + rect = np.zeros((len(coords), 4), float) + [0.0, 0.0, wh, wh] rect[:, 0:2] = coords - [fact, fact] dc.DrawRectangleList(rect.astype(np.int32)) @@ -1199,7 +1199,7 @@ class PolyBoxPlot(PolyPoints): size = 0.5 fact = 2.5 * size wh = 5.0 * size - rect = np.zeros((len(pt_data), 4), np.float) + [0.0, 0.0, wh, wh] + rect = np.zeros((len(pt_data), 4), float) + [0.0, 0.0, wh, wh] rect[:, 0:2] = pt_data - [fact, fact] dc.DrawRectangleList(rect.astype(np.int32))