Skip to content

Commit

Permalink
Python code: Fix E127/E128 warnings. (OSGeo#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
bje- authored and rouault committed Apr 16, 2018
1 parent b2b5c1a commit ae0c5f6
Show file tree
Hide file tree
Showing 258 changed files with 6,032 additions and 6,033 deletions.
6 changes: 3 additions & 3 deletions autotest/alg/applyverticalshiftgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def applyverticalshiftgrid_2():
grid_ds.SetProjection(sr.ExportToWkt())
with gdaltest.error_handler():
out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds,
options=['BLOCKSIZE=2000000000'])
options=['BLOCKSIZE=2000000000'])
if out_ds is not None:
gdaltest.post_reason('fail')
return 'fail'
Expand Down Expand Up @@ -317,7 +317,7 @@ def applyverticalshiftgrid_4():
grid_ds.SetGeoTransform([10, 1, 0, 0, 0, -1])
grid_ds.SetProjection(sr.ExportToWkt())
out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds,
options=['ERROR_ON_MISSING_VERT_SHIFT=YES'])
options=['ERROR_ON_MISSING_VERT_SHIFT=YES'])
with gdaltest.error_handler():
data = out_ds.GetRasterBand(1).ReadRaster()
if data is not None:
Expand All @@ -334,7 +334,7 @@ def applyverticalshiftgrid_4():
grid_ds.SetProjection(sr.ExportToWkt())
grid_ds.GetRasterBand(1).SetNoDataValue(0)
out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds,
options=['ERROR_ON_MISSING_VERT_SHIFT=YES'])
options=['ERROR_ON_MISSING_VERT_SHIFT=YES'])
with gdaltest.error_handler():
data = out_ds.GetRasterBand(1).ReadRaster()
if data is not None:
Expand Down
18 changes: 9 additions & 9 deletions autotest/alg/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ def contour_1():
raw_data = array.array('h', [10 for i in range(int(size / 2))]).tostring()
for i in range(int(size / 2)):
ds.WriteRaster(int(size / 4), i + int(size / 4), int(size / 2), 1, raw_data,
buf_type=gdal.GDT_Int16,
band_list=[1])
buf_type=gdal.GDT_Int16,
band_list=[1])

raw_data = array.array('h', [20 for i in range(int(size / 2))]).tostring()
for i in range(int(size / 4)):
ds.WriteRaster(int(size / 4) + int(size / 8), i + int(size / 4) + int(size / 8), int(size / 4), 1, raw_data,
buf_type=gdal.GDT_Int16,
band_list=[1])
buf_type=gdal.GDT_Int16,
band_list=[1])

raw_data = array.array('h', [25 for i in range(int(size / 4))]).tostring()
for i in range(int(size / 8)):
ds.WriteRaster(int(size / 4) + int(size / 8) + int(size / 16), i + int(size / 4) + int(size / 8) + int(size / 16), int(size / 8), 1, raw_data,
buf_type=gdal.GDT_Int16,
band_list=[1])
buf_type=gdal.GDT_Int16,
band_list=[1])

ogr_ds = ogr.GetDriverByName('ESRI Shapefile').CreateDataSource('tmp/contour.shp')
ogr_lyr = ogr_ds.CreateLayer('contour')
Expand All @@ -97,7 +97,7 @@ def contour_1():
ds = None

expected_envelopes = [[1.25, 1.75, 49.25, 49.75],
[1.25 + 0.125, 1.75 - 0.125, 49.25 + 0.125, 49.75 - 0.125]]
[1.25 + 0.125, 1.75 - 0.125, 49.25 + 0.125, 49.75 - 0.125]]
expected_height = [10, 20]

lyr = ogr_ds.ExecuteSQL("select * from contour order by elev asc")
Expand Down Expand Up @@ -162,8 +162,8 @@ def contour_2():
precision = 1. / size

expected_envelopes = [[1.25, 1.75, 49.25, 49.75],
[1.25 + 0.125, 1.75 - 0.125, 49.25 + 0.125, 49.75 - 0.125],
[1.25 + 0.125 + 0.0625, 1.75 - 0.125 - 0.0625, 49.25 + 0.125 + 0.0625, 49.75 - 0.125 - 0.0625]]
[1.25 + 0.125, 1.75 - 0.125, 49.25 + 0.125, 49.75 - 0.125],
[1.25 + 0.125 + 0.0625, 1.75 - 0.125 - 0.0625, 49.25 + 0.125 + 0.0625, 49.75 - 0.125 - 0.0625]]
expected_height = [10, 20, 25]

lyr = ogr_ds.ExecuteSQL("select * from contour order by elev asc")
Expand Down
6 changes: 3 additions & 3 deletions autotest/alg/polygonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def polygonize_1(is_int_polygonize=True):
return 'fail'

expect = [107, 123, 115, 115, 140, 148, 123, 140, 156,
100, 101, 102, 103]
100, 101, 102, 103]

tr = ogrtest.check_features_against_list(mem_layer, 'DN', expect)

Expand Down Expand Up @@ -126,7 +126,7 @@ def polygonize_2():
return 'fail'

expect = [107, 123, 115, 132, 115, 132, 140, 132, 148, 123, 140,
132, 156, 100, 101, 102, 103]
132, 156, 100, 101, 102, 103]

tr = ogrtest.check_features_against_list(mem_layer, 'DN', expect)

Expand Down Expand Up @@ -213,7 +213,7 @@ def polygonize_4():
return 'fail'

expect = [107, 123, 132, 115, 132, 115, 140, 148,
123, 140, 132, 156, 100, 101, 102, 103]
123, 140, 132, 156, 100, 101, 102, 103]

tr = ogrtest.check_features_against_list(mem_layer, 'DN', expect)

Expand Down
14 changes: 7 additions & 7 deletions autotest/alg/proximity.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def proximity_2():
dst_band = dst_ds.GetRasterBand(1)

gdal.ComputeProximity(src_band, dst_band,
options=['VALUES=65,64',
'MAXDIST=12',
'NODATA=-1',
'FIXED_BUF_VAL=255'])
options=['VALUES=65,64',
'MAXDIST=12',
'NODATA=-1',
'FIXED_BUF_VAL=255'])

cs_expected = 3256
cs = dst_band.Checksum()
Expand Down Expand Up @@ -119,9 +119,9 @@ def proximity_3():

gdal.ComputeProximity(src_band, dst_band,
options=['VALUES=65,64',
'MAXDIST=12',
'USE_INPUT_NODATA=YES',
'NODATA=0'])
'MAXDIST=12',
'USE_INPUT_NODATA=YES',
'NODATA=0'])

cs_expected = 1465
cs = dst_band.Checksum()
Expand Down
32 changes: 16 additions & 16 deletions autotest/alg/rasterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def rasterize_1():
# Create a memory raster to rasterize into.

target_ds = gdal.GetDriverByName('MEM').Create('', 100, 100, 3,
gdal.GDT_Byte)
gdal.GDT_Byte)
target_ds.SetGeoTransform((1000, 1, 0, 1100, 0, -1))
target_ds.SetProjection(sr_wkt)

# Create a memory layer to rasterize from.

rast_ogr_ds = \
ogr.GetDriverByName('Memory').CreateDataSource('wrk')
ogr.GetDriverByName('Memory').CreateDataSource('wrk')
rast_mem_lyr = rast_ogr_ds.CreateLayer('poly', srs=sr)

# Add a polygon.
Expand All @@ -82,7 +82,7 @@ def rasterize_1():
# Run the algorithm.

err = gdal.RasterizeLayer(target_ds, [3, 2, 1], rast_mem_lyr,
burn_values=[200, 220, 240])
burn_values=[200, 220, 240])

if err != 0:
print(err)
Expand Down Expand Up @@ -114,7 +114,7 @@ def rasterize_2():
# Create a memory raster to rasterize into.

target_ds = gdal.GetDriverByName('MEM').Create('', 12, 12, 3,
gdal.GDT_Byte)
gdal.GDT_Byte)
target_ds.SetGeoTransform((0, 1, 0, 12, 0, -1))
target_ds.SetProjection(sr_wkt)

Expand All @@ -126,8 +126,8 @@ def rasterize_2():

gdal.PushErrorHandler('CPLQuietErrorHandler')
err = gdal.RasterizeLayer(target_ds, [3, 2, 1], cutline_ds.GetLayer(0),
burn_values=[200, 220, 240],
options=["ALL_TOUCHED=TRUE"])
burn_values=[200, 220, 240],
options=["ALL_TOUCHED=TRUE"])
gdal.PopErrorHandler()

if err != 0:
Expand Down Expand Up @@ -161,14 +161,14 @@ def rasterize_3():
# Create a memory raster to rasterize into.

target_ds = gdal.GetDriverByName('MEM').Create('', 100, 100, 3,
gdal.GDT_Byte)
gdal.GDT_Byte)
target_ds.SetGeoTransform((1000, 1, 0, 1100, 0, -1))
target_ds.SetProjection(sr_wkt)

# Create a memory layer to rasterize from.

rast_ogr_ds = \
ogr.GetDriverByName('Memory').CreateDataSource('wrk')
ogr.GetDriverByName('Memory').CreateDataSource('wrk')
rast_mem_lyr = rast_ogr_ds.CreateLayer('poly', srs=sr)

# Add polygons and linestrings.
Expand All @@ -185,7 +185,7 @@ def rasterize_3():
# Run the algorithm.

err = gdal.RasterizeLayer(target_ds, [3, 2, 1], rast_mem_lyr,
burn_values=[10, 10, 55], options=["BURN_VALUE_FROM=Z"])
burn_values=[10, 10, 55], options=["BURN_VALUE_FROM=Z"])

if err != 0:
print(err)
Expand Down Expand Up @@ -216,7 +216,7 @@ def rasterize_4():

# Create a memory raster to rasterize into.
target_ds = gdal.GetDriverByName('MEM').Create('', 100, 100, 3,
gdal.GDT_Byte)
gdal.GDT_Byte)
target_ds.SetGeoTransform((1000, 1, 0, 1100, 0, -1))
target_ds.SetProjection(sr_wkt)

Expand All @@ -225,7 +225,7 @@ def rasterize_4():
rast_mem_lyr = rast_ogr_ds.CreateLayer('poly', srs=sr)
# Setup Schema
ogrtest.quick_create_layer_def(rast_mem_lyr,
[('CELSIUS', ogr.OFTReal)])
[('CELSIUS', ogr.OFTReal)])

# Add polygons and linestrings and a field named CELSIUS.
wkt_geom = ['POLYGON((1020 1030 40,1020 1045 30,1050 1045 20,1050 1030 35,1020 1030 40))',
Expand All @@ -245,7 +245,7 @@ def rasterize_4():

# Run the algorithm.
err = gdal.RasterizeLayer(target_ds, [1, 2, 3], rast_mem_lyr,
options=["ATTRIBUTE=CELSIUS"])
options=["ATTRIBUTE=CELSIUS"])

if err != 0:
print(err)
Expand Down Expand Up @@ -276,14 +276,14 @@ def rasterize_5():
# Create a memory raster to rasterize into.

target_ds = gdal.GetDriverByName('MEM').Create('', 100, 100, 3,
gdal.GDT_Byte)
gdal.GDT_Byte)
target_ds.SetGeoTransform((1000, 1, 0, 1100, 0, -1))
target_ds.SetProjection(sr_wkt)

# Create a memory layer to rasterize from.

rast_ogr_ds = \
ogr.GetDriverByName('Memory').CreateDataSource('wrk')
ogr.GetDriverByName('Memory').CreateDataSource('wrk')
rast_mem_lyr = rast_ogr_ds.CreateLayer('poly', srs=sr)

# Add polygons.
Expand Down Expand Up @@ -313,8 +313,8 @@ def rasterize_5():
# Run the algorithm.

err = gdal.RasterizeLayer(target_ds, [1, 2, 3], rast_mem_lyr,
burn_values=[100, 110, 120],
options=["MERGE_ALG=ADD"])
burn_values=[100, 110, 120],
options=["MERGE_ALG=ADD"])

if err != 0:
print(err)
Expand Down
2 changes: 1 addition & 1 deletion autotest/alg/sieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def sieve_7():
def sieve_8():

gdal.FileFromMemBuffer('/vsimem/sieve_8.asc',
"""ncols 7
"""ncols 7
nrows 7
xllcorner 440720.000000000000
yllcorner 3750120.000000000000
Expand Down
Loading

0 comments on commit ae0c5f6

Please sign in to comment.