Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ff98ab8f
提交
ff98ab8f
authored
5月 31, 2025
作者:
ricardoV94
提交者:
Ricardo Vieira
6月 02, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Coerce dtype __props__ to string due to invalid hash of `np.dtype()` objects
https://github.com/numpy/numpy/issues/17864
上级
864ebd1a
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
25 行增加
和
6 行删除
+25
-6
sp2.py
pytensor/sparse/sandbox/sp2.py
+1
-1
basic.py
pytensor/tensor/basic.py
+7
-2
elemwise.py
pytensor/tensor/elemwise.py
+2
-2
io.py
pytensor/tensor/io.py
+1
-1
op.py
pytensor/tensor/random/op.py
+2
-0
test_basic.py
tests/tensor/test_basic.py
+12
-0
没有找到文件。
pytensor/sparse/sandbox/sp2.py
浏览文件 @
ff98ab8f
...
...
@@ -96,7 +96,7 @@ class Binomial(Op):
def
__init__
(
self
,
format
,
dtype
):
self
.
format
=
format
self
.
dtype
=
dtyp
e
self
.
dtype
=
np
.
dtype
(
dtype
)
.
nam
e
def
make_node
(
self
,
n
,
p
,
shape
):
n
=
pt
.
as_tensor_variable
(
n
)
...
...
pytensor/tensor/basic.py
浏览文件 @
ff98ab8f
...
...
@@ -1090,6 +1090,8 @@ class Tri(Op):
def
__init__
(
self
,
dtype
=
None
):
if
dtype
is
None
:
dtype
=
config
.
floatX
else
:
dtype
=
np
.
dtype
(
dtype
)
.
name
self
.
dtype
=
dtype
def
make_node
(
self
,
N
,
M
,
k
):
...
...
@@ -1368,6 +1370,8 @@ class Eye(Op):
def
__init__
(
self
,
dtype
=
None
):
if
dtype
is
None
:
dtype
=
config
.
floatX
else
:
dtype
=
np
.
dtype
(
dtype
)
.
name
self
.
dtype
=
dtype
def
make_node
(
self
,
n
,
m
,
k
):
...
...
@@ -3225,7 +3229,7 @@ class ARange(COp):
__props__
=
(
"dtype"
,)
def
__init__
(
self
,
dtype
):
self
.
dtype
=
dtyp
e
self
.
dtype
=
np
.
dtype
(
dtype
)
.
nam
e
def
make_node
(
self
,
start
,
stop
,
step
):
from
math
import
ceil
...
...
@@ -3407,7 +3411,8 @@ def arange(start, stop=None, step=1, dtype=None):
# We use the same dtype as numpy instead of the result of
# the upcast.
dtype
=
str
(
numpy_dtype
)
else
:
dtype
=
np
.
dtype
(
dtype
)
.
name
if
dtype
not
in
_arange
:
_arange
[
dtype
]
=
ARange
(
dtype
)
return
_arange
[
dtype
](
start
,
stop
,
step
)
...
...
pytensor/tensor/elemwise.py
浏览文件 @
ff98ab8f
...
...
@@ -1234,8 +1234,8 @@ class CAReduce(COp):
else
:
self
.
axis
=
tuple
(
axis
)
self
.
dtype
=
dtype
self
.
acc_dtype
=
acc_dtype
self
.
dtype
=
dtype
if
dtype
is
None
else
np
.
dtype
(
dtype
)
.
name
self
.
acc_dtype
=
acc_dtype
if
acc_dtype
is
None
else
np
.
dtype
(
acc_dtype
)
.
name
self
.
upcast_discrete_output
=
upcast_discrete_output
@property
...
...
pytensor/tensor/io.py
浏览文件 @
ff98ab8f
...
...
@@ -25,7 +25,7 @@ class LoadFromDisk(Op):
__props__
=
(
"dtype"
,
"shape"
,
"mmap_mode"
)
def
__init__
(
self
,
dtype
,
shape
,
mmap_mode
=
None
):
self
.
dtype
=
np
.
dtype
(
dtype
)
# turn "float64" into np.float64
self
.
dtype
=
np
.
dtype
(
dtype
)
.
name
self
.
shape
=
shape
if
mmap_mode
not
in
(
None
,
"c"
):
raise
ValueError
(
...
...
pytensor/tensor/random/op.py
浏览文件 @
ff98ab8f
...
...
@@ -112,6 +112,8 @@ class RandomVariable(Op):
else
:
self
.
signature
=
safe_signature
(
self
.
ndims_params
,
[
self
.
ndim_supp
])
if
isinstance
(
dtype
,
np
.
dtype
):
dtype
=
dtype
.
name
self
.
dtype
=
dtype
or
getattr
(
self
,
"dtype"
,
None
)
self
.
inplace
=
(
...
...
tests/tensor/test_basic.py
浏览文件 @
ff98ab8f
...
...
@@ -2869,6 +2869,18 @@ class TestARange:
assert
np
.
arange
(
1.3
,
17.48
,
2.67
)
.
shape
==
arange
(
1.3
,
17.48
,
2.67
)
.
type
.
shape
assert
np
.
arange
(
-
64
,
64
)
.
shape
==
arange
(
-
64
,
64
)
.
type
.
shape
def
test_c_cache_bug
(
self
):
# Regression test for bug caused by issues in hash of `np.dtype()` objects
# https://github.com/numpy/numpy/issues/17864
end
=
iscalar
(
"end"
)
arange1
=
ARange
(
np
.
dtype
(
"float64"
))(
0
,
end
,
1
)
arange2
=
ARange
(
"float64"
)(
0
,
end
+
1
,
1
)
assert
arange1
.
owner
.
op
==
arange2
.
owner
.
op
assert
hash
(
arange1
.
owner
.
op
)
==
hash
(
arange2
.
owner
.
op
)
fn
=
function
([
end
],
[
arange1
,
arange2
])
res1
,
res2
=
fn
(
10
)
np
.
testing
.
assert_array_equal
(
res1
,
res2
[:
-
1
],
strict
=
True
)
class
TestNdGrid
:
def
setup_method
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论