wx.lib.floatcanvas: replace deprecated use of numpy float

This commit is contained in:
Scott Talbert
2021-12-30 14:17:23 -05:00
parent 7d1c8d44e0
commit b5ffe91c74
3 changed files with 71 additions and 71 deletions

View File

@@ -566,7 +566,7 @@ class XYObjectMixin:
array of shape (2, )
"""
Delta = N.asarray(Delta, N.float)
Delta = N.asarray(Delta, float)
self.XY += Delta
self.BoundingBox += Delta
@@ -579,7 +579,7 @@ class XYObjectMixin:
self.BoundingBox = BBox.asBBox((self.XY, self.XY))
def SetPoint(self, xy):
xy = N.array(xy, N.float)
xy = N.array(xy, float)
xy.shape = (2,)
self.XY = xy
@@ -603,7 +603,7 @@ class PointsObjectMixin:
array of shape (2, )
"""
Delta = N.asarray(Delta, N.float)
Delta = N.asarray(Delta, float)
Delta.shape = (2,)
self.Points += Delta
self.BoundingBox += Delta
@@ -637,10 +637,10 @@ class PointsObjectMixin:
"""
if copy:
self.Points = N.array(Points, N.float)
self.Points = N.array(Points, float)
self.Points.shape = (-1, 2) # Make sure it is a NX2 array, even if there is only one point
else:
self.Points = N.asarray(Points, N.float)
self.Points = N.asarray(Points, float)
self.CalcBoundingBox()
@@ -677,7 +677,7 @@ class Polygon(PointsObjectMixin, LineAndFillMixin, DrawObject):
"""
DrawObject.__init__(self, InForeground)
self.Points = N.array(Points ,N.float) # this DOES need to make a copy
self.Points = N.array(Points ,float) # this DOES need to make a copy
self.CalcBoundingBox()
self.LineColor = LineColor
@@ -728,7 +728,7 @@ class Line(PointsObjectMixin, LineOnlyMixin, DrawObject):
DrawObject.__init__(self, InForeground)
self.Points = N.array(Points,N.float)
self.Points = N.array(Points,float)
self.CalcBoundingBox()
self.LineColor = LineColor
@@ -805,7 +805,7 @@ class Arrow(XYObjectMixin, LineOnlyMixin, DrawObject):
DrawObject.__init__(self, InForeground)
self.XY = N.array(XY, N.float)
self.XY = N.array(XY, float)
self.XY.shape = (2,) # Make sure it is a length 2 vector
self.Length = Length
self.Direction = float(Direction)
@@ -865,10 +865,10 @@ class Arrow(XYObjectMixin, LineOnlyMixin, DrawObject):
## theta = (self.Direction-90.0) * N.pi / 180
## ArrowPoints = N.array( ( (0, L, L - S*N.cos(phi),L, L - S*N.cos(phi) ),
## (0, 0, S*N.sin(phi), 0, -S*N.sin(phi) ) ),
## N.float )
## float )
## RotationMatrix = N.array( ( ( N.cos(theta), -N.sin(theta) ),
## ( N.sin(theta), N.cos(theta) ) ),
## N.float
## float
## )
## ArrowPoints = N.matrixmultiply(RotationMatrix, ArrowPoints)
## self.ArrowPoints = N.transpose(ArrowPoints)
@@ -884,7 +884,7 @@ class Arrow(XYObjectMixin, LineOnlyMixin, DrawObject):
(N.cos(theta - phi), -N.sin(theta - phi) ),
(0,0),
(N.cos(theta + phi), -N.sin(theta + phi) ),
), N.float )
), float )
AP *= S
shift = (-L*N.cos(theta), L*N.sin(theta) )
AP[1:,:] += shift
@@ -934,7 +934,7 @@ class ArrowLine(PointsObjectMixin, LineOnlyMixin, DrawObject):
DrawObject.__init__(self, InForeground)
self.Points = N.asarray(Points,N.float)
self.Points = N.asarray(Points,float)
self.Points.shape = (-1,2) # Make sure it is a NX2 array, even if there is only one point
self.ArrowHeadSize = ArrowHeadSize
self.ArrowHeadAngle = float(ArrowHeadAngle)
@@ -956,7 +956,7 @@ class ArrowLine(PointsObjectMixin, LineOnlyMixin, DrawObject):
phi = self.ArrowHeadAngle * N.pi / 360
Points = self.Points
n = Points.shape[0]
self.ArrowPoints = N.zeros((n-1, 3, 2), N.float)
self.ArrowPoints = N.zeros((n-1, 3, 2), float)
for i in range(n-1):
dx, dy = self.Points[i] - self.Points[i+1]
theta = N.arctan2(dy, dx)
@@ -965,7 +965,7 @@ class ArrowLine(PointsObjectMixin, LineOnlyMixin, DrawObject):
(0,0),
(N.cos(theta + phi), -N.sin(theta + phi))
),
N.float )
float )
self.ArrowPoints[i,:,:] = AP
self.ArrowPoints *= S
@@ -1016,7 +1016,7 @@ class PointSet(PointsObjectMixin, ColorOnlyMixin, DrawObject):
"""
DrawObject.__init__(self, InForeground)
self.Points = N.array(Points,N.float)
self.Points = N.array(Points,float)
self.Points.shape = (-1,2) # Make sure it is a NX2 array, even if there is only one point
self.CalcBoundingBox()
self.Diameter = Diameter
@@ -1117,7 +1117,7 @@ class Point(XYObjectMixin, ColorOnlyMixin, DrawObject):
DrawObject.__init__(self, InForeground)
self.XY = N.array(XY, N.float)
self.XY = N.array(XY, float)
self.XY.shape = (2,) # Make sure it is a length 2 vector
self.CalcBoundingBox()
self.SetColor(Color)
@@ -1174,7 +1174,7 @@ class SquarePoint(XYObjectMixin, ColorOnlyMixin, DrawObject):
"""
DrawObject.__init__(self, InForeground)
self.XY = N.array(Point, N.float)
self.XY = N.array(Point, float)
self.XY.shape = (2,) # Make sure it is a length 2 vector
self.CalcBoundingBox()
self.SetColor(Color)
@@ -1262,16 +1262,16 @@ class RectEllipse(XYObjectMixin, LineAndFillMixin, DrawObject):
:param `WH`: a tuple with the Width and Height for the object
"""
self.XY = N.array( XY, N.float)
self.XY = N.array( XY, float)
self.XY.shape = (2,)
self.WH = N.array( WH, N.float)
self.WH = N.array( WH, float)
self.WH.shape = (2,)
self.CalcBoundingBox()
def CalcBoundingBox(self):
"""Calculate the bounding box."""
# you need this in case Width or Height are negative
corners = N.array((self.XY, (self.XY + self.WH) ), N.float)
corners = N.array((self.XY, (self.XY + self.WH) ), float)
self.BoundingBox = BBox.fromPoints(corners)
if self._Canvas:
self._Canvas.BoundingBoxDirty = True
@@ -1329,8 +1329,8 @@ class Circle(XYObjectMixin, LineAndFillMixin, DrawObject):
"""
DrawObject.__init__(self, InForeground)
self.XY = N.array(XY, N.float)
self.WH = N.array((Diameter/2, Diameter/2), N.float) # just to keep it compatible with others
self.XY = N.array(XY, float)
self.WH = N.array((Diameter/2, Diameter/2), float) # just to keep it compatible with others
self.CalcBoundingBox()
self.LineColor = LineColor
@@ -1355,7 +1355,7 @@ class Circle(XYObjectMixin, LineAndFillMixin, DrawObject):
:param integer `Diameter`: the diameter for the object
"""
self.WH = N.array((Diameter/2, Diameter/2), N.float) # just to keep it compatible with others
self.WH = N.array((Diameter/2, Diameter/2), float) # just to keep it compatible with others
def CalcBoundingBox(self):
"""Calculate the bounding box of the object."""
@@ -1633,7 +1633,7 @@ class ScaledText(TextObjectMixin, DrawObject):
DrawObject.__init__(self,InForeground)
self.String = String
self.XY = N.array( XY, N.float)
self.XY = N.array( XY, float)
self.XY.shape = (2,)
self.Size = Size
self.Color = Color
@@ -1810,7 +1810,7 @@ class ScaledTextBox(TextObjectMixin, DrawObject):
"""
DrawObject.__init__(self,InForeground)
self.XY = N.array(Point, N.float)
self.XY = N.array(Point, float)
self.Size = Size
self.Color = Color
self.BackgroundColor = BackgroundColor
@@ -1926,7 +1926,7 @@ class ScaledTextBox(TextObjectMixin, DrawObject):
SpaceWidth = dc.GetTextExtent(" ")[0]
LineHeight = TextHeight * self.LineSpacing
LineWidths = N.zeros((len(self.Strings),), N.float)
LineWidths = N.zeros((len(self.Strings),), float)
y = 0
Words = []
AllLinePoints = []
@@ -1934,7 +1934,7 @@ class ScaledTextBox(TextObjectMixin, DrawObject):
for i, s in enumerate(self.Strings):
LineWidths[i] = 0
LineWords = s.split(" ")
LinePoints = N.zeros((len(LineWords),2), N.float)
LinePoints = N.zeros((len(LineWords),2), float)
for j, word in enumerate(LineWords):
if j > 0:
LineWidths[i] += SpaceWidth
@@ -1951,7 +1951,7 @@ class ScaledTextBox(TextObjectMixin, DrawObject):
BoxWidth = TextWidth * ScaleFactor + 2*self.PadSize
else: # use the defined Width
BoxWidth = self.Width
Points = N.zeros((0,2), N.float)
Points = N.zeros((0,2), float)
for i, LinePoints in enumerate(AllLinePoints):
## Scale to World Coords.
@@ -2225,7 +2225,7 @@ class ScaledBitmap2(TextObjectMixin, DrawObject, ):
elif type(Bitmap) == wx.Image:
self.Image = Bitmap
self.XY = N.array(XY, N.float)
self.XY = N.array(XY, float)
self.Height = Height
(self.bmpWidth, self.bmpHeight) = float(self.Image.GetWidth()), float(self.Image.GetHeight())
self.bmpWH = N.array((self.bmpWidth, self.bmpHeight), N.int32)
@@ -2233,7 +2233,7 @@ class ScaledBitmap2(TextObjectMixin, DrawObject, ):
if Width is None:
self.BmpScale = float(self.bmpHeight) / Height
self.Width = self.bmpWidth / self.BmpScale
self.WH = N.array((self.Width, Height), N.float)
self.WH = N.array((self.Width, Height), float)
##fixme: should this have a y = -1 to shift to y-up?
self.BmpScale = self.bmpWH / self.WH
@@ -2388,7 +2388,7 @@ class DotGrid:
"""
def __init__(self, Spacing, Size = 2, Color = "Black", Cross=False, CrossThickness = 1):
self.Spacing = N.array(Spacing, N.float)
self.Spacing = N.array(Spacing, float)
self.Spacing.shape = (2,)
self.Size = Size
self.Color = Color
@@ -2406,7 +2406,7 @@ class DotGrid:
##fixme: this could use vstack or something with numpy
x = N.arange(minx, maxx+Spacing[0], Spacing[0]) # making sure to get the last point
y = N.arange(miny, maxy+Spacing[1], Spacing[1]) # an extra is OK
Points = N.zeros((len(y), len(x), 2), N.float)
Points = N.zeros((len(y), len(x), 2), float)
x.shape = (1,-1)
y.shape = (-1,1)
Points[:,:,0] += x
@@ -2501,12 +2501,12 @@ class Arc(XYObjectMixin, LineAndFillMixin, DrawObject):
XY = [minX,minY]
WH = [maxX-minX,maxY-minY]
self.XY = N.asarray( XY, N.float).reshape((2,))
self.WH = N.asarray( WH, N.float).reshape((2,))
self.XY = N.asarray( XY, float).reshape((2,))
self.WH = N.asarray( WH, float).reshape((2,))
self.StartXY = N.asarray(StartXY, N.float).reshape((2,))
self.CenterXY = N.asarray(CenterXY, N.float).reshape((2,))
self.EndXY = N.asarray(EndXY, N.float).reshape((2,))
self.StartXY = N.asarray(StartXY, float).reshape((2,))
self.CenterXY = N.asarray(CenterXY, float).reshape((2,))
self.EndXY = N.asarray(EndXY, float).reshape((2,))
#self.BoundingBox = array((self.XY, (self.XY + self.WH)), Float)
self.CalcBoundingBox()
@@ -2532,7 +2532,7 @@ class Arc(XYObjectMixin, LineAndFillMixin, DrawObject):
"""
Delta = N.asarray(Delta, N.float)
Delta = N.asarray(Delta, float)
self.XY += Delta
self.StartXY += Delta
self.CenterXY += Delta
@@ -2555,7 +2555,7 @@ class Arc(XYObjectMixin, LineAndFillMixin, DrawObject):
def CalcBoundingBox(self):
"""Calculate the bounding box."""
self.BoundingBox = BBox.asBBox( N.array((self.XY, (self.XY + self.WH) ),
N.float) )
float) )
if self._Canvas:
self._Canvas.BoundingBoxDirty = True
@@ -2604,9 +2604,9 @@ class PieChart(XYObjectMixin, LineOnlyMixin, DrawObject):
"""
DrawObject.__init__(self, InForeground)
self.XY = N.asarray(XY, N.float).reshape( (2,) )
self.XY = N.asarray(XY, float).reshape( (2,) )
self.Diameter = Diameter
self.Values = N.asarray(Values, dtype=N.float).reshape((-1,1))
self.Values = N.asarray(Values, dtype=float).reshape((-1,1))
if FillColors is None:
FillColors = self.DefaultColorList[:len(Values)]
if FillStyles is None:
@@ -2647,7 +2647,7 @@ class PieChart(XYObjectMixin, LineOnlyMixin, DrawObject):
:param `Values`: sequence of values you want to use for the chart
"""
Values = N.asarray(Values, dtype=N.float).reshape((-1,1))
Values = N.asarray(Values, dtype=float).reshape((-1,1))
self.Values = Values
self.CalculatePoints()
@@ -2684,7 +2684,7 @@ class PieChart(XYObjectMixin, LineOnlyMixin, DrawObject):
Diameter = ScaleWorldToPixel( (self.Diameter,self.Diameter) )[0]
else:
Diameter = self.Diameter
WH = N.array((Diameter,Diameter), dtype = N.float)
WH = N.array((Diameter,Diameter), dtype = float)
Corner = CenterXY - (WH / 2)
dc.SetPen(self.Pen)
for i, brush in enumerate(self.Brushes):