Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
85e20755
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
85e20755
编写于
3月 25, 2023
作者:
张
张春乔
提交者:
GitHub
3月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CodeStyle][UP028] using yield from (#52059)
上级
33b289d7
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
17 addition
and
33 deletion
+17
-33
pyproject.toml
pyproject.toml
+1
-1
python/paddle/dataset/imdb.py
python/paddle/dataset/imdb.py
+1
-2
python/paddle/distributed/fleet/data_generator/data_generator.py
...paddle/distributed/fleet/data_generator/data_generator.py
+1
-2
python/paddle/fluid/tests/unittests/dist_text_classification.py
.../paddle/fluid/tests/unittests/dist_text_classification.py
+1
-2
python/paddle/fluid/tests/unittests/feed_data_reader.py
python/paddle/fluid/tests/unittests/feed_data_reader.py
+1
-2
python/paddle/fluid/tests/unittests/test_imperative_decorator.py
...paddle/fluid/tests/unittests/test_imperative_decorator.py
+6
-12
python/paddle/fluid/tests/unittests/test_parallel_executor_transformer.py
...uid/tests/unittests/test_parallel_executor_transformer.py
+1
-2
python/paddle/nn/layer/layers.py
python/paddle/nn/layer/layers.py
+1
-2
python/paddle/reader/decorator.py
python/paddle/reader/decorator.py
+3
-6
python/paddle/utils/layers_utils.py
python/paddle/utils/layers_utils.py
+1
-2
未找到文件。
pyproject.toml
浏览文件 @
85e20755
...
@@ -70,7 +70,7 @@ select = [
...
@@ -70,7 +70,7 @@ select = [
"UP025"
,
"UP025"
,
"UP026"
,
"UP026"
,
# "UP027",
# "UP027",
#
"UP028",
"UP028"
,
"UP029"
,
"UP029"
,
# "UP030",
# "UP030",
# "UP031",
# "UP031",
...
...
python/paddle/dataset/imdb.py
浏览文件 @
85e20755
...
@@ -93,8 +93,7 @@ def reader_creator(pos_pattern, neg_pattern, word_idx):
...
@@ -93,8 +93,7 @@ def reader_creator(pos_pattern, neg_pattern, word_idx):
load
(
neg_pattern
,
INS
,
1
)
load
(
neg_pattern
,
INS
,
1
)
def
reader
():
def
reader
():
for
doc
,
label
in
INS
:
yield
from
INS
yield
doc
,
label
return
reader
return
reader
...
...
python/paddle/distributed/fleet/data_generator/data_generator.py
浏览文件 @
85e20755
...
@@ -228,8 +228,7 @@ class DataGenerator:
...
@@ -228,8 +228,7 @@ class DataGenerator:
'''
'''
def
local_iter
():
def
local_iter
():
for
sample
in
samples
:
yield
from
samples
yield
sample
return
local_iter
return
local_iter
...
...
python/paddle/fluid/tests/unittests/dist_text_classification.py
浏览文件 @
85e20755
...
@@ -192,8 +192,7 @@ def reader_creator(pos_pattern, neg_pattern, word_idx):
...
@@ -192,8 +192,7 @@ def reader_creator(pos_pattern, neg_pattern, word_idx):
load
(
neg_pattern
,
INS
,
1
)
load
(
neg_pattern
,
INS
,
1
)
def
reader
():
def
reader
():
for
doc
,
label
in
INS
:
yield
from
INS
yield
doc
,
label
return
reader
return
reader
...
...
python/paddle/fluid/tests/unittests/feed_data_reader.py
浏览文件 @
85e20755
...
@@ -19,8 +19,7 @@ from paddle.fluid.framework import Variable
...
@@ -19,8 +19,7 @@ from paddle.fluid.framework import Variable
def
cyclic_reader
(
reader
):
def
cyclic_reader
(
reader
):
def
__reader__
():
def
__reader__
():
while
True
:
while
True
:
for
data
in
reader
():
yield
from
reader
()
yield
data
return
__reader__
return
__reader__
...
...
python/paddle/fluid/tests/unittests/test_imperative_decorator.py
浏览文件 @
85e20755
...
@@ -105,8 +105,7 @@ class TestNoGradClass(unittest.TestCase):
...
@@ -105,8 +105,7 @@ class TestNoGradClass(unittest.TestCase):
)
)
def
test_gen
():
def
test_gen
():
for
i
in
range
(
3
):
yield
from
range
(
3
)
yield
i
a
=
0
a
=
0
for
i
in
test_gen
():
for
i
in
test_gen
():
...
@@ -114,8 +113,7 @@ class TestNoGradClass(unittest.TestCase):
...
@@ -114,8 +113,7 @@ class TestNoGradClass(unittest.TestCase):
@
paddle
.
no_grad
()
@
paddle
.
no_grad
()
def
test_wrapped_gen
():
def
test_wrapped_gen
():
for
i
in
range
(
3
):
yield
from
range
(
3
)
yield
i
b
=
0
b
=
0
for
i
in
test_wrapped_gen
():
for
i
in
test_wrapped_gen
():
...
@@ -151,8 +149,7 @@ class TestEnableGradClass(unittest.TestCase):
...
@@ -151,8 +149,7 @@ class TestEnableGradClass(unittest.TestCase):
)
)
def
test_gen
():
def
test_gen
():
for
i
in
range
(
3
):
yield
from
range
(
3
)
yield
i
a
=
0
a
=
0
for
i
in
test_gen
():
for
i
in
test_gen
():
...
@@ -160,8 +157,7 @@ class TestEnableGradClass(unittest.TestCase):
...
@@ -160,8 +157,7 @@ class TestEnableGradClass(unittest.TestCase):
@
paddle
.
enable_grad
()
@
paddle
.
enable_grad
()
def
test_wrapped_gen
():
def
test_wrapped_gen
():
for
i
in
range
(
3
):
yield
from
range
(
3
)
yield
i
b
=
0
b
=
0
for
i
in
test_wrapped_gen
():
for
i
in
test_wrapped_gen
():
...
@@ -215,8 +211,7 @@ class TestSetGradEnabledClass(unittest.TestCase):
...
@@ -215,8 +211,7 @@ class TestSetGradEnabledClass(unittest.TestCase):
)
)
def
test_gen
():
def
test_gen
():
for
i
in
range
(
3
):
yield
from
range
(
3
)
yield
i
a
=
0
a
=
0
for
i
in
test_gen
():
for
i
in
test_gen
():
...
@@ -224,8 +219,7 @@ class TestSetGradEnabledClass(unittest.TestCase):
...
@@ -224,8 +219,7 @@ class TestSetGradEnabledClass(unittest.TestCase):
@
paddle
.
set_grad_enabled
(
True
)
@
paddle
.
set_grad_enabled
(
True
)
def
test_wrapped_gen
():
def
test_wrapped_gen
():
for
i
in
range
(
3
):
yield
from
range
(
3
)
yield
i
b
=
0
b
=
0
for
i
in
test_wrapped_gen
():
for
i
in
test_wrapped_gen
():
...
...
python/paddle/fluid/tests/unittests/test_parallel_executor_transformer.py
浏览文件 @
85e20755
...
@@ -212,8 +212,7 @@ def get_feed_data_reader():
...
@@ -212,8 +212,7 @@ def get_feed_data_reader():
all_batch_tensors
.
append
(
tensors
)
all_batch_tensors
.
append
(
tensors
)
def
__reader__
():
def
__reader__
():
for
t
in
all_batch_tensors
:
yield
from
all_batch_tensors
yield
t
feed_data_reader
=
FeedDataReader
(
feed_data_reader
=
FeedDataReader
(
feed_list
=
transformer_model
.
build_inputs
(
feed_list
=
transformer_model
.
build_inputs
(
...
...
python/paddle/nn/layer/layers.py
浏览文件 @
85e20755
...
@@ -206,8 +206,7 @@ class LayerObjectHelper(LayerHelperBase):
...
@@ -206,8 +206,7 @@ class LayerObjectHelper(LayerHelperBase):
inputs
=
inputs_in
if
(
inputs_in
is
not
None
)
else
[]
inputs
=
inputs_in
if
(
inputs_in
is
not
None
)
else
[]
inputs
=
self
.
_multiple_input
(
inputs
)
inputs
=
self
.
_multiple_input
(
inputs
)
param_attrs
=
self
.
_multiple_param_attr
(
len
(
inputs
),
param_attr_in
)
param_attrs
=
self
.
_multiple_param_attr
(
len
(
inputs
),
param_attr_in
)
for
ipt
,
param_attr
in
zip
(
inputs
,
param_attrs
):
yield
from
zip
(
inputs
,
param_attrs
)
yield
ipt
,
param_attr
def
input_dtype
(
self
,
inputs_in
):
def
input_dtype
(
self
,
inputs_in
):
"""Get input data type
"""Get input data type
...
...
python/paddle/reader/decorator.py
浏览文件 @
85e20755
...
@@ -76,8 +76,7 @@ def cache(reader):
...
@@ -76,8 +76,7 @@ def cache(reader):
all_data
=
tuple
(
reader
())
all_data
=
tuple
(
reader
())
def
__impl__
():
def
__impl__
():
for
item
in
all_data
:
yield
from
all_data
yield
item
return
__impl__
return
__impl__
...
@@ -118,8 +117,7 @@ def map_readers(func, *readers):
...
@@ -118,8 +117,7 @@ def map_readers(func, *readers):
rs
=
[]
rs
=
[]
for
r
in
readers
:
for
r
in
readers
:
rs
.
append
(
r
())
rs
.
append
(
r
())
for
e
in
map
(
func
,
*
rs
):
yield
from
map
(
func
,
*
rs
)
yield
e
return
reader
return
reader
...
@@ -228,8 +226,7 @@ def chain(*readers):
...
@@ -228,8 +226,7 @@ def chain(*readers):
for
r
in
readers
:
for
r
in
readers
:
rs
.
append
(
r
())
rs
.
append
(
r
())
for
e
in
itertools
.
chain
(
*
rs
):
yield
from
itertools
.
chain
(
*
rs
)
yield
e
return
reader
return
reader
...
...
python/paddle/utils/layers_utils.py
浏览文件 @
85e20755
...
@@ -152,8 +152,7 @@ def _yield_value(iterable):
...
@@ -152,8 +152,7 @@ def _yield_value(iterable):
for
key
in
_sorted
(
iterable
):
for
key
in
_sorted
(
iterable
):
yield
iterable
[
key
]
yield
iterable
[
key
]
else
:
else
:
for
value
in
iterable
:
yield
from
iterable
yield
value
def
_yield_flat_nest
(
nest
):
def
_yield_flat_nest
(
nest
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录