Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7393b744
提交
7393b744
authored
6月 24, 2022
作者:
Adrian Seyboldt
提交者:
Ricardo Vieira
6月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow subtypes by default in make_node
上级
d6858fe2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
5 行删除
+19
-5
op.py
aesara/graph/op.py
+6
-5
test_op.py
tests/graph/test_op.py
+13
-0
没有找到文件。
aesara/graph/op.py
浏览文件 @
7393b744
...
@@ -222,21 +222,22 @@ class Op(MetaObject):
...
@@ -222,21 +222,22 @@ class Op(MetaObject):
"""
"""
if
self
.
itypes
is
None
:
if
self
.
itypes
is
None
:
raise
NotImplementedError
(
raise
NotImplementedError
(
"You can either define itypes and otypes,
\
"You can either define itypes and otypes, or implement make_node"
or implement make_node"
)
)
if
self
.
otypes
is
None
:
if
self
.
otypes
is
None
:
raise
NotImplementedError
(
raise
NotImplementedError
(
"You can either define itypes and otypes,
\
"You can either define itypes and otypes, or implement make_node"
or implement make_node"
)
)
if
len
(
inputs
)
!=
len
(
self
.
itypes
):
if
len
(
inputs
)
!=
len
(
self
.
itypes
):
raise
ValueError
(
raise
ValueError
(
f
"We expected {len(self.itypes)} inputs but got {len(inputs)}."
f
"We expected {len(self.itypes)} inputs but got {len(inputs)}."
)
)
if
not
all
(
it
.
in_same_class
(
inp
.
type
)
for
inp
,
it
in
zip
(
inputs
,
self
.
itypes
)):
if
not
all
(
expected_type
.
is_super
(
var
.
type
)
for
var
,
expected_type
in
zip
(
inputs
,
self
.
itypes
)
):
raise
TypeError
(
raise
TypeError
(
f
"Invalid input types for Op {self}:
\n
"
f
"Invalid input types for Op {self}:
\n
"
+
"
\n
"
.
join
(
+
"
\n
"
.
join
(
...
...
tests/graph/test_op.py
浏览文件 @
7393b744
...
@@ -223,3 +223,16 @@ def test_op_invalid_input_types():
...
@@ -223,3 +223,16 @@ def test_op_invalid_input_types():
msg
=
r"^Invalid input types for Op.*"
msg
=
r"^Invalid input types for Op.*"
with
pytest
.
raises
(
TypeError
,
match
=
msg
):
with
pytest
.
raises
(
TypeError
,
match
=
msg
):
TestOp
()(
dvector
(),
dscalar
(),
dvector
())
TestOp
()(
dvector
(),
dscalar
(),
dvector
())
def
test_op_input_broadcastable
():
# Test that we can create an op with a broadcastable subtype as input
class
SomeOp
(
aesara
.
tensor
.
Op
):
itypes
=
[
at
.
dvector
]
otypes
=
[
at
.
dvector
]
def
perform
(
self
,
*
_
):
raise
NotImplementedError
()
x
=
at
.
TensorType
(
dtype
=
"float64"
,
shape
=
(
1
,))(
"x"
)
assert
SomeOp
()(
x
)
.
type
==
at
.
dvector
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论