Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
99079db1
提交
99079db1
authored
3月 18, 2013
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1285 from lamblin/long_indexing
Allow Python long integers in indexing.
上级
e97557c8
5843edc1
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
0 行删除
+20
-0
basic.py
theano/tensor/basic.py
+6
-0
test_basic.py
theano/tensor/tests/test_basic.py
+14
-0
没有找到文件。
theano/tensor/basic.py
浏览文件 @
99079db1
...
@@ -4457,6 +4457,12 @@ class Subtensor(Op):
...
@@ -4457,6 +4457,12 @@ class Subtensor(Op):
# See <http://projects.scipy.org/numpy/ticket/2235>.
# See <http://projects.scipy.org/numpy/ticket/2235>.
elif
isinstance
(
entry
,
(
numpy
.
integer
,
int
)):
elif
isinstance
(
entry
,
(
numpy
.
integer
,
int
)):
return
entry
return
entry
# On Windows 64-bit, shapes are returned as Python long, as they can
# be bigger than what a Python int can hold.
# Shapes should always fit in a numpy.int64, and we support them better
elif
isinstance
(
entry
,
long
):
entry64
=
numpy
.
int64
(
entry
)
return
entry64
else
:
else
:
raise
AdvancedIndexingError
(
Subtensor
.
e_indextype
,
entry
)
raise
AdvancedIndexingError
(
Subtensor
.
e_indextype
,
entry
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
99079db1
...
@@ -2998,6 +2998,20 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -2998,6 +2998,20 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
self
.
assertTrue
(
tval
.
shape
==
())
self
.
assertTrue
(
tval
.
shape
==
())
self
.
assertTrue
(
numpy
.
all
(
tval
==
0
))
self
.
assertTrue
(
numpy
.
all
(
tval
==
0
))
def
test_long
(
self
):
n
=
self
.
shared
(
numpy
.
arange
(
12
,
dtype
=
self
.
dtype
)
.
reshape
((
4
,
3
)))
t
=
n
[
1L
:
4L
:
2L
,
1L
]
self
.
assertTrue
(
isinstance
(
t
.
owner
.
op
,
Subtensor
))
tval
=
self
.
eval_output_and_check
(
t
)
self
.
assertTrue
(
tval
.
shape
==
(
2
,))
self
.
assertTrue
(
numpy
.
all
(
tval
==
[
4
,
10
]))
def
test_long_too_big
(
self
):
# Currently, we cast Python longs to int64 when used for indexing.
# This test checks that using a long that does not fit raises an error.
n
=
self
.
shared
(
numpy
.
arange
(
12
,
dtype
=
self
.
dtype
)
.
reshape
((
4
,
3
)))
self
.
assertRaises
(
Exception
,
lambda
:
n
[:(
2L
**
63
)])
def
test_newaxis
(
self
):
def
test_newaxis
(
self
):
"""
"""
newaxis support comes from logic in the __getitem__ of TensorType
newaxis support comes from logic in the __getitem__ of TensorType
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论