From f2a3586e953bee8b1a019b05bca09bece7746317 Mon Sep 17 00:00:00 2001 From: gouzi <530971494@qq.com> Date: Sat, 16 Aug 2025 23:28:47 +0800 Subject: [PATCH] [CodeStyle] `black -> ruff format` migration - part 6 --- test/legacy_test/test_broadcast_to_op.py | 1 - test/legacy_test/test_calc_gradient.py | 1 - test/legacy_test/test_case.py | 4 ---- test/legacy_test/test_cast_op.py | 1 - test/legacy_test/test_channel_shuffle.py | 1 - test/legacy_test/test_clip_op.py | 2 -- test/legacy_test/test_compare_op.py | 4 ---- test/legacy_test/test_concat_op.py | 2 -- test/legacy_test/test_cond.py | 2 -- test/legacy_test/test_conj_op.py | 1 - test/legacy_test/test_conv2d_op.py | 1 - test/legacy_test/test_conv_nn_grad.py | 16 ---------------- test/legacy_test/test_crop_tensor_op.py | 1 - test/legacy_test/test_cumsum_op.py | 2 -- test/legacy_test/test_deformable_conv_op.py | 2 -- test/legacy_test/test_diag_embed.py | 1 - test/legacy_test/test_diag_v2.py | 1 - test/legacy_test/test_diff_op.py | 1 - test/legacy_test/test_dlpack.py | 2 -- test/legacy_test/test_dot_op.py | 1 - 20 files changed, 47 deletions(-) diff --git a/test/legacy_test/test_broadcast_to_op.py b/test/legacy_test/test_broadcast_to_op.py index 723bf799d2fcdf..4ade2cd70c2ba8 100644 --- a/test/legacy_test/test_broadcast_to_op.py +++ b/test/legacy_test/test_broadcast_to_op.py @@ -24,7 +24,6 @@ class TestBroadcastToError(unittest.TestCase): - def test_errors(self): with paddle.static.program_guard( paddle.static.Program(), paddle.static.Program() diff --git a/test/legacy_test/test_calc_gradient.py b/test/legacy_test/test_calc_gradient.py index dbeb249359926b..eb6df177850642 100644 --- a/test/legacy_test/test_calc_gradient.py +++ b/test/legacy_test/test_calc_gradient.py @@ -86,7 +86,6 @@ def test2(self): class TestGradientWithPrune(unittest.TestCase): - def test_prune(self): with paddle.base.scope_guard(paddle.static.Scope()): x = paddle.static.data(name='x', shape=[3], dtype='float32') diff --git a/test/legacy_test/test_case.py b/test/legacy_test/test_case.py index e8e5b9c94f5e52..e88e4bb45ea418 100644 --- a/test/legacy_test/test_case.py +++ b/test/legacy_test/test_case.py @@ -27,7 +27,6 @@ class TestAPICase(unittest.TestCase): - def test_return_single_var(self): def fn_1(): return paddle.tensor.fill_constant( @@ -298,7 +297,6 @@ def fn_3(): class TestAPICase_Nested(unittest.TestCase): - def test_nested_case(self): def fn_1(x=1): var_5 = paddle.tensor.fill_constant( @@ -513,7 +511,6 @@ def fn_3(): class TestAPICase_Error(unittest.TestCase): - def test_error(self): def fn_1(): return paddle.tensor.fill_constant( @@ -582,7 +579,6 @@ def type_error_default(): # when optimizer in case class TestMultiTask(unittest.TestCase): - def test_optimizer_in_case(self): BATCH_SIZE = 1 INPUT_SIZE = 784 diff --git a/test/legacy_test/test_cast_op.py b/test/legacy_test/test_cast_op.py index b8e6be0557588e..1c6b5741a33fdc 100644 --- a/test/legacy_test/test_cast_op.py +++ b/test/legacy_test/test_cast_op.py @@ -194,7 +194,6 @@ def test_grad(self): class TestCastOpError(unittest.TestCase): - def test_errors(self): paddle.enable_static() with program_guard(Program(), Program()): diff --git a/test/legacy_test/test_channel_shuffle.py b/test/legacy_test/test_channel_shuffle.py index 4b1f4ef5d75a26..10339cbd13cde5 100644 --- a/test/legacy_test/test_channel_shuffle.py +++ b/test/legacy_test/test_channel_shuffle.py @@ -252,7 +252,6 @@ def test_dygraph2(self): class TestChannelShuffleError(unittest.TestCase): - def test_error_functional(self): def error_input(): with paddle.base.dygraph.guard(): diff --git a/test/legacy_test/test_clip_op.py b/test/legacy_test/test_clip_op.py index a34c3de3a80fdb..0771ff51e61e5e 100644 --- a/test/legacy_test/test_clip_op.py +++ b/test/legacy_test/test_clip_op.py @@ -301,7 +301,6 @@ def initTestCase(self): class TestClipOpError(unittest.TestCase): - def test_errors(self): paddle.enable_static() with paddle.static.program_guard( @@ -489,7 +488,6 @@ def test_errors(self): class TestClipOpFp16(unittest.TestCase): - def test_fp16(self): if base.core.is_compiled_with_cuda(): paddle.enable_static() diff --git a/test/legacy_test/test_compare_op.py b/test/legacy_test/test_compare_op.py index 3d1036baaec60d..a189be9ef268ba 100644 --- a/test/legacy_test/test_compare_op.py +++ b/test/legacy_test/test_compare_op.py @@ -515,7 +515,6 @@ def test_check_output(self): class TestCompareOpError(unittest.TestCase): - def test_int16_support(self): paddle.enable_static() with paddle.static.program_guard( @@ -530,7 +529,6 @@ def test_int16_support(self): class API_TestElementwise_Equal(unittest.TestCase): - def test_api(self): paddle.enable_static() with paddle.static.program_guard( @@ -571,7 +569,6 @@ def test_api_fp16(self): class API_TestElementwise_Greater_Than(unittest.TestCase): - def test_api_fp16(self): paddle.enable_static() with paddle.static.program_guard( @@ -588,7 +585,6 @@ def test_api_fp16(self): class TestCompareOpPlace(unittest.TestCase): - def test_place_1(self): paddle.enable_static() place = paddle.CPUPlace() diff --git a/test/legacy_test/test_concat_op.py b/test/legacy_test/test_concat_op.py index ccfc0dc3424452..16e4f97b942aeb 100644 --- a/test/legacy_test/test_concat_op.py +++ b/test/legacy_test/test_concat_op.py @@ -673,7 +673,6 @@ def test_input_same_dtype(): class TestConcatAPI(unittest.TestCase): - def test_base_api(self): paddle.enable_static() with paddle.base.program_guard(paddle.base.Program()): @@ -1014,7 +1013,6 @@ def if_enable_cinn(self): class TestConcatOpErrorWithPir(unittest.TestCase): - def test_errors_with_pir(self): paddle.enable_static() with paddle.base.program_guard( diff --git a/test/legacy_test/test_cond.py b/test/legacy_test/test_cond.py index d966db3587f4ae..5a9b1fb51d9140 100644 --- a/test/legacy_test/test_cond.py +++ b/test/legacy_test/test_cond.py @@ -478,7 +478,6 @@ def test_extremely_simple_net_with_op_in_condition(self): class TestCondNestedControlFlow(unittest.TestCase): - def test_cond_inside_cond(self): """ pseudocode: @@ -930,7 +929,6 @@ def func(): class TestCondWithDict(unittest.TestCase): - @compare_legacy_with_pt def test_input_with_dict(self): paddle.enable_static() diff --git a/test/legacy_test/test_conj_op.py b/test/legacy_test/test_conj_op.py index 8f8083a68534ed..b5ceddb7a02333 100644 --- a/test/legacy_test/test_conj_op.py +++ b/test/legacy_test/test_conj_op.py @@ -155,7 +155,6 @@ def test_conj_api_real_number(self): class Testfp16ConjOp(unittest.TestCase): - def testfp16(self): if paddle.is_compiled_with_cuda(): input_x = ( diff --git a/test/legacy_test/test_conv2d_op.py b/test/legacy_test/test_conv2d_op.py index 4ee915872aa85a..f74ec7c8948c23 100644 --- a/test/legacy_test/test_conv2d_op.py +++ b/test/legacy_test/test_conv2d_op.py @@ -726,7 +726,6 @@ def init_kernel_type(self): class TestConv2DOpError(unittest.TestCase): - def test_errors(self): with paddle.static.program_guard( paddle.static.Program(), paddle.static.Program() diff --git a/test/legacy_test/test_conv_nn_grad.py b/test/legacy_test/test_conv_nn_grad.py index 17296ba5488998..93bbb2e53394ec 100644 --- a/test/legacy_test/test_conv_nn_grad.py +++ b/test/legacy_test/test_conv_nn_grad.py @@ -26,7 +26,6 @@ class TestConvDoubleGradCheck(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 4, 3, 3] @@ -50,7 +49,6 @@ def test_grad(self): class TestConvDoubleGradCheckTest0(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 4, 3, 3] @@ -74,7 +72,6 @@ def test_grad(self): class TestConvDoubleGradCheckTest1(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 3, 3, 3] @@ -98,7 +95,6 @@ def test_grad(self): class TestConv3DDoubleGradCheck(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 4, 3, 4, 2] @@ -122,7 +118,6 @@ def test_grad(self): class TestConv3DDoubleGradCheckTest1(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 4, 5, 3, 2] @@ -146,7 +141,6 @@ def test_grad(self): class TestConv2DoubleGradCheck_AsyPadding(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 2, 3, 3] @@ -170,7 +164,6 @@ def test_grad(self): class TestConv2DoubleGradCheck_PaddingSAME(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 2, 3, 3] @@ -194,7 +187,6 @@ def test_grad(self): class TestConv2DoubleGradCheck_PaddingVALID(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 2, 3, 3] @@ -218,7 +210,6 @@ def test_grad(self): class TestConv2DoubleGradCheck_ChannelLast(unittest.TestCase): - @prog_scope() def func_pir(self, place): x_shape = [2, 2, 3, 3] @@ -243,7 +234,6 @@ def test_grad(self): class TestConv2DoubleGradCheck_ChannelLast_AsyPadding(unittest.TestCase): - @prog_scope() def func_pir(self, place): x_shape = [2, 2, 3, 3] @@ -268,7 +258,6 @@ def test_grad(self): class TestConv3DDoubleGradCheck_AsyPadding(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 2, 2, 2, 2] @@ -292,7 +281,6 @@ def test_grad(self): class TestConv3DoubleGradCheck_PaddingSAME(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 2, 2, 2, 2] @@ -316,7 +304,6 @@ def test_grad(self): class TestConv3DoubleGradCheck_PaddingVALID(unittest.TestCase): - @prog_scope() def func_pir(self, place): shape = [2, 2, 3, 3, 2] @@ -340,7 +327,6 @@ def test_grad(self): class TestConv3DDoubleGradCheck_ChannelLast(unittest.TestCase): - @prog_scope() def func_pir(self, place): x_shape = [2, 2, 2, 2, 3] @@ -365,7 +351,6 @@ def test_grad(self): class TestConv3DDoubleGradCheck_ChannelLast_AsyPadding(unittest.TestCase): - @prog_scope() def func_pir(self, place): x_shape = [2, 2, 2, 2, 3] @@ -390,7 +375,6 @@ def test_grad(self): class TestDepthWiseConvDoubleGradCheck(unittest.TestCase): - @prog_scope() def func_pir(self, place): x_shape = [2, 4, 3, 3] diff --git a/test/legacy_test/test_crop_tensor_op.py b/test/legacy_test/test_crop_tensor_op.py index 6efc2270a1d156..75df7bf0910dac 100644 --- a/test/legacy_test/test_crop_tensor_op.py +++ b/test/legacy_test/test_crop_tensor_op.py @@ -271,7 +271,6 @@ def test_check_output(self): class TestCropTensorException(unittest.TestCase): - def test_exception(self): paddle.enable_static() input1 = paddle.static.data( diff --git a/test/legacy_test/test_cumsum_op.py b/test/legacy_test/test_cumsum_op.py index f218892447978e..f1aaee5297b056 100644 --- a/test/legacy_test/test_cumsum_op.py +++ b/test/legacy_test/test_cumsum_op.py @@ -590,7 +590,6 @@ def test_check_grad(self): class BadInputTest(unittest.TestCase): - def test_error(self): paddle.enable_static() with paddle.static.program_guard( @@ -725,7 +724,6 @@ def test_static(self): class TestCumSumOpFp16(unittest.TestCase): - def test_fp16(self): if core.is_compiled_with_cuda(): paddle.enable_static() diff --git a/test/legacy_test/test_deformable_conv_op.py b/test/legacy_test/test_deformable_conv_op.py index 0a0bac67ccc4d4..d220455bbd63b5 100644 --- a/test/legacy_test/test_deformable_conv_op.py +++ b/test/legacy_test/test_deformable_conv_op.py @@ -371,7 +371,6 @@ def init_test_case(self): class TestModulatedDeformableConvInvalidInput(unittest.TestCase): - def test_error_api(self): def test_invalid_input(): paddle.enable_static() @@ -428,7 +427,6 @@ def test_invalid_groups(): class TestDeformConv2DAPI(unittest.TestCase): - def test_api(self): def test_deform_conv2d_v1(): paddle.enable_static() diff --git a/test/legacy_test/test_diag_embed.py b/test/legacy_test/test_diag_embed.py index 5fba1905df3b00..9aee725e220768 100644 --- a/test/legacy_test/test_diag_embed.py +++ b/test/legacy_test/test_diag_embed.py @@ -60,7 +60,6 @@ def init_shape(self): class TestDiagEmbedAPICase(unittest.TestCase): - def test_case1(self): paddle.enable_static() main = paddle.static.Program() diff --git a/test/legacy_test/test_diag_v2.py b/test/legacy_test/test_diag_v2.py index a8680fba7044e7..26d9e76bfbbea9 100644 --- a/test/legacy_test/test_diag_v2.py +++ b/test/legacy_test/test_diag_v2.py @@ -106,7 +106,6 @@ def init_input_output(self): class TestDiagV2Error(unittest.TestCase): - def test_errors(self): paddle.enable_static() main = static.Program() diff --git a/test/legacy_test/test_diff_op.py b/test/legacy_test/test_diff_op.py index 71bda9175d2192..da82807fa68cb3 100644 --- a/test/legacy_test/test_diff_op.py +++ b/test/legacy_test/test_diff_op.py @@ -306,7 +306,6 @@ def set_args(self): class TestDiffOpFp16(TestDiffOp): - def test_fp16_with_gpu(self): paddle.enable_static() if paddle.base.core.is_compiled_with_cuda(): diff --git a/test/legacy_test/test_dlpack.py b/test/legacy_test/test_dlpack.py index d0fce4e313798d..86e881802f1b6d 100644 --- a/test/legacy_test/test_dlpack.py +++ b/test/legacy_test/test_dlpack.py @@ -332,7 +332,6 @@ def test_to_dlpack_from_zero_size(self): class TestDLPackDevice(unittest.TestCase): def test_dlpack_device(self): with dygraph_guard(): - tensor_cpu = paddle.to_tensor([1, 2, 3], place=base.CPUPlace()) device_type, device_id = tensor_cpu.__dlpack_device__() self.assertEqual(device_type, DLDeviceType.kDLCPU) @@ -362,7 +361,6 @@ def test_dlpack_device(self): def test_dlpack_device_zero_dim(self): with dygraph_guard(): - tensor = paddle.to_tensor(5.0, place=base.CPUPlace()) device_type, device_id = tensor.__dlpack_device__() self.assertEqual(device_type, DLDeviceType.kDLCPU) diff --git a/test/legacy_test/test_dot_op.py b/test/legacy_test/test_dot_op.py index a97a6fa8342ce0..60f89682849735 100644 --- a/test/legacy_test/test_dot_op.py +++ b/test/legacy_test/test_dot_op.py @@ -173,7 +173,6 @@ def test_check_grad_ignore_y(self): class TestDotOpError(unittest.TestCase): - def test_errors(self): with paddle.static.program_guard( paddle.static.Program(), paddle.static.Program()