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

@@ -210,12 +210,12 @@ class FloatCanvas(wx.Panel):
self.BoundingBoxDirty = False
self.MinScale = None
self.MaxScale = None
self.ViewPortCenter= N.array( (0,0), N.float)
self.ViewPortCenter= N.array( (0,0), float)
self.SetProjectionFun(None)
self.MapProjectionVector = N.array( (1,1), N.float) # No Projection to start!
self.TransformVector = N.array( (1,-1), N.float) # default Transformation
self.MapProjectionVector = N.array( (1,1), float) # No Projection to start!
self.TransformVector = N.array( (1,-1), float) # default Transformation
self.Scale = 1
self.ObjectUnderMouse = None
@@ -239,7 +239,7 @@ class FloatCanvas(wx.Panel):
elif callable(ProjectionFun):
self.ProjectionFun = ProjectionFun
elif ProjectionFun is None:
self.ProjectionFun = lambda x=None: N.array( (1,1), N.float)
self.ProjectionFun = lambda x=None: N.array( (1,1), float)
else:
raise FloatCanvasError('Projectionfun must be either:'
' "FlatEarth", None, or a callable object '
@@ -262,7 +262,7 @@ class FloatCanvas(wx.Panel):
MinLatitude = -75
Lat = min(CenterPoint[1],MaxLatitude)
Lat = max(Lat,MinLatitude)
return N.array((N.cos(N.pi*Lat/180),1),N.float)
return N.array((N.cos(N.pi*Lat/180),1),float)
def SetMode(self, Mode):
"""
@@ -703,9 +703,9 @@ class FloatCanvas(wx.Panel):
============== ======================================================
"""
shift = N.asarray(shift,N.float)
shift = N.asarray(shift,float)
if CoordType.lower() == 'panel':# convert from panel coordinates
shift = shift * N.array((-1,1),N.float) *self.PanelSize/self.TransformVector
shift = shift * N.array((-1,1),float) *self.PanelSize/self.TransformVector
elif CoordType.lower() == 'pixel': # convert from pixel coordinates
shift = shift/self.TransformVector
elif CoordType.lower() == 'world': # No conversion
@@ -715,7 +715,7 @@ class FloatCanvas(wx.Panel):
self.ViewPortCenter = self.ViewPortCenter + shift
self.MapProjectionVector = self.ProjectionFun(self.ViewPortCenter)
self.TransformVector = N.array((self.Scale,-self.Scale),N.float) * self.MapProjectionVector
self.TransformVector = N.array((self.Scale,-self.Scale),float) * self.MapProjectionVector
self._BackgroundDirty = True
if ReDraw:
self.Draw()
@@ -745,7 +745,7 @@ class FloatCanvas(wx.Panel):
if centerCoords.lower() == "pixel":
oldpoint = self.PixelToWorld( center )
elif centerCoords.lower() == 'world':
oldpoint = N.array(center, N.float)
oldpoint = N.array(center, float)
else:
raise FloatCanvasError('centerCoords must be either "World" or "Pixel"')
@@ -756,7 +756,7 @@ class FloatCanvas(wx.Panel):
if centerCoords.lower() == "pixel":
newpoint = self.PixelToWorld( center )
else:
newpoint = N.array(center, N.float)
newpoint = N.array(center, float)
delta = (newpoint - oldpoint)
self.MoveImage(-delta, 'World')
else:
@@ -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 ),float_)
self.MapProjectionVector = self.ProjectionFun(self.ViewPortCenter)
# Compute the new Scale
BoundingBox = BoundingBox*self.MapProjectionVector # this does need to make a copy!
@@ -799,7 +799,7 @@ class FloatCanvas(wx.Panel):
self._BackgroundDirty = True
else:
# Reset the shifting and scaling to defaults when there is no BB
self.ViewPortCenter= N.array( (0,0), N.float)
self.ViewPortCenter= N.array( (0,0), float)
self.Scale= 1
self.SetToNewScale(DrawFlag=DrawFlag)
@@ -816,7 +816,7 @@ class FloatCanvas(wx.Panel):
if self.MaxScale is not None:
Scale = min(Scale, self.MaxScale)
self.MapProjectionVector = self.ProjectionFun(self.ViewPortCenter)
self.TransformVector = N.array((Scale,-Scale),N.float) * self.MapProjectionVector
self.TransformVector = N.array((Scale,-Scale),float) * self.MapProjectionVector
self.Scale = Scale
self._BackgroundDirty = True
if DrawFlag:
@@ -889,9 +889,9 @@ class FloatCanvas(wx.Panel):
SetToNull=True
if SetToNull:
self.BoundingBox = BBox.NullBBox()
self.ViewPortCenter= N.array( (0,0), N.float)
self.TransformVector = N.array( (1,-1), N.float)
self.MapProjectionVector = N.array( (1,1), N.float)
self.ViewPortCenter= N.array( (0,0), float)
self.TransformVector = N.array( (1,-1), float)
self.MapProjectionVector = N.array( (1,1), float)
self.Scale = 1
self.BoundingBoxDirty = False
@@ -903,7 +903,7 @@ class FloatCanvas(wx.Panel):
or a NX2 Numpy array of x,y coordinates.
"""
return (((N.asarray(Points, N.float) -
return (((N.asarray(Points, float) -
(self.PanelSize/2))/self.TransformVector) +
self.ViewPortCenter)
@@ -915,7 +915,7 @@ class FloatCanvas(wx.Panel):
a 2-tuple, or sequence of 2-tuples.
"""
#Note: this can be called by users code for various reasons, so N.asarray is needed.
return (((N.asarray(Coordinates,N.float) -
return (((N.asarray(Coordinates,float) -
self.ViewPortCenter)*self.TransformVector)+
(self.HalfPanelSize)).astype('i')
@@ -927,7 +927,7 @@ class FloatCanvas(wx.Panel):
Lengths should be a NX2 array of (x,y) coordinates, or
a 2-tuple, or sequence of 2-tuples.
"""
return ( (N.asarray(Lengths, N.float)*self.TransformVector) ).astype('i')
return ( (N.asarray(Lengths, float)*self.TransformVector) ).astype('i')
def ScalePixelToWorld(self,Lengths):
"""
@@ -937,7 +937,7 @@ class FloatCanvas(wx.Panel):
Lengths should be a NX2 array of (x,y) coordinates, or
a 2-tuple, or sequence of 2-tuples.
"""
return (N.asarray(Lengths,N.float) / self.TransformVector)
return (N.asarray(Lengths,float) / self.TransformVector)
def AddObject(self, obj):
"""