Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

FloatCanvas triggers DeprecationWarning from Numpy 1.25.0 or later for 'sometrue'

Open reticulatus opened this issue 1 year ago • 0 comments

Operating system: Linux Mint 21.2 wxPython version & source: 4.2.1 from pypi Python version & source: 3.10.12 from distro Numpy version & source: 1.26.2 from pypi

Description of the problem:

I copied the code from the docs for the FloatCanvas package into a small test app (see example below).

When I ran the app, it output the following warning:

/home/richardt/Development/python/exp/hci/wxpython/float_canvas/float_canvas_1.py:25: DeprecationWarning: `sometrue` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `any` instead.
  self.Canvas.Draw()

Line 604 in FloatCanvas.py for the FloatCanvas.Draw() method contains:

        if N.sometrue(self.PanelSize <= 2 ):

I did a recursive search of my wxPython 4.2.1 installation and found that sometrue also occurs in line 2047 of lib/plot/plotcanvas.py:

             if np.sometrue(
Code Example (click to expand)
import wx
from wx.lib.floatcanvas import FloatCanvas

class MyFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)

        self.Canvas = FloatCanvas.FloatCanvas(self, -1,
                                     size=(500, 500),
                                     ProjectionFun=None,
                                     Debug=0,
                                     BackgroundColor="White",
                                     )

        # add a circle
        cir = FloatCanvas.Circle((10, 10), 100)
        self.Canvas.AddObject(cir)

        # add a rectangle
        rect = FloatCanvas.Rectangle((110, 10), (100, 100), FillColor='Red')
        self.Canvas.AddObject(rect)

        self.Canvas.Draw()

app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()

reticulatus avatar Dec 16 '23 11:12 reticulatus