From f8830754442befabc20de0a80ff43d061dc95522 Mon Sep 17 00:00:00 2001 From: Shuangchi He <34329208+Yulv-git@users.noreply.github.com> Date: Mon, 10 Oct 2022 17:39:58 +0800 Subject: [PATCH] [CodeStyle][F401] remove unused imports in unittests/fft_ps_rnn. (#46707) --- .../fluid/tests/unittests/fft/spectral_op_np.py | 2 +- python/paddle/fluid/tests/unittests/fft/test_fft.py | 2 -- .../unittests/fft/test_fft_with_static_graph.py | 2 -- .../fluid/tests/unittests/fft/test_spectral_op.py | 9 +-------- .../fluid/tests/unittests/ps/fl_ps_trainer.py | 3 --- .../fluid/tests/unittests/ps/ps_dnn_trainer.py | 2 -- .../paddle/fluid/tests/unittests/ps/test_fl_ps.py | 6 +++--- .../fluid/tests/unittests/ps/test_the_one_ps.py | 13 +++---------- python/paddle/fluid/tests/unittests/rnn/convert.py | 1 - 9 files changed, 8 insertions(+), 32 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/fft/spectral_op_np.py b/python/paddle/fluid/tests/unittests/fft/spectral_op_np.py index 756dd788997..0dc958f54fc 100644 --- a/python/paddle/fluid/tests/unittests/fft/spectral_op_np.py +++ b/python/paddle/fluid/tests/unittests/fft/spectral_op_np.py @@ -16,7 +16,7 @@ import enum import numpy as np from functools import partial from numpy import asarray -from numpy.fft._pocketfft import _raw_fft, _raw_fftnd, _get_forward_norm, _get_backward_norm, _cook_nd_args +from numpy.fft._pocketfft import _cook_nd_args, _raw_fft, _raw_fftnd class NormMode(enum.Enum): diff --git a/python/paddle/fluid/tests/unittests/fft/test_fft.py b/python/paddle/fluid/tests/unittests/fft/test_fft.py index 7ae48819de3..e6ea9865ae3 100644 --- a/python/paddle/fluid/tests/unittests/fft/test_fft.py +++ b/python/paddle/fluid/tests/unittests/fft/test_fft.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import contextlib -import re import sys import unittest diff --git a/python/paddle/fluid/tests/unittests/fft/test_fft_with_static_graph.py b/python/paddle/fluid/tests/unittests/fft/test_fft_with_static_graph.py index 2c0ff3f9272..7b286c5086c 100644 --- a/python/paddle/fluid/tests/unittests/fft/test_fft_with_static_graph.py +++ b/python/paddle/fluid/tests/unittests/fft/test_fft_with_static_graph.py @@ -13,8 +13,6 @@ # limitations under the License. import contextlib -import re -import sys import unittest import numpy as np diff --git a/python/paddle/fluid/tests/unittests/fft/test_spectral_op.py b/python/paddle/fluid/tests/unittests/fft/test_spectral_op.py index 16dd37cf815..bc362d1b7a6 100644 --- a/python/paddle/fluid/tests/unittests/fft/test_spectral_op.py +++ b/python/paddle/fluid/tests/unittests/fft/test_spectral_op.py @@ -12,20 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest - import numpy as np import paddle import re import sys from spectral_op_np import fft_c2c, fft_r2c, fft_c2r, fft_c2c_backward, fft_r2c_backward, fft_c2r_backward -import paddle.fluid.core as core -import paddle.fluid.dygraph as dg -import paddle.static as static -from numpy.random import random as rand -from paddle.fluid import Program, program_guard -from paddle import _C_ops, _legacy_C_ops +from paddle import _C_ops sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/ps/fl_ps_trainer.py b/python/paddle/fluid/tests/unittests/ps/fl_ps_trainer.py index 76c5109e9b9..aebf38a4585 100755 --- a/python/paddle/fluid/tests/unittests/ps/fl_ps_trainer.py +++ b/python/paddle/fluid/tests/unittests/ps/fl_ps_trainer.py @@ -13,11 +13,8 @@ # limitations under the License. import os -import unittest -import numpy as np import time import paddle -from paddle.distributed.ps.utils.public import ps_log_root_dir, debug_program import paddle.distributed.fleet as fleet import paddle.fluid as fluid diff --git a/python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py b/python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py index 3cad88ec6bc..d54f86b3863 100755 --- a/python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py +++ b/python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py @@ -16,12 +16,10 @@ import paddle.distributed.fleet.base.role_maker as role_maker from paddle.distributed.ps.utils.ps_program_builder import * import paddle.distributed.fleet as fleet import argparse -import time import sys import yaml, six, copy import paddle import os -import warnings import ast import numpy as np import struct diff --git a/python/paddle/fluid/tests/unittests/ps/test_fl_ps.py b/python/paddle/fluid/tests/unittests/ps/test_fl_ps.py index c2fc55efdfe..0a993217eba 100755 --- a/python/paddle/fluid/tests/unittests/ps/test_fl_ps.py +++ b/python/paddle/fluid/tests/unittests/ps/test_fl_ps.py @@ -15,15 +15,14 @@ # limitations under the License. import unittest -import shlex -from paddle.fluid.tests.unittests.distributed_passes.dist_pass_test_base import prepare_python_path_and_return_module, remove_path_if_exists +import shlex # noqa: F401 +from paddle.fluid.tests.unittests.distributed_passes.dist_pass_test_base import remove_path_if_exists # noqa: F401 import os class FlPsTest(unittest.TestCase): def test_launch_fl_ps(self): - pass ''' cmd = [ 'python', '-m', 'paddle.distributed.fleet.launch', '--log_dir', @@ -36,6 +35,7 @@ class FlPsTest(unittest.TestCase): prepare_python_path_and_return_module(__file__) exitcode = os.system(' '.join(cmd)) ''' + pass if __name__ == '__main__': diff --git a/python/paddle/fluid/tests/unittests/ps/test_the_one_ps.py b/python/paddle/fluid/tests/unittests/ps/test_the_one_ps.py index 7dfaef29f38..c0d10d63687 100755 --- a/python/paddle/fluid/tests/unittests/ps/test_the_one_ps.py +++ b/python/paddle/fluid/tests/unittests/ps/test_the_one_ps.py @@ -12,19 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import unittest -import numpy as np -import paddle -import paddle.fluid as fluid - -import paddle from paddle.fluid.tests.unittests.distributed_passes.ps_pass_test_base import * from paddle.distributed.ps.utils.public import logger, ps_log_root_dir -from ps_dnn_trainer import DnnTrainer -import paddle.distributed.fleet.proto.the_one_ps_pb2 as ps_pb2 -from google.protobuf import text_format +import paddle.distributed.fleet.proto.the_one_ps_pb2 as ps_pb2 # noqa: F401 +from google.protobuf import text_format # noqa: F401 class TestTheOnePs(PsPassTestBase): @@ -36,7 +29,6 @@ class TestTheOnePs(PsPassTestBase): pass def check(self, file1, file2): - pass ''' f = open(file1, "rb") ps_desc_1 = ps_pb2.PSParameter() @@ -56,6 +48,7 @@ class TestTheOnePs(PsPassTestBase): else: return False ''' + pass def test_ps_cpu_async(self): self.init() diff --git a/python/paddle/fluid/tests/unittests/rnn/convert.py b/python/paddle/fluid/tests/unittests/rnn/convert.py index 1a3e571269d..b26db11e1d3 100644 --- a/python/paddle/fluid/tests/unittests/rnn/convert.py +++ b/python/paddle/fluid/tests/unittests/rnn/convert.py @@ -13,7 +13,6 @@ # limitations under the License. import paddle -import numpy as np def convert_params_for_cell(np_cell, paddle_cell): -- GitLab