提交 f9813f0f authored 作者: Razvan Pascanu's avatar Razvan Pascanu

merge; no conflicts

......@@ -152,7 +152,7 @@ class BadCLinkerOutput(DebugModeError):
print >> ssio, numpy.isnan(self.val_py).sum(),
# only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue()
except:
except Exception:
pass
try:
ssio = StringIO()
......@@ -166,7 +166,7 @@ class BadCLinkerOutput(DebugModeError):
print >> ssio, numpy.isnan(self.val_c).sum(),
# only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue()
except:
except Exception:
pass
try:
ov=numpy.asarray(self.val_c)
......@@ -184,7 +184,7 @@ class BadCLinkerOutput(DebugModeError):
print >> ssio, " Std Rel Diff: ", numpy.std(reldiff)
# only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue()
except:
except Exception:
pass
return sio.getvalue()
......@@ -246,7 +246,7 @@ class BadOptimization(DebugModeError):
print >> ssio, self.old_r_val.strides
# only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue()
except:
except Exception:
pass
str_old_r_val = str(self.old_r_val)
......@@ -263,7 +263,7 @@ class BadOptimization(DebugModeError):
print >> ssio, self.new_r_val.strides
# only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue()
except:
except Exception:
pass
str_new_r_val = str(self.new_r_val)
if len(str_new_r_val) > val_str_len_limit:
......@@ -286,7 +286,7 @@ class BadOptimization(DebugModeError):
print >> ssio, " Std Rel Diff: ", numpy.std(reldiff)
# only if all succeeds to we add anything to sio
print >> sio, ssio.getvalue()
except:
except Exception:
pass
print >> sio, " Reason: ", str(self.reason)
......@@ -400,7 +400,7 @@ class InvalidValueError(DebugModeError):
v_min = v.min()
v_max = v.max()
v_isfinite = numpy.all(numpy.isfinite(v))
except:
except Exception:
pass
client_node = self.client_node
hint = self.hint
......@@ -687,7 +687,7 @@ def _check_strides_match(a, b, warn_err, op):
try:
strides_eq = a.strides == b.strides
except:
except Exception:
return # no strides
if not strides_eq:
......@@ -1435,7 +1435,7 @@ class _Linker(gof.link.LocalLinker):
## First time, with None in output_storage
try:
thunk_c()
except:
except Exception:
raise_with_op(node)
for r in node.outputs:
......@@ -1475,7 +1475,7 @@ class _Linker(gof.link.LocalLinker):
def thunk():
try:
thunk_c()
except:
except Exception:
raise_with_op(node)
_logger.debug(
'%i - calling _check_preallocated_output '
......@@ -1547,7 +1547,7 @@ class _Linker(gof.link.LocalLinker):
storage_map[r][0].itemset(dr_vals[r][0])
else:
storage_map[r][0] = dr_vals[r][0]
except:
except Exception:
# Restore the initial state of storage_map
for r in storage_map:
if r in original_storage_map_keys:
......
......@@ -597,7 +597,7 @@ class Function(object):
t0_fn = time.time()
try:
self.fn()
except:
except Exception:
if hasattr(self.fn, 'position_of_error'):
# this is a new vm-provided function
# the C VM needs this because the exception manipulation
......@@ -1107,7 +1107,7 @@ try:
# compatible with python 2.4, we implement pickling of slice
# ourself.
cPickle.dumps(slice(0, 10, 100))
except:
except TypeError:
# This slice pickle implementation seam backward and forward compatible.
def _pickle_slice(s):
return (slice, (s.start, s.stop, s.step))
......@@ -1120,7 +1120,7 @@ def check_equal(x, y):
for checker in __checkers:
try:
return checker(x, y)
except:
except Exception:
continue
return x == y
#raise Exception('No checker for equality between %s and %s' % (x, y))
......
......@@ -421,22 +421,22 @@ class Method(Component):
_inputs = [x.variable for x in inputs]
# Grab the variables that are not accessible from either the inputs or the updates.
if outputs is None:
outputs_list = []
outputs_list = []
else:
if isinstance(outputs, (list, tuple)):
outputs_list = list(outputs)
else:
outputs_list = [outputs]
if isinstance(outputs, (list, tuple)):
outputs_list = list(outputs)
else:
outputs_list = [outputs]
#backport
#outputs_list = [] if outputs is None else (list(outputs) if isinstance(outputs, (list, tuple)) else [outputs])
outputs_variable_list = []
for o in outputs_list:
if isinstance(o, io.Out):
outputs_variable_list += [o.variable]
else:
outputs_variable_list += [o]
if isinstance(o, io.Out):
outputs_variable_list += [o.variable]
else:
outputs_variable_list += [o]
#backport
#outputs_variable_list = [o.variable if isinstance(o, io.Out) else o for o in outputs_list]
......@@ -469,9 +469,9 @@ class Method(Component):
inputs.append(storage)
if self.mode is None:
effective_mode = mode
effective_mode = mode
else:
effective_mode = self.mode
effective_mode = self.mode
#backport
#effective_mode = mode if self.mode is None else self.mode
......@@ -486,9 +486,9 @@ class Method(Component):
else:
rval = ''
if isinstance(self.outputs, (list, tuple)):
inputs, outputs, updates = self.inputs, self.outputs
inputs, outputs, updates = self.inputs, self.outputs
else:
inputs, outputs, updates = [self.outputs], self.updates
inputs, outputs, updates = [self.outputs], self.updates
#backport
#inputs, outputs, updates = self.inputs, self.outputs if isinstance(self.outputs, (list, tuple)) else [self.outputs], self.updates
......@@ -505,9 +505,9 @@ class Method(Component):
def __str__(self):
if self.updates:
sep = "; "
sep = "; "
else:
sep = ""
sep = ""
return "Method(%s -> %s%s%s)" % \
(self.inputs,
self.outputs,
......@@ -1095,9 +1095,9 @@ class Module(ComponentDict):
# to look for submodules on which make_module_instance needs to be called
def recurse(v):
if isinstance(v,list):
iter = enumerate(v)
iter = enumerate(v)
else:
iter = v.iteritems()
iter = v.iteritems()
#backport
#iter = enumerate(v) if isinstance(v,list) else v.iteritems()
for sk,sv in iter:
......@@ -1120,7 +1120,7 @@ class Module(ComponentDict):
self[k] = self.__wrapper__(recurse(v))
try:
self[k] = self.__wrapper__(v)
except:
except Exception:
if isinstance(v, Component):
raise
else:
......
......@@ -143,7 +143,7 @@ def rebuild_collect_shared( outputs
replace = []
try:
replace_pairs = replace.items()
except:
except Exception:
replace_pairs = replace
for v_orig, v_repl in replace_pairs:
......@@ -476,6 +476,4 @@ def iter_over_pairs(pairs):
if isinstance(pairs, dict):
return pairs.iteritems()
else:
return pairs
return pairs
......@@ -472,7 +472,7 @@ class T_module(unittest.TestCase):
m = M.make()
try:
m.y = 77 #fail?
except:
except Exception:
pass
assert m.y == 40
assert m.f(20) == 100
......
......@@ -461,7 +461,7 @@ def pydotprint(fct, outfile=None,
try:
import pydot as pd
except:
except ImportError:
print "failed to import pydot. Yous must install pydot for this function to work."
return
......
......@@ -593,7 +593,7 @@ class unary_out_lookup(gof.utils.object2):
types = types[0]
try:
rval = self.tbl[types]
except:
except Exception:
raise TypeError(types)
if isinstance(types, (list, tuple)):
return rval
......
......@@ -118,10 +118,7 @@ def hash_listsDictsTuples(x):
for v in x:
hash_value ^= hash_listsDictsTuples(v)
else:
try:
hash_value ^= hash(x)
except:
pass
hash_value ^= hash(x)
return hash_value
......@@ -249,7 +246,7 @@ def isNaN_or_Inf_or_None(x):
isNaN = numpy.isnan(x)
isInf = numpy.isinf(x)
isStr = isinstance(x, str)
except:
except Exception:
isNaN = False
isInf = False
isStr = False
......@@ -258,7 +255,7 @@ def isNaN_or_Inf_or_None(x):
val = get_constant_value(x)
isInf = numpy.isinf(val)
isNaN = numpy.isnan(val)
except:
except Exception:
isNaN = False
isInf = False
if isinstance(x, gof.Constant) and isinstance(x.data, str):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论