Commit 64ed20e6 authored by Chet Nieter's avatar Chet Nieter

Fixed flake8 errors.

parent 79b89c9f
......@@ -179,7 +179,7 @@ class FileStoreSpecB(FileStoreAPI):
pipeline = md.get("pipeline", [])
for item in pipeline:
if item["name"] == objectname:
return item.get("visibility", False) == True
return item.get("visibility", False) is True
return False
def get_control_parameters(self, objectname):
......@@ -278,18 +278,19 @@ def load(filename):
# check if we support this cinema database.
if fs.metadata.get("type") != "composite-image-stack":
print ("Only 'composite-image-stack' file stores are supported.")
print("Only 'composite-image-stack' file stores are supported.")
raise RuntimeError(
"Only 'composite-image-stack' file stores are supported.")
if fs.metadata.get("camera_model") != "azimuth-elevation-roll":
print ("Only 'azimuth-elevation-roll' cameras are supported.")
print("Only 'azimuth-elevation-roll' cameras are supported.")
raise RuntimeError(
"Only 'azimuth-elevation-roll' cameras are supported.")
if fs.metadata.get("value_mode") != 2:
if not filename in __warning_count:
if filename not in __warning_count:
__warning_count[filename] = True
print ("Warning: the cinema store '" + filename.strip() +
"', encodes data values as RGB arrays which is known to " +
"have issues in current implementation. Scalar" +
"coloring may produce unexpected results.")
print("Warning: the cinema store '" + filename.strip() +
"', encodes data values as RGB arrays which is known to " +
"have issues in current implementation. Scalar" +
"coloring may produce unexpected results.")
return FileStoreSpecB(fs)
import paraview
class ProgressObject():
'''Progress reporter. Creates a dummy vtkCinemaExporter proxy to use it
as the emitter of progress events.'''
def __init__(self):
self.proxy = paraview.simple.servermanager.CreateProxy("exporters", "CinemaExporter")
self.proxy = paraview.simple.servermanager.CreateProxy(
"exporters", "CinemaExporter")
self.obj = self.proxy.GetClientSideObject()
def UpdateProgress(self, progress):
......
......@@ -35,10 +35,10 @@ def printView(view):
r.SetViewPoint(-1, 1, 0)
r.ViewToWorld()
ul = r.GetWorldPoint()
print (ll[0], ll[1], ll[2])
print (lr[0], lr[1], lr[2])
print (ur[0], ur[1], ur[2])
print (ul[0], ul[1], ul[2])
print(ll[0], ll[1], ll[2])
print(lr[0], lr[1], lr[2])
print(ur[0], ur[1], ur[2])
print(ul[0], ul[1], ul[2])
# print (math.sqrt((ur[0]-ll[0])*(ur[0]-ll[0])+
# (ur[1]-ll[1])*(ur[1]-ll[1])+
# (ur[2]-ll[2])*(ur[2]-ll[2])))
......@@ -220,7 +220,7 @@ class ImageExplorer(explorers.Explorer):
if self.UsingGL2:
self.view.StopCaptureLuminance()
if self.CaptureValues != True:
if self.CaptureValues is not True:
# this is a workaround for a bug in VTK
# in valuepass, we need the arrays we will render,
# but with CompositePolyDataMapper we need to render
......@@ -448,7 +448,7 @@ class ColorList():
def AddLUT(self, field, name, comp):
self._dict[name] = {'type': 'lut', 'field': field,
'name': name, 'comp':comp}
'name': name, 'comp': comp}
def AddDepth(self, name):
self._dict[name] = {'type': 'depth'}
......
......@@ -9,6 +9,7 @@ import sys
import copy
import numpy as np
class FileStore(store.Store):
"""Implementation of a store based on named files and directories."""
......@@ -41,7 +42,7 @@ class FileStore(store.Store):
elif 'parameter_list' in info_json:
self._set_parameter_list(info_json['parameter_list'])
else:
print ("Error I can't read that file")
print("Error I can't read that file")
exit()
self.metadata = info_json['metadata']
self.filename_pattern = info_json['name_pattern']
......@@ -192,8 +193,8 @@ class FileStore(store.Store):
try:
os.makedirs(dirname)
except OSError:
print ("OSError: Could not make dirs! " +
"This is expected if running in batch mode with '-sym'")
print("OSError: Could not make dirs! " +
"This is expected if running in batch mode with '-sym'")
pass
if document.data is not None:
......@@ -202,7 +203,8 @@ class FileStore(store.Store):
if 'role' in params:
if params['role'] == 'field':
if 'image_size' not in self.metadata:
self.add_metadata({'image_size': document.data.shape[:2]})
self.add_metadata(
{'image_size': document.data.shape[:2]})
self.add_metadata({'endian': sys.byteorder})
doctype = self.determine_type(document.descriptor)
......@@ -239,7 +241,7 @@ class FileStore(store.Store):
if doctype == 'MAGNITUDE':
direct_format = False
if ('value_mode' in self.metadata and
self.metadata['value_mode'] == 2):
self.metadata['value_mode'] == 2):
direct_format = True
k = self.find_field_key(descriptor)
......@@ -247,7 +249,6 @@ class FileStore(store.Store):
components = []
for v in self.get_parameter_values(k):
if prefix in v:
index = self.get_parameter(k)['values'].index(v)
desc = copy.copy(descriptor)
desc[k] = v
vrange = [0., 1.]
......
......@@ -12,7 +12,7 @@ exrEnabled = False
try:
import oexr_helper as exr
exrEnabled = True
print (
print(
"Imported OpenEXR, will default to *.exr for float images (z-buffer, "
"value, etc.).")
except ImportError:
......@@ -189,7 +189,7 @@ class RasterWrangler(object):
return None
else:
print ("Warning: need PIL or VTK to read from " + fname)
print("Warning: need PIL or VTK to read from " + fname)
def rgbwriter(self, imageslice, fname):
"""takes in a color buffer and writes it as an image file"""
......@@ -213,7 +213,7 @@ class RasterWrangler(object):
pimg.save(fname)
else:
print ("Warning: need PIL or VTK to write to " + fname)
print("Warning: need PIL or VTK to write to " + fname)
def valuewriter(self, imageSlice, fname, vrange):
""" Takes in either a (1C) float or a RGB (3C) buffer and writes it as
......@@ -360,6 +360,8 @@ class RasterWrangler(object):
compresseddata = file.read()
imageslice = numpy.fromstring(zlib.decompress(compresseddata),
numpy.float32)
if not isinstance(imageslice, numpy.ndarray):
raise IOError(filename + " does not load correctly.")
return
# Try .npz form
......@@ -367,7 +369,8 @@ class RasterWrangler(object):
if os.path.isfile(adjustedName):
with open(adjustedName, mode='r') as file:
with numpy.load(file) as tz:
pass
if not isinstance(tz, numpy.ndarray):
raise IOError(filename + " does not load correctly.")
return
if not os.path.isfile(filename):
......
......@@ -136,10 +136,8 @@ class Store(object):
Vs.append(newentry)
# Check if vector component
vecname = value.split('_')
if (len(vecname) > 1 and
len(vecname[-1]) == 1 and
self.vector_regex.match(vecname[-1])
):
if (len(vecname) > 1 and len(vecname[-1]) == 1 and
self.vector_regex.match(vecname[-1])):
if vecname[0] in potential_vectors:
potential_vectors[vecname[0]] += 1
else:
......@@ -195,9 +193,9 @@ class Store(object):
"""
values = []
if ('values' in self.__parameter_list[name] and
'types' in self.__parameter_list[name]):
for val,typ in zip(self.__parameter_list[name]['values'],
self.__parameter_list[name]['types']):
'types' in self.__parameter_list[name]):
for val, typ in zip(self.__parameter_list[name]['values'],
self.__parameter_list[name]['types']):
if typ == 'value':
values.append(val)
return values
......@@ -558,7 +556,7 @@ class Store(object):
# print ("PARAMETERS", param_names)
params = []
values = []
total_elem = 1.0;
total_elem = 1.0
for name in param_names:
vals = self.get_parameter(name)['values']
if fixedargs and name in fixedargs:
......@@ -581,7 +579,7 @@ class Store(object):
descriptor = dict(itertools.izip(params, element))
if progressObject:
elem_accum += 1.0;
elem_accum += 1.0
progressObject.UpdateProgress(elem_accum / total_elem)
if fixedargs is not None:
......
......@@ -53,7 +53,7 @@ def convert_pose_to_camera(iPosition, iFocalPoint, iViewUp, pose, camType):
pf = np.add(pr, iPosition)
return (iPosition, pf, newUp)
else:
print ("ERROR unexpected camera type")
print("ERROR unexpected camera type")
return (iPosition, iFocalPoint, iViewUp)
......
......@@ -174,8 +174,8 @@ class Compositor_SpecB(Compositor):
valueMin = valueRange[0]
valueMax = valueRange[1]
# this provides a way to clamp, for example NaN's
foreground[foreground<valueMin] = valueMin
foreground[foreground>valueMax] = valueMax
foreground[foreground < valueMin] = valueMin
foreground[foreground > valueMax] = valueMax
valRange = valueMax - valueMin
if valRange > 1e-4:
foreground = (foreground - valueMin) / valRange
......
......@@ -152,7 +152,8 @@ class TestBasicFileStore(unittest.TestCase):
cs2.load()
docs = []
for doc in cs2.find(
{'theta': 30, 'phi': 140, 'contour': 100, 'color': 'RTData_1'}):
{'theta': 30, 'phi': 140,
'contour': 100, 'color': 'RTData_1'}):
docs.append(doc.data)
# compare the two
......
......@@ -4,8 +4,8 @@ import PIL.ImImagePlugin
import numpy as np
if len(sys.argv) != 5:
print ("usage: depth_raster_obj1 value_raster_obj1" +
"depth_raster_obj2 value_raster_obj2 ")
print("usage: depth_raster_obj1 value_raster_obj1" +
"depth_raster_obj2 value_raster_obj2 ")
exit(0)
......
......@@ -23,7 +23,7 @@ while acnt < len(sys.argv):
if sys.argv[acnt] == "-zh":
acnt = acnt + 1
zlib_height = int(sys.argv[acnt])
acnt = acnt +1
acnt = acnt + 1
fname = sys.argv[-1]
......
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