Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f85a0676
提交
f85a0676
authored
8月 19, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
8月 20, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix remaining dtype warnings in tests.tensor.test_basic
上级
f84d2b00
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
0 行增加
和
83 行删除
+0
-83
test_basic.py
tests/tensor/test_basic.py
+0
-0
test_math.py
tests/tensor/test_math.py
+0
-0
utils.py
tests/tensor/utils.py
+0
-83
没有找到文件。
tests/tensor/test_basic.py
浏览文件 @
f85a0676
差异被折叠。
点击展开。
tests/tensor/test_math.py
浏览文件 @
f85a0676
差异被折叠。
点击展开。
tests/tensor/utils.py
浏览文件 @
f85a0676
...
@@ -109,89 +109,6 @@ def eval_outputs(outputs, ops=(), mode=None):
...
@@ -109,89 +109,6 @@ def eval_outputs(outputs, ops=(), mode=None):
return
variables
return
variables
def
get_numeric_subclasses
(
cls
=
np
.
number
,
ignore
=
None
):
"""Return subclasses of `cls` in the numpy scalar hierarchy.
We only return subclasses that correspond to unique data types. The
hierarchy can be seen here:
http://docs.scipy.org/doc/numpy/reference/arrays.scalars.html
"""
if
ignore
is
None
:
ignore
=
[]
rval
=
[]
dtype
=
np
.
dtype
(
cls
)
dtype_num
=
dtype
.
num
if
dtype_num
not
in
ignore
:
# Safety check: we should be able to represent 0 with this data type.
np
.
array
(
0
,
dtype
=
dtype
)
rval
.
append
(
cls
)
ignore
.
append
(
dtype_num
)
for
sub_
in
cls
.
__subclasses__
():
rval
+=
[
c
for
c
in
get_numeric_subclasses
(
sub_
,
ignore
=
ignore
)]
return
rval
def
get_numeric_types
(
with_int
=
True
,
with_float
=
True
,
with_complex
=
False
,
only_aesara_types
=
True
):
"""Return NumPy numeric data types.
Parameters
----------
with_int
Whether to include integer types.
with_float
Whether to include floating point types.
with_complex
Whether to include complex types.
only_aesara_types
If ``True``, then numpy numeric data types that are not supported by
Aesara are ignored (i.e. those that are not declared in
``scalar/basic.py``).
Returns
-------
A list of unique data type objects. Note that multiple data types may share
the same string representation, but can be differentiated through their
`num` attribute.
Note that when `only_aesara_types` is True we could simply return the list
of types defined in the `scalar` module. However with this function we can
test more unique dtype objects, and in the future we may use it to
automatically detect new data types introduced in numpy.
"""
if
only_aesara_types
:
aesara_types
=
[
d
.
dtype
for
d
in
aesara
.
scalar
.
all_types
]
rval
=
[]
def
is_within
(
cls1
,
cls2
):
# Return True if scalars defined from `cls1` are within the hierarchy
# starting from `cls2`.
# The third test below is to catch for instance the fact that
# one can use ``dtype=numpy.number`` and obtain a float64 scalar, even
# though `numpy.number` is not under `numpy.floating` in the class
# hierarchy.
return
(
cls1
is
cls2
or
issubclass
(
cls1
,
cls2
)
or
isinstance
(
np
.
array
([
0
],
dtype
=
cls1
)[
0
],
cls2
)
)
for
cls
in
get_numeric_subclasses
():
dtype
=
np
.
dtype
(
cls
)
if
(
(
not
with_complex
and
is_within
(
cls
,
np
.
complexfloating
))
or
(
not
with_int
and
is_within
(
cls
,
np
.
integer
))
or
(
not
with_float
and
is_within
(
cls
,
np
.
floating
))
or
(
only_aesara_types
and
dtype
not
in
aesara_types
)
):
# Ignore this class.
continue
rval
.
append
([
str
(
dtype
),
dtype
,
dtype
.
num
])
# We sort it to be deterministic, then remove the string and num elements.
return
[
x
[
1
]
for
x
in
sorted
(
rval
,
key
=
str
)]
def
_numpy_checker
(
x
,
y
):
def
_numpy_checker
(
x
,
y
):
"""Checks if `x.data` and `y.data` have the same contents.
"""Checks if `x.data` and `y.data` have the same contents.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论