提交 32fa17ac authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merge branch 'nouiz-error'

......@@ -136,9 +136,13 @@ AddConfigVar('nocleanup',
BoolParam(False),
in_c_key=False)
# This flag is used when we import Theano to initialize global variables.
# So changing it after import will not modify these global variables.
# This could be done differently... but for now we simply prevent it from being
# changed at runtime.
AddConfigVar('tensor.cmp_sloppy',
"Relax tensor._allclose (0) not at all, (1) a bit, (2) more",
IntParam(0, lambda i: i in (0,1,2)),
IntParam(0, lambda i: i in (0,1,2), allow_override=False),
in_c_key=False)
AddConfigVar('tensor.local_elemwise_fusion',
......
......@@ -1222,12 +1222,16 @@ class _tensor_py_operators:
shape = property(lambda self: shape(self))
size = property(lambda self: prod(self.shape))
def __len__(self):
# We can't implement __len__ as Python requests that this
# function returns an integer >=0
raise TypeError("Theano Variables can't work with len(Theano "
"Variable) due to Python restriction. You can use "
"TheanoVariable.shape[0] instead.")
# We can't implement __len__ to provide a better error message.
# Otherwise TensorVariable[:-1] does not work as Python 2.5.1 calls
# __len__ before calling __getitem__. It also does not catch the raised
# Exception!
# def __len__(self):
# # We can't implement __len__ as Python requests that this
# # function returns an integer >=0
# raise Exception("Theano Variables can't work with len(Theano "
# "Variable) due to Python restriction. You can use "
# "TheanoVariable.shape[0] instead.")
def reshape(self, shape, ndim=None):
"""Return a reshaped view/copy of this variable.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论