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

merge; no conflicts

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