Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
000a1c87
提交
000a1c87
authored
9月 29, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
9月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove use of deprecated NumPy list indexing
上级
0f4f64fe
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
11 行增加
和
19 行删除
+11
-19
sort.py
aesara/tensor/sort.py
+3
-3
test_pool.py
tests/tensor/signal/test_pool.py
+2
-2
test_subtensor.py
tests/tensor/test_subtensor.py
+6
-14
没有找到文件。
aesara/tensor/sort.py
浏览文件 @
000a1c87
...
...
@@ -291,10 +291,10 @@ def _topk_py_impl(op, x, k, axis, idx_dtype):
idx
[
axis
]
=
slice
(
-
k
,
None
)
if
k
>
0
else
slice
(
-
k
)
if
not
op
.
return_indices
:
zv
=
np
.
partition
(
x
,
-
k
,
axis
=
axis
)[
idx
]
zv
=
np
.
partition
(
x
,
-
k
,
axis
=
axis
)[
tuple
(
idx
)
]
return
zv
elif
op
.
return_values
:
zi
=
np
.
argpartition
(
x
,
-
k
,
axis
=
axis
)[
idx
]
zi
=
np
.
argpartition
(
x
,
-
k
,
axis
=
axis
)[
tuple
(
idx
)
]
idx2
=
tuple
(
np
.
arange
(
s
)
.
reshape
((
s
,)
+
(
1
,)
*
(
ndim
-
i
-
1
))
if
i
!=
axis
else
zi
for
i
,
s
in
enumerate
(
x
.
shape
)
...
...
@@ -302,7 +302,7 @@ def _topk_py_impl(op, x, k, axis, idx_dtype):
zv
=
x
[
idx2
]
return
zv
,
zi
.
astype
(
idx_dtype
)
else
:
zi
=
np
.
argpartition
(
x
,
-
k
,
axis
=
axis
)[
idx
]
zi
=
np
.
argpartition
(
x
,
-
k
,
axis
=
axis
)[
tuple
(
idx
)
]
return
zi
.
astype
(
idx_dtype
)
...
...
tests/tensor/signal/test_pool.py
浏览文件 @
000a1c87
...
...
@@ -216,7 +216,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
r_stride
=
builtins
.
max
(
r_stride
,
pad
[
i
])
r_end
=
builtins
.
min
(
r_end
,
input
.
shape
[
-
nd
+
i
]
+
pad
[
i
])
region
.
append
(
slice
(
r_stride
,
r_end
))
patch
=
padded_input
[
l
][
region
]
patch
=
padded_input
[
l
][
tuple
(
region
)
]
output_val
[
l
][
r
]
=
func
(
patch
)
return
output_val
...
...
@@ -325,7 +325,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
r_stride
=
r
[
i
]
*
stride
[
i
]
r_end
=
builtins
.
min
(
r_stride
+
ws
[
i
],
input
.
shape
[
-
nd
+
i
])
region
.
append
(
slice
(
r_stride
,
r_end
))
patch
=
input
[
l
][
region
]
patch
=
input
[
l
][
tuple
(
region
)
]
output_val
[
l
][
r
]
=
func
(
patch
)
return
output_val
...
...
tests/tensor/test_subtensor.py
浏览文件 @
000a1c87
...
...
@@ -527,12 +527,6 @@ class TestSubtensor(utt.OptimizationTestMixin):
with
pytest
.
raises
(
Exception
):
n
[:
(
2
**
63
)]
def
test_list_slice
(
self
):
x
=
at
.
arange
(
100
)
.
reshape
((
5
,
5
,
4
))
res
=
x
[[
slice
(
1
,
-
1
)]
*
x
.
ndim
]
.
eval
()
x
=
np
.
arange
(
100
)
.
reshape
((
5
,
5
,
4
))
np
.
allclose
(
res
,
x
[[
slice
(
1
,
-
1
)]
*
x
.
ndim
])
def
test_slice_symbol
(
self
):
x
=
self
.
shared
(
np
.
random
.
random
((
5
,
4
))
.
astype
(
self
.
dtype
))
y
=
self
.
shared
(
np
.
random
.
random
((
1
,
2
,
3
))
.
astype
(
self
.
dtype
))
...
...
@@ -623,15 +617,15 @@ class TestSubtensor(utt.OptimizationTestMixin):
test_array_np
[
np
.
newaxis
,
1
:,
mask
],
test_array
[
np
.
newaxis
,
1
:,
mask
]
.
eval
()
)
assert_array_equal
(
numpy_inc_subtensor
(
test_array_np
,
[
0
,
mask
]
,
1
),
numpy_inc_subtensor
(
test_array_np
,
(
0
,
mask
)
,
1
),
inc_subtensor
(
test_array
[(
0
,)
+
mask
.
nonzero
()],
1
)
.
eval
(),
)
assert_array_equal
(
numpy_inc_subtensor
(
test_array_np
,
[
0
,
mask
]
,
1
),
numpy_inc_subtensor
(
test_array_np
,
(
0
,
mask
)
,
1
),
inc_subtensor
(
test_array
[
0
,
mask
],
1
)
.
eval
(),
)
assert_array_equal
(
numpy_inc_subtensor
(
test_array_np
,
[
slice
(
None
),
mask
]
,
1
),
numpy_inc_subtensor
(
test_array_np
,
(
slice
(
None
),
mask
)
,
1
),
inc_subtensor
(
test_array
[:,
mask
],
1
)
.
eval
(),
)
...
...
@@ -657,15 +651,15 @@ class TestSubtensor(utt.OptimizationTestMixin):
numpy_n4
[
test_array_np
>
2
,
...
,
0
,
1
],
n4
[
test_array
>
2
,
...
,
0
,
1
]
.
eval
()
)
assert_array_equal
(
numpy_inc_subtensor
(
numpy_n4
,
[
test_array_np
>
2
,
Ellipsis
]
,
1
),
numpy_inc_subtensor
(
numpy_n4
,
(
test_array_np
>
2
,
Ellipsis
)
,
1
),
inc_subtensor
(
n4
[
test_array
>
2
,
...
],
1
)
.
eval
(),
)
assert_array_equal
(
numpy_inc_subtensor
(
numpy_n4
,
[
test_array_np
>
2
,
Ellipsis
,
1
]
,
1
),
numpy_inc_subtensor
(
numpy_n4
,
(
test_array_np
>
2
,
Ellipsis
,
1
)
,
1
),
inc_subtensor
(
n4
[
test_array
>
2
,
...
,
1
],
1
)
.
eval
(),
)
assert_array_equal
(
numpy_inc_subtensor
(
numpy_n4
,
[
test_array_np
>
2
,
Ellipsis
,
0
,
1
]
,
1
),
numpy_inc_subtensor
(
numpy_n4
,
(
test_array_np
>
2
,
Ellipsis
,
0
,
1
)
,
1
),
inc_subtensor
(
n4
[
test_array
>
2
,
...
,
0
,
1
],
1
)
.
eval
(),
)
...
...
@@ -730,8 +724,6 @@ class TestSubtensor(utt.OptimizationTestMixin):
test_array
.
__getitem__
((
False
,))
with
pytest
.
raises
(
TypeError
):
test_array
.
__getitem__
((
True
,
False
))
with
pytest
.
raises
(
TypeError
):
test_array
.
__getitem__
([
True
,
False
])
with
pytest
.
raises
(
TypeError
):
test_array
.
__getitem__
(([
0
,
1
],
[
0
,
False
]))
with
pytest
.
raises
(
TypeError
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论