Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9a124cac
提交
9a124cac
authored
9月 02, 2025
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
9月 20, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Scipy is not optional
上级
27d79707
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
12 行增加
和
19 行删除
+12
-19
test_basic.py
tests/link/numba/test_basic.py
+1
-1
test_math_scipy.py
tests/tensor/test_math_scipy.py
+5
-10
test_basic.py
tests/typed_list/test_basic.py
+6
-8
没有找到文件。
tests/link/numba/test_basic.py
浏览文件 @
9a124cac
...
@@ -6,9 +6,9 @@ from unittest import mock
...
@@ -6,9 +6,9 @@ from unittest import mock
import
numpy
as
np
import
numpy
as
np
import
pytest
import
pytest
import
scipy
from
pytensor.compile
import
SymbolicInput
from
pytensor.compile
import
SymbolicInput
from
tests.tensor.test_math_scipy
import
scipy
numba
=
pytest
.
importorskip
(
"numba"
)
numba
=
pytest
.
importorskip
(
"numba"
)
...
...
tests/tensor/test_math_scipy.py
浏览文件 @
9a124cac
import
warnings
import
warnings
from
functools
import
partial
import
numpy
as
np
import
numpy
as
np
import
pytest
import
pytest
import
scipy
from
pytensor.gradient
import
NullTypeGradError
,
verify_grad
from
pytensor.scalar
import
ScalarLoop
from
pytensor.tensor.elemwise
import
Elemwise
scipy
=
pytest
.
importorskip
(
"scipy"
)
from
functools
import
partial
from
scipy
import
special
,
stats
from
scipy
import
special
,
stats
from
pytensor
import
function
,
grad
from
pytensor
import
function
,
grad
from
pytensor
import
tensor
as
pt
from
pytensor
import
tensor
as
pt
from
pytensor.compile.mode
import
get_default_mode
from
pytensor.compile.mode
import
get_default_mode
from
pytensor.configdefaults
import
config
from
pytensor.configdefaults
import
config
from
pytensor.gradient
import
NullTypeGradError
,
verify_grad
from
pytensor.scalar
import
ScalarLoop
from
pytensor.tensor
import
gammaincc
,
inplace
,
kn
,
kv
,
kve
,
vector
from
pytensor.tensor
import
gammaincc
,
inplace
,
kn
,
kv
,
kve
,
vector
from
pytensor.tensor.elemwise
import
Elemwise
from
tests
import
unittest_tools
as
utt
from
tests
import
unittest_tools
as
utt
from
tests.tensor.utils
import
(
from
tests.tensor.utils
import
(
_good_broadcast_unary_chi2sf
,
_good_broadcast_unary_chi2sf
,
...
...
tests/typed_list/test_basic.py
浏览文件 @
9a124cac
import
numpy
as
np
import
numpy
as
np
import
pytest
import
pytest
import
scipy
import
pytensor
import
pytensor
import
pytensor.typed_list
import
pytensor.typed_list
...
@@ -37,8 +38,7 @@ def rand_ranged_matrix(minimum, maximum, shape):
...
@@ -37,8 +38,7 @@ def rand_ranged_matrix(minimum, maximum, shape):
def
random_lil
(
shape
,
dtype
,
nnz
):
def
random_lil
(
shape
,
dtype
,
nnz
):
sp
=
pytest
.
importorskip
(
"scipy"
)
rval
=
scipy
.
sparse
.
lil_matrix
(
shape
,
dtype
=
dtype
)
rval
=
sp
.
sparse
.
lil_matrix
(
shape
,
dtype
=
dtype
)
huge
=
2
**
30
huge
=
2
**
30
for
k
in
range
(
nnz
):
for
k
in
range
(
nnz
):
# set non-zeros in random locations (row x, col y)
# set non-zeros in random locations (row x, col y)
...
@@ -451,7 +451,6 @@ class TestIndex:
...
@@ -451,7 +451,6 @@ class TestIndex:
assert
f
([[
x
,
y
],
[
x
,
y
,
y
]],
[
x
,
y
])
==
0
assert
f
([[
x
,
y
],
[
x
,
y
,
y
]],
[
x
,
y
])
==
0
def
test_sparse
(
self
):
def
test_sparse
(
self
):
sp
=
pytest
.
importorskip
(
"scipy"
)
mySymbolicSparseList
=
TypedListType
(
mySymbolicSparseList
=
TypedListType
(
sparse
.
SparseTensorType
(
"csr"
,
pytensor
.
config
.
floatX
)
sparse
.
SparseTensorType
(
"csr"
,
pytensor
.
config
.
floatX
)
)()
)()
...
@@ -461,8 +460,8 @@ class TestIndex:
...
@@ -461,8 +460,8 @@ class TestIndex:
f
=
pytensor
.
function
([
mySymbolicSparseList
,
mySymbolicSparse
],
z
)
f
=
pytensor
.
function
([
mySymbolicSparseList
,
mySymbolicSparse
],
z
)
x
=
s
p
.
sparse
.
csr_matrix
(
random_lil
((
10
,
40
),
pytensor
.
config
.
floatX
,
3
))
x
=
s
cipy
.
sparse
.
csr_matrix
(
random_lil
((
10
,
40
),
pytensor
.
config
.
floatX
,
3
))
y
=
s
p
.
sparse
.
csr_matrix
(
random_lil
((
10
,
40
),
pytensor
.
config
.
floatX
,
3
))
y
=
s
cipy
.
sparse
.
csr_matrix
(
random_lil
((
10
,
40
),
pytensor
.
config
.
floatX
,
3
))
assert
f
([
x
,
y
],
y
)
==
1
assert
f
([
x
,
y
],
y
)
==
1
...
@@ -519,7 +518,6 @@ class TestCount:
...
@@ -519,7 +518,6 @@ class TestCount:
assert
f
([[
x
,
y
],
[
x
,
y
,
y
]],
[
x
,
y
])
==
1
assert
f
([[
x
,
y
],
[
x
,
y
,
y
]],
[
x
,
y
])
==
1
def
test_sparse
(
self
):
def
test_sparse
(
self
):
sp
=
pytest
.
importorskip
(
"scipy"
)
mySymbolicSparseList
=
TypedListType
(
mySymbolicSparseList
=
TypedListType
(
sparse
.
SparseTensorType
(
"csr"
,
pytensor
.
config
.
floatX
)
sparse
.
SparseTensorType
(
"csr"
,
pytensor
.
config
.
floatX
)
)()
)()
...
@@ -529,8 +527,8 @@ class TestCount:
...
@@ -529,8 +527,8 @@ class TestCount:
f
=
pytensor
.
function
([
mySymbolicSparseList
,
mySymbolicSparse
],
z
)
f
=
pytensor
.
function
([
mySymbolicSparseList
,
mySymbolicSparse
],
z
)
x
=
s
p
.
sparse
.
csr_matrix
(
random_lil
((
10
,
40
),
pytensor
.
config
.
floatX
,
3
))
x
=
s
cipy
.
sparse
.
csr_matrix
(
random_lil
((
10
,
40
),
pytensor
.
config
.
floatX
,
3
))
y
=
s
p
.
sparse
.
csr_matrix
(
random_lil
((
10
,
40
),
pytensor
.
config
.
floatX
,
3
))
y
=
s
cipy
.
sparse
.
csr_matrix
(
random_lil
((
10
,
40
),
pytensor
.
config
.
floatX
,
3
))
assert
f
([
x
,
y
,
y
],
y
)
==
2
assert
f
([
x
,
y
,
y
],
y
)
==
2
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论