Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9dbfadab
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2292
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9dbfadab
编写于
4月 06, 2023
作者:
N
Nyakku Shigure
提交者:
GitHub
4月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CodeStyle][B017] catch more specific exceptions in unittests (#52553)
上级
160dfd01
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
50 addition
and
66 deletion
+50
-66
pyproject.toml
pyproject.toml
+1
-40
python/paddle/distributed/fleet/base/graphviz.py
python/paddle/distributed/fleet/base/graphviz.py
+7
-11
python/paddle/fluid/tests/unittests/distributed_passes/check_pass_conflict_example.py
...ittests/distributed_passes/check_pass_conflict_example.py
+1
-1
python/paddle/fluid/tests/unittests/ir/inference/test_trt_dynamic_shape.py
...id/tests/unittests/ir/inference/test_trt_dynamic_shape.py
+6
-2
test/dygraph_to_static/test_convert_call_generator.py
test/dygraph_to_static/test_convert_call_generator.py
+12
-2
test/legacy_test/test_transforms.py
test/legacy_test/test_transforms.py
+23
-10
未找到文件。
pyproject.toml
浏览文件 @
9dbfadab
...
...
@@ -41,10 +41,6 @@ select = [
"B002"
,
"B003"
,
"B004"
,
# "B005",
# "B006",
# "B007",
# "B008",
"B009"
,
"B010"
,
"B011"
,
...
...
@@ -53,65 +49,30 @@ select = [
"B014"
,
"B015"
,
"B016"
,
#
"B017",
"B017"
,
"B018"
,
"B019"
,
"B020"
,
"B021"
,
"B022"
,
# "B023",
# "B024",
"B025"
,
# "B026",
# "B027",
# "B028",
"B029"
,
# "B030",
"B032"
,
# "B904",
# Pylint
"PLC0414"
,
# "PLC1901",
"PLC3002"
,
"PLE0100"
,
"PLE0101"
,
# "PLE0116",
# "PLE0117",
# "PLE0118",
"PLE0604"
,
"PLE0605"
,
"PLE1142"
,
"PLE1205"
,
"PLE1206"
,
"PLE1307"
,
# "PLE1310",
# "PLE1507",
"PLE2502"
,
# "PLE2510",
# "PLE2512",
# "PLE2513",
# "PLE2514",
# "PLE2515",
# "PLR0133",
"PLR0206"
,
"PLR0402"
,
# "PLR0911",
# "PLR0912",
# "PLR0913",
# "PLR0915",
# "PLR1701",
# "PLR1711",
# "PLR1722",
# "PLR2004",
# "PLR5501",
# "PLW0120",
# "PLW0129",
# "PLW0602",
# "PLW0603",
# "PLW0711",
# "PLW1508",
# "PLW2901",
]
unfixable
=
[
"NPY001"
...
...
python/paddle/distributed/fleet/base/graphviz.py
浏览文件 @
9dbfadab
...
...
@@ -43,7 +43,7 @@ class Rank:
return
(
'{'
+
'rank={};'
.
format
(
self
.
kind
)
+
f
'rank=
{
self
.
kind
}
;'
+
','
.
join
([
node
.
name
for
node
in
self
.
nodes
])
+
'}'
)
...
...
@@ -97,7 +97,7 @@ class Graph:
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
)
logging
.
warning
(
"write block debug graph to {}"
.
format
(
image_path
)
)
logging
.
warning
(
f
"write block debug graph to
{
image_path
}
"
)
return
image_path
def
show
(
self
,
dot_path
):
...
...
@@ -125,13 +125,11 @@ class Graph:
def
__str__
(
self
):
reprs
=
[
'digraph G {'
,
'title = {}'
.
format
(
crepr
(
self
.
title
))
,
f
'title =
{
crepr
(
self
.
title
)
}
'
,
]
for
attr
in
self
.
attrs
:
reprs
.
append
(
"{key}={value};"
.
format
(
key
=
attr
,
value
=
crepr
(
self
.
attrs
[
attr
]))
)
reprs
.
append
(
f
"
{
attr
}
=
{
crepr
(
self
.
attrs
[
attr
])
}
;"
)
reprs
.
append
(
self
.
_rank_repr
())
...
...
@@ -161,8 +159,7 @@ class Node:
label
=
self
.
label
,
extra
=
','
+
','
.
join
(
"%s=%s"
%
(
key
,
crepr
(
value
))
for
key
,
value
in
self
.
attrs
.
items
()
f
"
{
key
}
=
{
crepr
(
value
)
}
"
for
key
,
value
in
self
.
attrs
.
items
()
)
if
self
.
attrs
else
""
,
...
...
@@ -191,8 +188,7 @@ class Edge:
if
not
self
.
attrs
else
"["
+
','
.
join
(
"{}={}"
.
format
(
attr
[
0
],
crepr
(
attr
[
1
]))
for
attr
in
self
.
attrs
.
items
()
f
"
{
attr
[
0
]
}
=
{
crepr
(
attr
[
1
])
}
"
for
attr
in
self
.
attrs
.
items
()
)
+
"]"
,
)
...
...
@@ -292,5 +288,5 @@ class GraphPreviewGenerator:
source
,
target
,
color
=
"#00000"
if
not
highlight
else
"orange"
,
**
kwargs
**
kwargs
,
)
python/paddle/fluid/tests/unittests/distributed_passes/check_pass_conflict_example.py
浏览文件 @
9dbfadab
...
...
@@ -39,7 +39,7 @@ class CheckPassConflictTest2(PassConflictChecker):
]
def
test_resnet
(
self
):
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaises
(
Exception
):
# noqa: B017
self
.
check_main
(
resnet_model
,
batch_size
=
32
)
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_dynamic_shape.py
浏览文件 @
9dbfadab
...
...
@@ -72,7 +72,9 @@ class TRTDynamicShapeOutOfBound1Test(TRTDynamicShapeTest):
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
use_gpu
=
True
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaisesRegex
(
ValueError
,
"The fed Variable 'data' should have dimensions"
):
self
.
check_output_with_option
(
use_gpu
)
...
...
@@ -99,7 +101,9 @@ class TRTDynamicShapeOutOfBound3Test(TRTDynamicShapeTest):
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
use_gpu
=
True
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaisesRegex
(
ValueError
,
"The fed Variable 'data' should have dimensions"
):
self
.
check_output_with_option
(
use_gpu
)
...
...
test/dygraph_to_static/test_convert_call_generator.py
浏览文件 @
9dbfadab
...
...
@@ -16,11 +16,12 @@ import unittest
import
paddle
from
paddle.jit
import
to_static
from
paddle.jit.dy2static.convert_call_func
import
translator_logger
def
dyfunc_generator
():
for
i
in
range
(
100
):
yield
paddle
.
fluid
.
dygraph
.
to_variable
([
i
]
*
10
)
yield
paddle
.
to_tensor
([
i
]
*
10
)
def
main_func
():
...
...
@@ -31,8 +32,17 @@ def main_func():
class
TestConvertGenerator
(
unittest
.
TestCase
):
def
test_raise_error
(
self
):
with
self
.
assertRaises
(
Exception
):
translator_logger
.
verbosity_level
=
1
with
self
.
assertLogs
(
translator_logger
.
logger_name
,
level
=
'WARNING'
)
as
cm
:
to_static
(
main_func
)()
self
.
assertRegex
(
cm
.
output
[
0
],
"Your function:`dyfunc_generator` doesn't support "
"to transform to static function because it is a "
"generator function"
,
)
if
__name__
==
'__main__'
:
...
...
test/legacy_test/test_transforms.py
浏览文件 @
9dbfadab
...
...
@@ -299,10 +299,10 @@ class TestTransformsCV2(unittest.TestCase):
trans_batch
=
transforms
.
Compose
([
transforms
.
Resize
(
-
1
)])
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaises
(
(
cv2
.
error
,
AssertionError
,
ValueError
)
):
self
.
do_transform
(
trans
)
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaises
(
(
cv2
.
error
,
AssertionError
,
ValueError
)
):
self
.
do_transform
(
trans_batch
)
with
self
.
assertRaises
(
ValueError
):
...
...
@@ -411,22 +411,35 @@ class TestTransformsCV2(unittest.TestCase):
with
self
.
assertRaises
(
NotImplementedError
):
transform
=
transforms
.
BrightnessTransform
(
'0.1'
,
keys
=
'a'
)
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaisesRegex
(
AssertionError
,
"scale should be a tuple or list"
):
transform
=
transforms
.
RandomErasing
(
scale
=
0.5
)
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaisesRegex
(
AssertionError
,
"ratio should be a tuple or list"
):
transform
=
transforms
.
RandomErasing
(
ratio
=
0.8
)
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaisesRegex
(
AssertionError
,
r
"scale should be of kind \(min, max\) and in range \[0, 1\]"
,
):
transform
=
transforms
.
RandomErasing
(
scale
=
(
10
,
0.4
))
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaisesRegex
(
AssertionError
,
r
"ratio should be of kind \(min, max\)"
):
transform
=
transforms
.
RandomErasing
(
ratio
=
(
3.3
,
0.3
))
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaisesRegex
(
AssertionError
,
r
"The probability should be in range \[0, 1\]"
):
transform
=
transforms
.
RandomErasing
(
prob
=
1.5
)
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaisesRegex
(
ValueError
,
r
"value must be 'random' when type is str"
):
transform
=
transforms
.
RandomErasing
(
value
=
"0"
)
def
test_info
(
self
):
...
...
@@ -571,10 +584,10 @@ class TestTransformsTensor(TestTransformsCV2):
trans_batch
=
transforms
.
Compose
([
transforms
.
Resize
(
-
1
)])
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaises
(
(
cv2
.
error
,
AssertionError
,
ValueError
)
):
self
.
do_transform
(
trans
)
with
self
.
assertRaises
(
Exception
):
with
self
.
assertRaises
(
(
cv2
.
error
,
AssertionError
,
ValueError
)
):
self
.
do_transform
(
trans_batch
)
with
self
.
assertRaises
(
ValueError
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录