Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
52bbf59d
Unverified
提交
52bbf59d
authored
3月 12, 2025
作者:
Abhinav
提交者:
GitHub
3月 12, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify atleast_Nd to accept only one positional argument (#1291)
上级
f10a6036
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
19 行删除
+14
-19
basic.py
pytensor/tensor/basic.py
+12
-18
test_basic.py
tests/tensor/test_basic.py
+2
-1
没有找到文件。
pytensor/tensor/basic.py
浏览文件 @
52bbf59d
...
@@ -4355,28 +4355,22 @@ def empty_like(
...
@@ -4355,28 +4355,22 @@ def empty_like(
def
atleast_Nd
(
def
atleast_Nd
(
*
arys
:
np
.
ndarray
|
TensorVariable
,
n
:
int
=
1
,
left
:
bool
=
True
arry
:
np
.
ndarray
|
TensorVariable
,
*
,
n
:
int
=
1
,
left
:
bool
=
True
)
->
TensorVariable
:
)
->
TensorVariable
:
"""Convert inputs to arrays with at least `n` dimensions."""
"""Convert input to an array with at least `n` dimensions."""
res
=
[]
for
ary
in
arys
:
ary
=
as_tensor
(
ary
)
if
ary
.
ndim
>=
n
:
arry
=
as_tensor
(
arry
)
result
=
ary
else
:
result
=
(
shape_padleft
(
ary
,
n
-
ary
.
ndim
)
if
left
else
shape_padright
(
ary
,
n
-
ary
.
ndim
)
)
res
.
append
(
result
)
if
arry
.
ndim
>=
n
:
result
=
arry
if
len
(
res
)
==
1
:
return
res
[
0
]
else
:
else
:
return
res
result
=
(
shape_padleft
(
arry
,
n
-
arry
.
ndim
)
if
left
else
shape_padright
(
arry
,
n
-
arry
.
ndim
)
)
return
result
atleast_1d
=
partial
(
atleast_Nd
,
n
=
1
)
atleast_1d
=
partial
(
atleast_Nd
,
n
=
1
)
...
...
tests/tensor/test_basic.py
浏览文件 @
52bbf59d
...
@@ -4364,7 +4364,8 @@ def test_atleast_Nd():
...
@@ -4364,7 +4364,8 @@ def test_atleast_Nd():
for
n
in
range
(
1
,
3
):
for
n
in
range
(
1
,
3
):
ary1
,
ary2
=
dscalar
(),
dvector
()
ary1
,
ary2
=
dscalar
(),
dvector
()
res_ary1
,
res_ary2
=
atleast_Nd
(
ary1
,
ary2
,
n
=
n
)
res_ary1
=
atleast_Nd
(
ary1
,
n
=
n
)
res_ary2
=
atleast_Nd
(
ary2
,
n
=
n
)
assert
res_ary1
.
ndim
==
n
assert
res_ary1
.
ndim
==
n
if
n
==
ary2
.
ndim
:
if
n
==
ary2
.
ndim
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论