@@ -1001,12 +1001,31 @@ def test_ComputeMinMaxLocation():
10011001 and ret .maxY == 18
10021002 )
10031003
1004- ds = gdal .GetDriverByName ("MEM" ).Create ("" , 1 , 1 , 1 , gdal .GDT_Float64 )
1004+
1005+ @pytest .mark .parametrize (
1006+ "datatype" , [gdal .GDT_Float16 , gdal .GDT_Float32 , gdal .GDT_Float64 ]
1007+ )
1008+ def test_ComputeMinMaxLocation_nan (datatype ):
1009+
1010+ ds = gdal .GetDriverByName ("MEM" ).Create ("" , 1 , 1 , 1 , datatype )
10051011 ds .GetRasterBand (1 ).Fill (float ("nan" ))
10061012 ret = ds .GetRasterBand (1 ).ComputeMinMaxLocation ()
10071013 assert ret is None
10081014
10091015
1016+ @pytest .mark .parametrize ("value" , [float ("inf" ), float ("-inf" )])
1017+ @pytest .mark .parametrize (
1018+ "datatype" , [gdal .GDT_Float16 , gdal .GDT_Float32 , gdal .GDT_Float64 ]
1019+ )
1020+ def test_ComputeMinMaxLocation_inf (value , datatype ):
1021+
1022+ ds = gdal .GetDriverByName ("MEM" ).Create ("" , 1 , 1 , 1 , datatype )
1023+ ds .GetRasterBand (1 ).Fill (value )
1024+ ret = ds .GetRasterBand (1 ).ComputeMinMaxLocation ()
1025+ assert ret .min == value and ret .max == value
1026+ assert ret .minX == 0 and ret .minY == 0 and ret .maxX == 0 and ret .maxY == 0
1027+
1028+
10101029def test_create_numpy_types ():
10111030 np = pytest .importorskip ("numpy" )
10121031 gdaltest .importorskip_gdal_array ()
0 commit comments