Commit 088291d8 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Replaced deprecated numpy data types as they are only aliases of the builtin data types.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 254bcd67
......@@ -90,13 +90,13 @@ def convertGdalNumpyDataType(dType):
for i in dTypeDic.items():
if dType == i[1]:
outdType = i[0]
elif dType in [np.int8, np.int64, np.int]:
elif dType in [np.int8, np.int64, int]:
outdType = "Int32"
print(">>> Warning: %s is converted to GDAL_Type 'Int_32'\n" % dType)
elif dType in [np.bool, np.bool_]:
elif dType in [bool, np.bool_]:
outdType = "Byte"
print(">>> Warning: %s is converted to GDAL_Type 'Byte'\n" % dType)
elif dType in [np.float]:
elif dType in [float]:
outdType = "Float32"
print(">>> Warning: %s is converted to GDAL_Type 'Float32'\n" % dType)
elif dType in [np.float16]:
......
......@@ -136,7 +136,7 @@ def mapXY2imXY(mapXY, gt):
if ndim == 1:
mapXY = mapXY.reshape(1, 2)
assert mapXY.shape[1] == 2, 'An array in shape [Nx2] is needed. Got shape %s.' % mapXY.shape
imXY = np.empty_like(mapXY, dtype=np.float)
imXY = np.empty_like(mapXY, dtype=float)
imXY[:, 0] = (mapXY[:, 0] - gt[0]) / gt[1]
imXY[:, 1] = (mapXY[:, 1] - gt[3]) / gt[5]
return imXY if ndim > 1 else imXY.flatten()
......@@ -158,7 +158,7 @@ def imXY2mapXY(imXY, gt):
if imXY.ndim == 1:
imXY = imXY.reshape(1, 2)
assert imXY.shape[1] == 2, 'An array in shape [Nx2] is needed. Got shape %s.' % imXY.shape
mapXY = np.empty_like(imXY, dtype=np.float)
mapXY = np.empty_like(imXY, dtype=float)
mapXY[:, 0] = gt[0] + imXY[:, 0] * abs(gt[1])
mapXY[:, 1] = gt[3] - imXY[:, 1] * abs(gt[5])
return mapXY if ndim > 1 else mapXY.flatten()
......
......@@ -59,7 +59,7 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
# downsample to half size, nearest neighbour
from skimage.transform import rescale # import here to avoid static TLS import error
array = rescale(array, zoom_factor, order=0, preserve_range=True, mode='edge').astype(np.bool)
array = rescale(array, zoom_factor, order=0, preserve_range=True, mode='edge').astype(bool)
# update pixel sizes within gt
gt = list(gt)
......
......@@ -82,6 +82,6 @@ def find_nearest(array, value, roundAlg='auto', extrapolate=False, exclude_val=F
inTol = diffs <= tolerance
if True in inTol:
out = array_sub[np.argwhere(inTol.astype(np.int) == 1)[0][0]]
out = array_sub[np.argwhere(inTol.astype(int) == 1)[0][0]]
return out
......@@ -87,7 +87,7 @@ class Test_get_GDAL_ds_inmem(TestCase):
self.assertIsInstance(ds, Dataset)
with self.assertRaises(TypeError):
ds = get_GDAL_ds_inmem(array=self.arr3d, gt=self.gt, prj=self.prj, nodata=np.array([0], dtype=np.bool))
ds = get_GDAL_ds_inmem(array=self.arr3d, gt=self.gt, prj=self.prj, nodata=np.array([0], dtype=bool))
self.assertIsInstance(ds, Dataset)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment