is_nan function defined for Python versions under 2.6

git-svn-id: http://svn.osgeo.org/postgis/trunk@6879 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Jorge Arévalo 2011-03-05 11:00:25 +00:00
parent 0ad05964db
commit 3b31a2ccca

View file

@ -70,6 +70,12 @@ g_rt_schema = 'public'
VERBOSE = False
SUMMARY = []
def is_nan(x):
if sys.hexversion < 0x02060000:
return str(float(x)).lower() == 'nan'
else:
return math.isnan(x)
def parse_command_line():
"""Collects, parses and validates command line arguments."""
@ -529,7 +535,7 @@ def collect_nodata_values(ds, band_from, band_to):
for i in range(band_from, band_to):
band = ds.GetRasterBand(i)
nodata = band.GetNoDataValue()
if nodata is not None and not math.isnan(nodata):
if nodata is not None and not is_nan(nodata):
nd.append(nodata)
return nd