From db0de75f08b6f250846707b2fe4179fe268209ef Mon Sep 17 00:00:00 2001 From: gouzi <530971494@qq.com> Date: Sat, 16 Aug 2025 23:44:40 +0800 Subject: [PATCH] [CodeStyle] `black -> ruff format` migration - part 13 --- test/legacy_test/ernie_utils/moe_all_gather_layer.py | 1 - test/legacy_test/ernie_utils/moe_layer.py | 1 + test/legacy_test/hygon_dcu/hygon_llama_ops.py | 6 ------ test/legacy_test/test_uniform_random_op.py | 8 -------- test/legacy_test/test_unpool1d_op.py | 1 - test/legacy_test/test_unpool3d_op.py | 1 - test/legacy_test/test_unpool_indices.py | 3 --- test/legacy_test/test_unpool_op.py | 1 - test/legacy_test/test_unstack_op.py | 1 - test/legacy_test/test_variance_layer.py | 1 - test/legacy_test/test_warpctc_op.py | 1 - test/legacy_test/test_warprnnt_op.py | 1 - test/legacy_test/test_while_loop_op.py | 1 - test/legacy_test/test_while_op.py | 1 - test/legacy_test/test_yolo_box_op.py | 1 - test/legacy_test/test_yolov3_loss_op.py | 1 - test/quantization/test_trace_quanter.py | 1 + test/quantization/test_weight_only_linear.py | 1 - test/sequence/test_sequence_mask.py | 1 - test/sot/test_guard_fastpath_strategy.py | 1 - 20 files changed, 2 insertions(+), 32 deletions(-) diff --git a/test/legacy_test/ernie_utils/moe_all_gather_layer.py b/test/legacy_test/ernie_utils/moe_all_gather_layer.py index 3585f8242e3a8e..f5dabc5d6447e7 100644 --- a/test/legacy_test/ernie_utils/moe_all_gather_layer.py +++ b/test/legacy_test/ernie_utils/moe_all_gather_layer.py @@ -89,7 +89,6 @@ def __init__( group_experts=False, moe_statics=None, ): - super().__init__( gate, experts, diff --git a/test/legacy_test/ernie_utils/moe_layer.py b/test/legacy_test/ernie_utils/moe_layer.py index de4815338a4c74..e9547179c241ac 100644 --- a/test/legacy_test/ernie_utils/moe_layer.py +++ b/test/legacy_test/ernie_utils/moe_layer.py @@ -19,6 +19,7 @@ Returns: _type_: _description_ """ + from __future__ import annotations import logging diff --git a/test/legacy_test/hygon_dcu/hygon_llama_ops.py b/test/legacy_test/hygon_dcu/hygon_llama_ops.py index 4ead7b15c39028..c941d1e93c20a0 100644 --- a/test/legacy_test/hygon_dcu/hygon_llama_ops.py +++ b/test/legacy_test/hygon_dcu/hygon_llama_ops.py @@ -401,7 +401,6 @@ def test_check_gradient(self): # test mean op class TestFP16MeanOp(OpTest): - def setUp(self): self.op_type = "mean" self.python_api = paddle.mean @@ -441,7 +440,6 @@ def test_checkout_grad(self): # test scale op class TestScaleFp16Op(OpTest): - def setUp(self): self.op_type = "scale" self.python_api = paddle.scale @@ -466,7 +464,6 @@ def test_check_grad(self): # test sum op class TestAFP16SumOp(OpTest): - def setUp(self): self.op_type = "sum" self.python_api = paddle.add_n @@ -528,7 +525,6 @@ def test_check_output(self): # test add, add_grad op class TestFP16ElementwiseAddOp(OpTest): - def setUp(self): self.op_type = "elementwise_add" self.python_api = paddle.add @@ -612,7 +608,6 @@ def test_check_grad_ignore_y(self): # test multiply, multiply_grad op class TestElementwiseMulOpFp16(OpTest): - def setUp(self): self.op_type = "elementwise_mul" self.prim_op_type = "prim" @@ -791,7 +786,6 @@ def test_check_output(self): # test matmul, matmul_grad op class TestMatMulV2Op(OpTest): - def config(self): self.x_shape = (100,) self.y_shape = (100,) diff --git a/test/legacy_test/test_uniform_random_op.py b/test/legacy_test/test_uniform_random_op.py index 43fe75fed5810d..f2a5f3eae97bca 100644 --- a/test/legacy_test/test_uniform_random_op.py +++ b/test/legacy_test/test_uniform_random_op.py @@ -206,7 +206,6 @@ def init_dtype(self): class TestUniformRandomOpError(unittest.TestCase): - def test_errors(self): paddle.enable_static() main_prog = Program() @@ -305,7 +304,6 @@ def check_with_place(self, place): class TestUniformRandomOpApi(unittest.TestCase): - def test_api(self): paddle.enable_static() paddle.seed(10) @@ -343,7 +341,6 @@ def test_api(self): class TestUniformRandomOp_attr_tensor_API(unittest.TestCase): - def test_attr_tensor_API(self): paddle.enable_static() startup_program = base.Program() @@ -402,7 +399,6 @@ def test_attr_tensor_int32_API(self): class TestUniformRandomOp_API_seed(unittest.TestCase): - def test_attr_tensor_API(self): paddle.enable_static() _seed = 10 @@ -456,7 +452,6 @@ def check_with_place(self, place): class TestUniformRandomOpSelectedRowsShapeTensorList(unittest.TestCase): - def test_check_output(self): for place in get_places(): self.check_with_place(place) @@ -493,7 +488,6 @@ def test_check_output(self): class TestUniformRandomBatchSizeLikeOpError(unittest.TestCase): - def test_errors(self): paddle.enable_static() main_prog = Program() @@ -527,7 +521,6 @@ def test_dtype(): class TestUniformAlias(unittest.TestCase): - def test_alias(self): paddle.uniform([2, 3], min=-5.0, max=5.0) paddle.tensor.uniform([2, 3], min=-5.0, max=5.0) @@ -540,7 +533,6 @@ def test_uniform_random(): class TestUniformOpError(unittest.TestCase): - def test_errors(self): paddle.enable_static() main_prog = Program() diff --git a/test/legacy_test/test_unpool1d_op.py b/test/legacy_test/test_unpool1d_op.py index 41c482a4f67c67..58dc381b1aa5d6 100644 --- a/test/legacy_test/test_unpool1d_op.py +++ b/test/legacy_test/test_unpool1d_op.py @@ -179,7 +179,6 @@ def test_case(self): class TestUnpool1DOpAPI_static(unittest.TestCase): - def test_case(self): paddle.enable_static() for place in get_places(): diff --git a/test/legacy_test/test_unpool3d_op.py b/test/legacy_test/test_unpool3d_op.py index 6f8267e5640ee5..93153590ab27c0 100644 --- a/test/legacy_test/test_unpool3d_op.py +++ b/test/legacy_test/test_unpool3d_op.py @@ -410,7 +410,6 @@ def test_case(self): class TestUnpool3DOpAPI_static(unittest.TestCase): - def test_case(self): paddle.enable_static() for place in get_places(): diff --git a/test/legacy_test/test_unpool_indices.py b/test/legacy_test/test_unpool_indices.py index d8cc5ed8a7f584..4b0325035a2047 100644 --- a/test/legacy_test/test_unpool_indices.py +++ b/test/legacy_test/test_unpool_indices.py @@ -377,7 +377,6 @@ def test_case(self): class TestUnpool1DAPI_st(unittest.TestCase): - def test_case(self): paddle.enable_static() for place in get_places(): @@ -455,7 +454,6 @@ def test_case(self): class TestUnpool2DAPI_st(unittest.TestCase): - def test_case(self): paddle.enable_static() for place in get_places(): @@ -542,7 +540,6 @@ def test_case(self): class TestUnpool3DAPI_st2(unittest.TestCase): - def test_case(self): paddle.enable_static() for place in get_places(): diff --git a/test/legacy_test/test_unpool_op.py b/test/legacy_test/test_unpool_op.py index 5a3b7204633587..2ad865f6046088 100644 --- a/test/legacy_test/test_unpool_op.py +++ b/test/legacy_test/test_unpool_op.py @@ -456,7 +456,6 @@ def test_case(self): class TestUnpoolOpAPI_st(unittest.TestCase): - def test_case(self): import paddle import paddle.nn.functional as F diff --git a/test/legacy_test/test_unstack_op.py b/test/legacy_test/test_unstack_op.py index 3deabe4e867dd1..003e078202e5a0 100755 --- a/test/legacy_test/test_unstack_op.py +++ b/test/legacy_test/test_unstack_op.py @@ -236,7 +236,6 @@ def test_check_grad(self): class TestUnstackZeroInputOp(unittest.TestCase): - def unstack_zero_input_static(self): paddle.enable_static() diff --git a/test/legacy_test/test_variance_layer.py b/test/legacy_test/test_variance_layer.py index 4b0eeb2fe8e667..cd1a3842660567 100644 --- a/test/legacy_test/test_variance_layer.py +++ b/test/legacy_test/test_variance_layer.py @@ -116,7 +116,6 @@ def test_alias(self): class TestVarError(unittest.TestCase): - def test_error(self): with paddle.static.program_guard(paddle.static.Program()): x = paddle.static.data('X', [2, 3, 4], 'int32') diff --git a/test/legacy_test/test_warpctc_op.py b/test/legacy_test/test_warpctc_op.py index cdf735d3ae21e9..13657c6c4992c3 100644 --- a/test/legacy_test/test_warpctc_op.py +++ b/test/legacy_test/test_warpctc_op.py @@ -528,7 +528,6 @@ def test_check_grad(self): class TestWarpCTCOpError(unittest.TestCase): - def test_errors(self): paddle.enable_static() main_program = paddle.static.Program() diff --git a/test/legacy_test/test_warprnnt_op.py b/test/legacy_test/test_warprnnt_op.py index 865650948689ed..22a1efa17f7396 100644 --- a/test/legacy_test/test_warprnnt_op.py +++ b/test/legacy_test/test_warprnnt_op.py @@ -249,7 +249,6 @@ def test_check_grad(self): class TestWarpRNNTOpError(unittest.TestCase): - def test_errors1(self): with paddle.static.program_guard( paddle.static.Program(), paddle.static.Program() diff --git a/test/legacy_test/test_while_loop_op.py b/test/legacy_test/test_while_loop_op.py index 2aea461b856806..6299321d4709b7 100644 --- a/test/legacy_test/test_while_loop_op.py +++ b/test/legacy_test/test_while_loop_op.py @@ -178,7 +178,6 @@ def body(i, ten, test_dict, test_list, test_list_dict): class TestApiWhileLoop_Nested(unittest.TestCase): - @compare_legacy_with_pt def test_nested_net(self): def external_cond(i, j, init, sums): diff --git a/test/legacy_test/test_while_op.py b/test/legacy_test/test_while_op.py index eb080965edff30..c7a70dbb29838e 100644 --- a/test/legacy_test/test_while_op.py +++ b/test/legacy_test/test_while_op.py @@ -154,7 +154,6 @@ def test_bad_x(): class TestIgnoreVarNameInWhile(unittest.TestCase): - def test_ignore_var(self): def cond(i, ten, temp, y): return i < ten diff --git a/test/legacy_test/test_yolo_box_op.py b/test/legacy_test/test_yolo_box_op.py index fe6371bbb1ea24..a78a8f6acb8e20 100644 --- a/test/legacy_test/test_yolo_box_op.py +++ b/test/legacy_test/test_yolo_box_op.py @@ -268,7 +268,6 @@ def test_dygraph(self): class TestYoloBoxStatic(unittest.TestCase): - def test_static(self): x1 = paddle.static.data('x1', [2, 14, 8, 8], 'float32') img_size = paddle.static.data('img_size', [2, 2], 'int32') diff --git a/test/legacy_test/test_yolov3_loss_op.py b/test/legacy_test/test_yolov3_loss_op.py index e2e95aac6622fa..12170ad410a169 100644 --- a/test/legacy_test/test_yolov3_loss_op.py +++ b/test/legacy_test/test_yolov3_loss_op.py @@ -440,7 +440,6 @@ def test_dygraph(self): class TestYolov3LossStatic(unittest.TestCase): - def test_static(self): x = paddle.static.data('x', [2, 14, 8, 8], 'float32') gt_box = paddle.static.data('gt_box', [2, 10, 4], 'float32') diff --git a/test/quantization/test_trace_quanter.py b/test/quantization/test_trace_quanter.py index cb006c37bc689e..a7c902ee011c76 100644 --- a/test/quantization/test_trace_quanter.py +++ b/test/quantization/test_trace_quanter.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """The quantizer layers should be traced by paddle.jit.save function.""" + import os import tempfile import unittest diff --git a/test/quantization/test_weight_only_linear.py b/test/quantization/test_weight_only_linear.py index 376edc370eb2ea..9fa52abb615e2d 100644 --- a/test/quantization/test_weight_only_linear.py +++ b/test/quantization/test_weight_only_linear.py @@ -932,7 +932,6 @@ def test_weightonly_linear_backward( "quantized_matmul requires CUDA >= 11.2 and CUDA_ARCH >= 8", ) class WeightOnlyLinear_stream_k_TestCase(unittest.TestCase): - def test_weightonly_linear_backward_int4(self): def test_weightonly_linear_backward( self, algo='weight_only_int4', weight_dtype='int4' diff --git a/test/sequence/test_sequence_mask.py b/test/sequence/test_sequence_mask.py index ed1ff595fef0e8..256385e7e4f3ab 100644 --- a/test/sequence/test_sequence_mask.py +++ b/test/sequence/test_sequence_mask.py @@ -185,7 +185,6 @@ def initParameters(self): class TestSequenceMaskOpError(unittest.TestCase): - def test_errors(self): paddle.enable_static() with paddle.static.program_guard( diff --git a/test/sot/test_guard_fastpath_strategy.py b/test/sot/test_guard_fastpath_strategy.py index 0ae067b2fa5b61..9cc76740666c89 100644 --- a/test/sot/test_guard_fastpath_strategy.py +++ b/test/sot/test_guard_fastpath_strategy.py @@ -45,7 +45,6 @@ def test_guard(self): # subsequent guard checks will be skipped to improve performance. # The related logic is implemented in the OpcodeExecutorCache class. with EnvironmentVariableGuard(ENV_SOT_UNSAFE_CACHE_FASTPATH, True): - self.assertTrue(ENV_SOT_UNSAFE_CACHE_FASTPATH.get()) self.assertFalse(