Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
c6105449
M
mindinsight
项目概览
MindSpore
/
mindinsight
通知
8
Star
4
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindinsight
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c6105449
编写于
6月 29, 2020
作者:
W
wenkai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix ZeroDivisionError when original bucket width is 0 by checking the width.
上级
f57e0271
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
1 deletion
+24
-1
mindinsight/datavisual/data_transform/histogram_container.py
mindinsight/datavisual/data_transform/histogram_container.py
+4
-1
tests/ut/datavisual/data_transform/test_histogram_container.py
.../ut/datavisual/data_transform/test_histogram_container.py
+20
-0
未找到文件。
mindinsight/datavisual/data_transform/histogram_container.py
浏览文件 @
c6105449
...
@@ -225,7 +225,10 @@ class HistogramContainer:
...
@@ -225,7 +225,10 @@ class HistogramContainer:
intersection
=
self
.
_calc_intersection_len
(
intersection
=
self
.
_calc_intersection_len
(
min1
=
cur_left
,
max1
=
cur_right
,
min1
=
cur_left
,
max1
=
cur_right
,
min2
=
original_bucket
.
left
,
max2
=
original_bucket
.
right
)
min2
=
original_bucket
.
left
,
max2
=
original_bucket
.
right
)
estimated_count
=
(
intersection
/
original_bucket
.
width
)
*
original_bucket
.
count
if
not
original_bucket
.
width
:
estimated_count
=
original_bucket
.
count
else
:
estimated_count
=
(
intersection
/
original_bucket
.
width
)
*
original_bucket
.
count
cur_estimated_count
+=
estimated_count
cur_estimated_count
+=
estimated_count
if
cur_right
>
original_bucket
.
right
:
if
cur_right
>
original_bucket
.
right
:
...
...
tests/ut/datavisual/data_transform/test_histogram_container.py
浏览文件 @
c6105449
...
@@ -83,3 +83,23 @@ class TestHistogram:
...
@@ -83,3 +83,23 @@ class TestHistogram:
assert
buckets
==
(
assert
buckets
==
(
(
-
1.0
,
0.8
,
0
),
(
-
0.19999999999999996
,
0.8
,
1
),
(
0.6000000000000001
,
0.8
,
5
),
(
1.4000000000000004
,
0.8
,
6
),
(
-
1.0
,
0.8
,
0
),
(
-
0.19999999999999996
,
0.8
,
1
),
(
0.6000000000000001
,
0.8
,
5
),
(
1.4000000000000004
,
0.8
,
6
),
(
2.2
,
0.8
,
0
))
(
2.2
,
0.8
,
0
))
def
test_re_sample_buckets_zero_width
(
self
):
"""Test zero width bucket when re-sampling."""
mocked_input
=
mock
.
MagicMock
()
mocked_bucket
=
mock
.
MagicMock
()
mocked_bucket
.
left
=
0
mocked_bucket
.
width
=
1
mocked_bucket
.
count
=
1
mocked_bucket2
=
mock
.
MagicMock
()
mocked_bucket2
.
left
=
1
mocked_bucket2
.
width
=
0
mocked_bucket2
.
count
=
2
mocked_input
.
buckets
=
[
mocked_bucket
,
mocked_bucket2
]
histogram
=
hist
.
HistogramContainer
(
mocked_input
)
histogram
.
set_visual_range
(
max_val
=
2
,
min_val
=
0
,
bins
=
3
)
buckets
=
histogram
.
buckets
()
assert
buckets
==
(
(
0.0
,
0.6666666666666666
,
1
),
(
0.6666666666666666
,
0.6666666666666666
,
3
),
(
1.3333333333333333
,
0.6666666666666666
,
0
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录