Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ad8c564c
提交
ad8c564c
authored
2月 24, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wrapping ResultBase._data, more tests
上级
6ce2678b
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
6 行删除
+28
-6
core.py
core.py
+2
-0
result.py
gof/result.py
+26
-6
没有找到文件。
core.py
浏览文件 @
ad8c564c
...
@@ -1508,6 +1508,8 @@ sqr_inplace = sqr.inplace_version()
...
@@ -1508,6 +1508,8 @@ sqr_inplace = sqr.inplace_version()
sqr_inplace
.
set_impl
(
lambda
x
:
x
.
__imul__
(
x
))
sqr_inplace
.
set_impl
(
lambda
x
:
x
.
__imul__
(
x
))
class
sqrt
(
elemwise
):
class
sqrt
(
elemwise
):
impl
=
numpy
.
sqrt
impl
=
numpy
.
sqrt
def
grad
(
x
,
gz
):
def
grad
(
x
,
gz
):
...
...
gof/result.py
浏览文件 @
ad8c564c
...
@@ -104,14 +104,15 @@ class ResultBase(object):
...
@@ -104,14 +104,15 @@ class ResultBase(object):
def
__init__
(
self
,
role
=
None
,
data
=
None
,
constant
=
False
):
def
__init__
(
self
,
role
=
None
,
data
=
None
,
constant
=
False
):
self
.
_role
=
role
self
.
_role
=
role
self
.
constant
=
constant
self
.
constant
=
constant
self
.
_data
=
[
None
]
if
data
is
None
:
#None is not filtered
if
data
is
None
:
#None is not filtered
self
.
_data
=
None
self
.
_data
[
0
]
=
None
self
.
state
=
Empty
self
.
state
=
Empty
else
:
else
:
try
:
try
:
self
.
_data
=
self
.
data_filter
(
data
)
self
.
_data
[
0
]
=
self
.
data_filter
(
data
)
except
ResultBase
.
AbstractFunction
:
except
ResultBase
.
AbstractFunction
:
self
.
_data
=
data
self
.
_data
[
0
]
=
data
self
.
state
=
Computed
self
.
state
=
Computed
#
#
...
@@ -165,15 +166,19 @@ class ResultBase(object):
...
@@ -165,15 +166,19 @@ class ResultBase(object):
#
#
def
__get_data
(
self
):
def
__get_data
(
self
):
return
self
.
_data
return
self
.
_data
[
0
]
def
__set_data
(
self
,
data
):
def
__set_data
(
self
,
data
):
if
self
.
replaced
:
raise
ResultBase
.
BrokenLinkError
()
if
self
.
replaced
:
raise
ResultBase
.
BrokenLinkError
()
if
self
.
constant
:
raise
Exception
(
'cannot set constant ResultBase'
)
if
self
.
constant
:
raise
Exception
(
'cannot set constant ResultBase'
)
if
data
is
None
:
self
.
_data
[
0
]
=
None
self
.
state
=
Empty
return
try
:
try
:
self
.
_data
=
self
.
data_filter
(
data
)
self
.
_data
[
0
]
=
self
.
data_filter
(
data
)
except
ResultBase
.
AbstractFunction
:
#use default behaviour
except
ResultBase
.
AbstractFunction
:
#use default behaviour
self
.
_data
=
data
self
.
_data
[
0
]
=
data
self
.
state
=
Computed
self
.
state
=
Computed
data
=
property
(
__get_data
,
__set_data
,
data
=
property
(
__get_data
,
__set_data
,
...
@@ -240,8 +245,23 @@ class ResultBase(object):
...
@@ -240,8 +245,23 @@ class ResultBase(object):
class
_test_ResultBase
(
unittest
.
TestCase
):
class
_test_ResultBase
(
unittest
.
TestCase
):
def
test_0
(
self
):
def
test_0
(
self
):
r
=
ResultBase
()
r
=
ResultBase
()
def
test_1
(
self
):
r
=
ResultBase
()
assert
r
.
state
is
Empty
r
.
data
=
0
assert
r
.
data
==
0
assert
r
.
state
is
Computed
r
.
data
=
1
assert
r
.
data
==
1
assert
r
.
state
is
Computed
r
.
data
=
None
assert
r
.
data
==
None
assert
r
.
state
is
Empty
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论