Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
869d2cb5
提交
869d2cb5
authored
9月 25, 2012
作者:
Matthew Rocklin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
posort docstring
上级
d7df1a98
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
0 行删除
+16
-0
sched.py
theano/gof/sched.py
+16
-0
没有找到文件。
theano/gof/sched.py
浏览文件 @
869d2cb5
...
@@ -87,6 +87,22 @@ def _toposort(edges):
...
@@ -87,6 +87,22 @@ def _toposort(edges):
def
posort
(
l
,
*
cmps
):
def
posort
(
l
,
*
cmps
):
""" Partially ordered sort with multiple comparators
""" Partially ordered sort with multiple comparators
Given a list of comparators order the elements in l so that the comparators
are satisfied as much as possible giving precedence to earlier comparators.
inputs:
l - an iterable of nodes in a graph
cmps - a sequence of comparator functions that describe which nodes
should come before which others
outputs:
a list of nodes which satisfy the comparators as much as possible.
>>> lower_tens = lambda a, b: a/10 - b/10 # prefer lower numbers div 10
>>> prefer evens = lambda a, b: a
%2
- b
%2
# prefer even numbers
>>> posort(range(20), lower_tens, prefer_evens)
[0, 8, 2, 4, 6, 1, 3, 5, 7, 9, 16, 18, 10, 12, 14, 17, 19, 11, 13, 15]
implemented with _toposort """
implemented with _toposort """
comes_before
=
{
a
:
set
()
for
a
in
l
}
comes_before
=
{
a
:
set
()
for
a
in
l
}
comes_after
=
{
a
:
set
()
for
a
in
l
}
comes_after
=
{
a
:
set
()
for
a
in
l
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论