Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
00a23bdd
提交
00a23bdd
authored
1月 20, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Whitespace fix
上级
e65a79fb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
14 行删除
+13
-14
type.py
theano/gof/type.py
+13
-14
没有找到文件。
theano/gof/type.py
浏览文件 @
00a23bdd
...
@@ -42,15 +42,15 @@ class CLinkerType(CLinkerObject):
...
@@ -42,15 +42,15 @@ class CLinkerType(CLinkerObject):
:Exceptions:
:Exceptions:
- `MethodNotDefined`: Subclass does not implement this method
- `MethodNotDefined`: Subclass does not implement this method
"""
"""
raise
MethodNotDefined
(
"c_literal"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_literal"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_declare
(
self
,
name
,
sub
):
def
c_declare
(
self
,
name
,
sub
):
"""Required: Return c code to declare variables that will be
"""Required: Return c code to declare variables that will be
instantiated by `c_extract`.
instantiated by `c_extract`.
Example:
Example:
.. code-block: python
.. code-block: python
return "PyObject ** addr_of_
%(name)
s;"
return "PyObject ** addr_of_
%(name)
s;"
...
@@ -82,7 +82,7 @@ class CLinkerType(CLinkerObject):
...
@@ -82,7 +82,7 @@ class CLinkerType(CLinkerObject):
"""Required: Return c code to initialize the variables that were declared by
"""Required: Return c code to initialize the variables that were declared by
self.c_declare()
self.c_declare()
Example:
Example:
.. code-block: python
.. code-block: python
return "addr_of_
%(name)
s = NULL;"
return "addr_of_
%(name)
s = NULL;"
...
@@ -110,7 +110,7 @@ class CLinkerType(CLinkerObject):
...
@@ -110,7 +110,7 @@ class CLinkerType(CLinkerObject):
by this function. --jpt
by this function. --jpt
Example:
Example:
.. code-block: python
.. code-block: python
return "if (py_
%(name)
s == Py_None)" +
\\\
return "if (py_
%(name)
s == Py_None)" +
\\\
...
@@ -133,7 +133,7 @@ class CLinkerType(CLinkerObject):
...
@@ -133,7 +133,7 @@ class CLinkerType(CLinkerObject):
"""
"""
raise
MethodNotDefined
(
"c_extract"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_extract"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_cleanup
(
self
,
name
,
sub
):
def
c_cleanup
(
self
,
name
,
sub
):
"""Optional: Return c code to clean up after `c_extract`.
"""Optional: Return c code to clean up after `c_extract`.
...
@@ -206,7 +206,7 @@ class PureType(object):
...
@@ -206,7 +206,7 @@ class PureType(object):
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
"""Required: Return data or an appropriately wrapped/converted data.
"""Required: Return data or an appropriately wrapped/converted data.
Subclass implementation should raise a TypeError exception if the data is not of an
Subclass implementation should raise a TypeError exception if the data is not of an
acceptable type.
acceptable type.
...
@@ -231,7 +231,7 @@ class PureType(object):
...
@@ -231,7 +231,7 @@ class PureType(object):
return
True
return
True
except
(
TypeError
,
ValueError
):
except
(
TypeError
,
ValueError
):
return
False
return
False
def
value_validity_msg
(
self
,
a
):
def
value_validity_msg
(
self
,
a
):
"""Optional: return a message explaining the output of is_valid_value"""
"""Optional: return a message explaining the output of is_valid_value"""
return
"none"
return
"none"
...
@@ -249,7 +249,7 @@ class PureType(object):
...
@@ -249,7 +249,7 @@ class PureType(object):
def
make_constant
(
self
,
value
,
name
=
None
):
def
make_constant
(
self
,
value
,
name
=
None
):
return
self
.
Constant
(
type
=
self
,
data
=
value
,
name
=
name
)
return
self
.
Constant
(
type
=
self
,
data
=
value
,
name
=
name
)
def
__call__
(
self
,
name
=
None
):
def
__call__
(
self
,
name
=
None
):
"""Return a new `Variable` instance of Type `self`.
"""Return a new `Variable` instance of Type `self`.
...
@@ -331,7 +331,7 @@ class Type(object2, PureType, CLinkerType):
...
@@ -331,7 +331,7 @@ class Type(object2, PureType, CLinkerType):
class
SingletonType
(
Type
):
class
SingletonType
(
Type
):
"""Convenient Base class for a Type subclass with no attributes
"""Convenient Base class for a Type subclass with no attributes
It saves having to implement __eq__ and __hash__
It saves having to implement __eq__ and __hash__
"""
"""
__instance
=
None
__instance
=
None
...
@@ -348,13 +348,13 @@ class Generic(SingletonType):
...
@@ -348,13 +348,13 @@ class Generic(SingletonType):
Represents a generic Python object.
Represents a generic Python object.
This class implements the `PureType` and `CLinkerType` interfaces for generic PyObject
This class implements the `PureType` and `CLinkerType` interfaces for generic PyObject
instances.
instances.
EXAMPLE of what this means, or when you would use this type.
EXAMPLE of what this means, or when you would use this type.
WRITEME
WRITEME
"""
"""
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
return
data
return
data
...
@@ -376,7 +376,7 @@ class Generic(SingletonType):
...
@@ -376,7 +376,7 @@ class Generic(SingletonType):
Py_INCREF(py_
%(name)
s);
Py_INCREF(py_
%(name)
s);
%(name)
s = py_
%(name)
s;
%(name)
s = py_
%(name)
s;
"""
%
locals
()
"""
%
locals
()
def
c_cleanup
(
self
,
name
,
sub
):
def
c_cleanup
(
self
,
name
,
sub
):
return
"""
return
"""
Py_XDECREF(
%(name)
s);
Py_XDECREF(
%(name)
s);
...
@@ -391,4 +391,3 @@ class Generic(SingletonType):
...
@@ -391,4 +391,3 @@ class Generic(SingletonType):
"""
%
locals
()
"""
%
locals
()
generic
=
Generic
()
generic
=
Generic
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论