Commit 2baa8b28 authored by Alvaro Sanchez's avatar Alvaro Sanchez

Reading image files in mode 'rb'.

This is necessary for Python on Windows which makes a distinction between
text and binary files.
parent 8a9e5c0d
Pipeline #47350 passed with stage
......@@ -290,7 +290,7 @@ class RasterWrangler(object):
# Adjust the filename, replace .im with .Z
adjustedName = baseName + ".Z"
with open(adjustedName, mode='r') as file:
with open(adjustedName, mode='rb') as file:
compresseddata = file.read()
flatarr = numpy.fromstring(zlib.decompress(compresseddata),
numpy.float32)
......@@ -304,7 +304,7 @@ class RasterWrangler(object):
# Adjust the filename, replace .im with .npz
adjustedName = baseName + ".npz"
with open(adjustedName, mode='r') as file:
with open(adjustedName, mode='rb') as file:
with numpy.load(file) as tz:
imageslice = tz[tz.files[0]]
return imageslice
......@@ -356,8 +356,9 @@ class RasterWrangler(object):
baseName, ext = os.path.splitext(filename)
adjustedName = baseName + ".Z"
if os.path.isfile(adjustedName):
with open(adjustedName, mode='r') as file:
with open(adjustedName, mode='rb') as file:
compresseddata = file.read()
imageslice = numpy.fromstring(zlib.decompress(compresseddata),
numpy.float32)
if not isinstance(imageslice, numpy.ndarray):
......@@ -367,7 +368,7 @@ class RasterWrangler(object):
# Try .npz form
adjustedName = baseName + ".npz"
if os.path.isfile(adjustedName):
with open(adjustedName, mode='r') as file:
with open(adjustedName, mode='rb') as file:
with numpy.load(file) as tz:
if not isinstance(tz[tz.files[0]], numpy.ndarray):
raise IOError(adjustedName + " does not load correctly.")
......
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