Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9ac18dc1
提交
9ac18dc1
authored
5月 20, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
5月 20, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add missing properties to copied Function objects
上级
104dc037
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
18 行删除
+28
-18
types.py
aesara/compile/function/types.py
+2
-0
test_types.py
tests/compile/function/test_types.py
+26
-18
没有找到文件。
aesara/compile/function/types.py
浏览文件 @
9ac18dc1
...
@@ -785,6 +785,8 @@ class Function:
...
@@ -785,6 +785,8 @@ class Function:
f_cpy
.
finder
[
swap
[
in_ori
.
variable
]]
=
container
f_cpy
.
finder
[
swap
[
in_ori
.
variable
]]
=
container
in_cpy
.
variable
=
swap
[
in_ori
.
variable
]
in_cpy
.
variable
=
swap
[
in_ori
.
variable
]
f_cpy
.
trust_input
=
self
.
trust_input
f_cpy
.
unpack_single
=
self
.
unpack_single
f_cpy
.
name
=
name
f_cpy
.
name
=
name
f_cpy
.
maker
.
fgraph
.
name
=
name
f_cpy
.
maker
.
fgraph
.
name
=
name
return
f_cpy
return
f_cpy
...
...
tests/compile/function/test_types.py
浏览文件 @
9ac18dc1
...
@@ -299,7 +299,7 @@ class TestFunction:
...
@@ -299,7 +299,7 @@ class TestFunction:
t
()
t
()
def
test_copy
(
self
):
def
test_copy
(
self
):
a
=
scalar
()
# the a is for 'anonymous' (un-named).
a
=
scalar
()
x
,
s
=
scalars
(
"xs"
)
x
,
s
=
scalars
(
"xs"
)
f
=
function
(
f
=
function
(
...
@@ -312,26 +312,34 @@ class TestFunction:
...
@@ -312,26 +312,34 @@ class TestFunction:
)
)
g
=
copy
.
copy
(
f
)
g
=
copy
.
copy
(
f
)
# if they both return, assume that they return equivalent things.
assert
f
.
unpack_single
==
g
.
unpack_single
assert
f
.
trust_input
==
g
.
trust_input
assert
g
.
container
[
x
]
.
storage
is
not
f
.
container
[
x
]
.
storage
assert
g
.
container
[
x
]
.
storage
is
not
f
.
container
[
x
]
.
storage
assert
g
.
container
[
a
]
.
storage
is
not
f
.
container
[
a
]
.
storage
assert
g
.
container
[
a
]
.
storage
is
not
f
.
container
[
a
]
.
storage
assert
g
.
container
[
s
]
.
storage
is
not
f
.
container
[
s
]
.
storage
assert
g
.
container
[
s
]
.
storage
is
not
f
.
container
[
s
]
.
storage
assert
g
.
value
[
a
]
is
f
.
value
[
a
]
# should not have been copied
# Should not have been copied
assert
(
assert
g
.
value
[
a
]
is
f
.
value
[
a
]
g
.
value
[
s
]
is
not
f
.
value
[
s
]
)
# should have been copied because it is mutable.
assert
not
(
g
.
value
[
s
]
!=
f
.
value
[
s
])
.
any
()
# its contents should be identical
assert
f
(
2
,
1
)
==
g
(
# Should have been copied because it is mutable
2
assert
g
.
value
[
s
]
is
not
f
.
value
[
s
]
)
# they should be in sync, default value should be copied.
assert
f
(
2
,
1
)
==
g
(
# Their contents should be equal, though
2
assert
np
.
array_equal
(
g
.
value
[
s
],
f
.
value
[
s
])
)
# they should be in sync, default value should be copied.
f
(
1
,
2
)
# put them out of sync
# They should be in sync, default value should be copied
assert
f
(
1
,
2
)
!=
g
(
1
,
2
)
# they should not be equal anymore.
assert
np
.
array_equal
(
f
(
2
,
1
),
g
(
2
))
# They should be in sync, default value should be copied
assert
np
.
array_equal
(
f
(
2
,
1
),
g
(
2
))
# Put them out of sync
f
(
1
,
2
)
# They should not be equal anymore
assert
not
np
.
array_equal
(
f
(
1
,
2
),
g
(
1
,
2
))
def
test_copy_share_memory
(
self
):
def
test_copy_share_memory
(
self
):
x
=
fscalar
(
"x"
)
x
=
fscalar
(
"x"
)
...
@@ -478,9 +486,9 @@ class TestFunction:
...
@@ -478,9 +486,9 @@ class TestFunction:
ori
=
function
([
x
],
out
,
mode
=
mode
,
updates
=
{
z
:
z
*
2
})
ori
=
function
([
x
],
out
,
mode
=
mode
,
updates
=
{
z
:
z
*
2
})
cpy
=
ori
.
copy
(
delete_updates
=
True
)
cpy
=
ori
.
copy
(
delete_updates
=
True
)
assert
cpy
(
1
)
[
0
]
==
4
assert
cpy
(
1
)
==
4
assert
cpy
(
1
)
[
0
]
==
4
assert
cpy
(
1
)
==
4
assert
cpy
(
1
)
[
0
]
==
4
assert
cpy
(
1
)
==
4
# Test if unused implicit and explicit inputs from delete_updates
# Test if unused implicit and explicit inputs from delete_updates
# are ignored as intended.
# are ignored as intended.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论