Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5a1a147d
提交
5a1a147d
authored
1月 06, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
1月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make MetaType extend ABCMeta
This causes `abstractmethod`-decorated methods to take effect (i.e. classes that don't implement these required methods will fail during construction).
上级
f98754f1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
9 行增加
和
2 行删除
+9
-2
test_graph.py
tests/gof/test_graph.py
+3
-0
test_toolbox.py
tests/gof/test_toolbox.py
+3
-0
utils.py
theano/gof/utils.py
+3
-2
没有找到文件。
tests/gof/test_graph.py
浏览文件 @
5a1a147d
...
@@ -30,6 +30,9 @@ class MyType(Type):
...
@@ -30,6 +30,9 @@ class MyType(Type):
def
__init__
(
self
,
thingy
):
def
__init__
(
self
,
thingy
):
self
.
thingy
=
thingy
self
.
thingy
=
thingy
def
filter
(
self
,
*
args
,
**
kwargs
):
raise
NotImplementedError
()
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
return
isinstance
(
other
,
MyType
)
and
other
.
thingy
==
self
.
thingy
return
isinstance
(
other
,
MyType
)
and
other
.
thingy
==
self
.
thingy
...
...
tests/gof/test_toolbox.py
浏览文件 @
5a1a147d
...
@@ -12,6 +12,9 @@ class TestNodeFinder:
...
@@ -12,6 +12,9 @@ class TestNodeFinder:
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
name
=
name
self
.
name
=
name
def
filter
(
self
,
*
args
,
**
kwargs
):
raise
NotImplementedError
()
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
...
...
theano/gof/utils.py
浏览文件 @
5a1a147d
import
linecache
import
linecache
import
sys
import
sys
import
traceback
import
traceback
from
abc
import
ABCMeta
from
io
import
StringIO
from
io
import
StringIO
...
@@ -157,7 +158,7 @@ class MethodNotDefined(Exception):
...
@@ -157,7 +158,7 @@ class MethodNotDefined(Exception):
"""
"""
class
MetaType
(
type
):
class
MetaType
(
ABCMeta
):
def
__new__
(
cls
,
name
,
bases
,
dct
):
def
__new__
(
cls
,
name
,
bases
,
dct
):
props
=
dct
.
get
(
"__props__"
,
None
)
props
=
dct
.
get
(
"__props__"
,
None
)
if
props
is
not
None
:
if
props
is
not
None
:
...
@@ -220,7 +221,7 @@ class MetaType(type):
...
@@ -220,7 +221,7 @@ class MetaType(type):
dct
[
"__str__"
]
=
__str__
dct
[
"__str__"
]
=
__str__
return
type
.
__new__
(
cls
,
name
,
bases
,
dct
)
return
super
()
.
__new__
(
cls
,
name
,
bases
,
dct
)
class
MetaObject
(
metaclass
=
MetaType
):
class
MetaObject
(
metaclass
=
MetaType
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论