提交 e9073c35 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Remove tensor.__getslice__ to avoid sys.maxsize

When calling t[1:], for instance, the arguments passed to __getslice__ are (1, sys.maxsize), which is a pain to deal with, and can even not be an int (but a long). If __getslice__ does not exist, __getitem__ is called instead, with argument slice(1, None, None), which is much more desirable. __getslice__ is deprecated in python 2.6 anyway.
上级 1d26096a
......@@ -1413,10 +1413,6 @@ class _tensor_py_operators:
return cast(self, dtype)
#SLICING
# def __getitem__(self, args): return Subtensor.from_idxs(self,
# args).outputs[0]
# def __getslice__(self, *args): return Subtensor.from_idxs(self,
# (slice(*args),)).outputs[0]
def __getitem__(self, args):
if not isinstance(args, tuple):
args = args,
......@@ -1445,10 +1441,6 @@ class _tensor_py_operators:
else:
return Subtensor(args)(self, *Subtensor.collapse(args, lambda entry: isinstance(entry, Variable)))
def __getslice__(self, *args):
args = slice(*args),
return self.__getitem__(args)
#COPYING
def copy(self):
return tensor_copy(self)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论