提交 7365e01e authored 作者: David Warde-Farley's avatar David Warde-Farley 提交者: Arnaud Bergeron

Things that need to be lists but aren't.

上级 069a9912
...@@ -2291,8 +2291,8 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions ...@@ -2291,8 +2291,8 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
inputs = [inputs] inputs = [inputs]
# Wrap them in In or Out instances if needed. # Wrap them in In or Out instances if needed.
inputs = map(self.wrap_in, inputs) inputs, outputs = (list(map(self.wrap_in, inputs)),
outputs = map(self.wrap_out, outputs) list(map(self.wrap_out, outputs)))
_inputs = gof.graph.inputs([o.variable for o in outputs] + _inputs = gof.graph.inputs([o.variable for o in outputs] +
[i.update for i in inputs [i.update for i in inputs
if getattr(i, 'update', False)]) if getattr(i, 'update', False)])
...@@ -2320,7 +2320,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions ...@@ -2320,7 +2320,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
optimizer(fgraph) optimizer(fgraph)
theano.compile.function_module.insert_deepcopy( theano.compile.function_module.insert_deepcopy(
fgraph, inputs, outputs + additional_outputs) fgraph, inputs, list(chain(outputs, additional_outputs)))
finally: finally:
theano.config.compute_test_value = compute_test_value_orig theano.config.compute_test_value = compute_test_value_orig
......
...@@ -87,7 +87,7 @@ class MyOp(Op): ...@@ -87,7 +87,7 @@ class MyOp(Op):
def make_node(self, *inputs): def make_node(self, *inputs):
assert len(inputs) == self.nin assert len(inputs) == self.nin
inputs = map(as_variable, inputs) inputs = list(map(as_variable, inputs))
for input in inputs: for input in inputs:
if input.type is not tdouble: if input.type is not tdouble:
raise Exception("Error 1") raise Exception("Error 1")
......
...@@ -65,7 +65,7 @@ class MyOp(Op): ...@@ -65,7 +65,7 @@ class MyOp(Op):
def make_node(self, *inputs): def make_node(self, *inputs):
assert len(inputs) == self.nin assert len(inputs) == self.nin
inputs = map(as_variable, inputs) inputs = list(map(as_variable, inputs))
for input in inputs: for input in inputs:
if not isinstance(input.type, MyType): if not isinstance(input.type, MyType):
raise Exception("Error 1") raise Exception("Error 1")
......
...@@ -46,7 +46,7 @@ def MyVariable(thingy): ...@@ -46,7 +46,7 @@ def MyVariable(thingy):
class MyOp(Op): class MyOp(Op):
def make_node(self, *inputs): def make_node(self, *inputs):
inputs = map(as_variable, inputs) inputs = list(map(as_variable, inputs))
for input in inputs: for input in inputs:
if not isinstance(input.type, MyType): if not isinstance(input.type, MyType):
print(input, input.type, type(input), type(input.type)) print(input, input.type, type(input), type(input.type))
......
...@@ -39,7 +39,7 @@ class MyOp(Op): ...@@ -39,7 +39,7 @@ class MyOp(Op):
def make_node(self, *inputs): def make_node(self, *inputs):
assert len(inputs) == self.nin assert len(inputs) == self.nin
inputs = map(as_variable, inputs) inputs = list(map(as_variable, inputs))
for input in inputs: for input in inputs:
if input.type is not tdouble: if input.type is not tdouble:
raise Exception("Error 1") raise Exception("Error 1")
......
...@@ -57,7 +57,7 @@ class MyType(Type): ...@@ -57,7 +57,7 @@ class MyType(Type):
class MyOp(Op): class MyOp(Op):
def make_node(self, *inputs): def make_node(self, *inputs):
inputs = map(as_variable, inputs) inputs = list(map(as_variable, inputs))
for input in inputs: for input in inputs:
if not isinstance(input.type, MyType): if not isinstance(input.type, MyType):
raise Exception("Error 1") raise Exception("Error 1")
......
...@@ -39,7 +39,7 @@ class MyOp(Op): ...@@ -39,7 +39,7 @@ class MyOp(Op):
self.x = x self.x = x
def make_node(self, *inputs): def make_node(self, *inputs):
inputs = map(as_variable, inputs) inputs = list(map(as_variable, inputs))
for input in inputs: for input in inputs:
if not isinstance(input.type, MyType): if not isinstance(input.type, MyType):
raise Exception("Error 1") raise Exception("Error 1")
......
...@@ -39,7 +39,7 @@ class MyOp(Op): ...@@ -39,7 +39,7 @@ class MyOp(Op):
def make_node(self, *inputs): def make_node(self, *inputs):
assert len(inputs) == self.nin assert len(inputs) == self.nin
inputs = map(as_variable, inputs) inputs = list(map(as_variable, inputs))
for input in inputs: for input in inputs:
if not isinstance(input.type, MyType): if not isinstance(input.type, MyType):
raise Exception("Error 1") raise Exception("Error 1")
......
...@@ -237,7 +237,7 @@ class test_upgrade_to_float(object): ...@@ -237,7 +237,7 @@ class test_upgrade_to_float(object):
# at least float32, not float16. # at least float32, not float16.
unary_ops_vals = [ unary_ops_vals = [
(inv, list(range(-127, 0) + range(1, 127))), (inv, list(range(-127, 0)) + list(range(1, 127))),
(sqrt, list(range(0, 128))), (sqrt, list(range(0, 128))),
(log, list(range(1, 128))), (log, list(range(1, 128))),
(log2, list(range(1, 128))), (log2, list(range(1, 128))),
...@@ -262,7 +262,7 @@ class test_upgrade_to_float(object): ...@@ -262,7 +262,7 @@ class test_upgrade_to_float(object):
(arctanh, [0])] (arctanh, [0])]
binary_ops_vals = [ binary_ops_vals = [
(arctan2, list(range(-127, 128), range(-127, 128)))] (arctan2, list(range(-127, 128)), list(range(-127, 128)))]
@staticmethod @staticmethod
def _test_unary(unary_op, x_range): def _test_unary(unary_op, x_range):
...@@ -306,8 +306,8 @@ class test_upgrade_to_float(object): ...@@ -306,8 +306,8 @@ class test_upgrade_to_float(object):
def test_true_div(self): def test_true_div(self):
# true_div's upcast policy is not exactly "upgrade_to_float", # true_div's upcast policy is not exactly "upgrade_to_float",
# so the test is a little bit different # so the test is a little bit different
x_range = range(-127, 128) x_range = list(range(-127, 128))
y_range = range(-127, 0) + range(1, 127) y_range = list(range(-127, 0)) + list(range(1, 127))
xi = int8('xi') xi = int8('xi')
yi = int8('yi') yi = int8('yi')
......
...@@ -1706,7 +1706,7 @@ class T_Scan(unittest.TestCase): ...@@ -1706,7 +1706,7 @@ class T_Scan(unittest.TestCase):
# Also validate that the mappings outer_inp_from_outer_out and # Also validate that the mappings outer_inp_from_outer_out and
# outer_inp_from_inner_inp produce the correct results # outer_inp_from_inner_inp produce the correct results
scan_node = updates.values()[0].owner scan_node = list(updates.values())[0].owner
result = scan_node.op.var_mappings['outer_inp_from_outer_out'] result = scan_node.op.var_mappings['outer_inp_from_outer_out']
expected_result = {0: 3, 1: 5, 2: 4} expected_result = {0: 3, 1: 5, 2: 4}
...@@ -3662,7 +3662,7 @@ class T_Scan(unittest.TestCase): ...@@ -3662,7 +3662,7 @@ class T_Scan(unittest.TestCase):
n_steps=10, n_steps=10,
truncate_gradient=-1, truncate_gradient=-1,
go_backwards=False) go_backwards=False)
cost = updates.values()[0] cost = list(updates.values())[0]
g_sh = tensor.grad(cost, shared_var) g_sh = tensor.grad(cost, shared_var)
fgrad = theano.function([], g_sh) fgrad = theano.function([], g_sh)
assert fgrad() == 1 assert fgrad() == 1
......
...@@ -846,7 +846,8 @@ _good_broadcast_div_mod_normal_float_no_complex = dict( ...@@ -846,7 +846,8 @@ _good_broadcast_div_mod_normal_float_no_complex = dict(
uinteger=(randint(2, 3).astype("uint8"), uinteger=(randint(2, 3).astype("uint8"),
randint_nonzero(2, 3).astype("uint8")), randint_nonzero(2, 3).astype("uint8")),
int8=[numpy.tile(numpy.arange(-127, 128, dtype='int8'), [254, 1]).T, int8=[numpy.tile(numpy.arange(-127, 128, dtype='int8'), [254, 1]).T,
numpy.tile(numpy.array(range(-127, 0) + range(1, 128), dtype='int8'), numpy.tile(numpy.array(list(range(-127, 0)) + list(range(1, 128)),
dtype='int8'),
[255, 1])], [255, 1])],
# This empty2 doesn't work for some tests. I don't remember why # This empty2 doesn't work for some tests. I don't remember why
#empty2=(numpy.asarray([0]), numpy.asarray([])), #empty2=(numpy.asarray([0]), numpy.asarray([])),
...@@ -933,7 +934,7 @@ TrueDivInplaceTester = makeBroadcastTester( ...@@ -933,7 +934,7 @@ TrueDivInplaceTester = makeBroadcastTester(
_good_inv = dict( _good_inv = dict(
normal=[5 * rand_nonzero((2, 3))], normal=[5 * rand_nonzero((2, 3))],
integers=[randint_nonzero(2, 3)], integers=[randint_nonzero(2, 3)],
int8=[numpy.array(range(-127, 0) + range(1, 127), dtype='int8')], int8=[numpy.array(list(range(-127, 0)) + list(range(1, 127)), dtype='int8')],
complex=[randcomplex_nonzero((2, 3))], complex=[randcomplex_nonzero((2, 3))],
empty=[numpy.asarray([], dtype=config.floatX)]) empty=[numpy.asarray([], dtype=config.floatX)])
......
...@@ -388,7 +388,7 @@ class CompressTester(utt.InferShapeTester): ...@@ -388,7 +388,7 @@ class CompressTester(utt.InferShapeTester):
class TestRepeatOp(utt.InferShapeTester): class TestRepeatOp(utt.InferShapeTester):
def _possible_axis(self, ndim): def _possible_axis(self, ndim):
return [None] + range(ndim) + [-i for i in range(ndim)] return [None] + list(range(ndim)) + [-i for i in range(ndim)]
def setUp(self): def setUp(self):
super(TestRepeatOp, self).setUp() super(TestRepeatOp, self).setUp()
......
...@@ -33,7 +33,7 @@ class MyOp(Op): ...@@ -33,7 +33,7 @@ class MyOp(Op):
self.x = x self.x = x
def make_node(self, *inputs): def make_node(self, *inputs):
inputs = map(as_variable, inputs) inputs = list(map(as_variable, inputs))
for input in inputs: for input in inputs:
if not isinstance(input.type, MyType): if not isinstance(input.type, MyType):
raise Exception("Error 1") raise Exception("Error 1")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论