Commit 131acd5d authored by David E. DeMarle's avatar David E. DeMarle Committed by Kitware Robot

Merge topic 'fix-read-binary'

2baa8b28 Reading image files in mode 'rb'.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !109
parents 8a9e5c0d 2baa8b28
Pipeline #47352 failed with stage
in 0 seconds
......@@ -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