From ee99dc5943224db6160f76624432d27bde5e435c Mon Sep 17 00:00:00 2001 From: Jeff114514 <928430299@qq.com> Date: Wed, 7 Aug 2024 12:28:35 +0800 Subject: [PATCH] fix --- python/paddle/utils/environments.py | 4 ++-- test/book/notest_understand_sentiment.py | 2 +- .../book/test_recognize_digits_deprecated.py | 2 +- test/deprecated/book/test_word2vec_book_deprecated.py | 2 +- .../legacy_test/test_multiprocess_reader_exception.py | 6 +++--- .../distributed_passes/auto_parallel_pass_test_base.py | 4 ++-- test/distributed_passes/dist_pass_test_base.py | 6 +++--- test/ir/inference/auto_scan_test.py | 4 ++-- test/ir/inference/test_trt_convert_prelu.py | 10 +++++----- test/legacy_test/check_nan_inf_base.py | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/python/paddle/utils/environments.py b/python/paddle/utils/environments.py index 4921e4161d8df..c2ab02ce1bfe2 100644 --- a/python/paddle/utils/environments.py +++ b/python/paddle/utils/environments.py @@ -41,10 +41,10 @@ def __init__(self, name: str, default: T): self.default = default def get(self) -> T: - raise NotImplementedError() + raise NotImplementedError def set(self, value: T) -> None: - raise NotImplementedError() + raise NotImplementedError def delete(self) -> None: del os.environ[self.name] diff --git a/test/book/notest_understand_sentiment.py b/test/book/notest_understand_sentiment.py index d4610da235455..402bf129b3001 100644 --- a/test/book/notest_understand_sentiment.py +++ b/test/book/notest_understand_sentiment.py @@ -82,7 +82,7 @@ def train( data, label, input_dim=dict_dim, class_dim=class_dim ) else: - raise NotImplementedError() + raise NotImplementedError adagrad = paddle.optimizer.Adagrad(learning_rate=0.002) adagrad.minimize(cost) diff --git a/test/deprecated/book/test_recognize_digits_deprecated.py b/test/deprecated/book/test_recognize_digits_deprecated.py index cbf50736a35a0..59d9f9448bb09 100644 --- a/test/deprecated/book/test_recognize_digits_deprecated.py +++ b/test/deprecated/book/test_recognize_digits_deprecated.py @@ -90,7 +90,7 @@ def train( net_conf = conv_net if parallel: - raise NotImplementedError() + raise NotImplementedError else: prediction, avg_loss, acc = net_conf(img, label) diff --git a/test/deprecated/book/test_word2vec_book_deprecated.py b/test/deprecated/book/test_word2vec_book_deprecated.py index 3c8a879bbc74b..d7542f97827ef 100644 --- a/test/deprecated/book/test_word2vec_book_deprecated.py +++ b/test/deprecated/book/test_word2vec_book_deprecated.py @@ -119,7 +119,7 @@ def __network__(words): [first_word, second_word, third_word, forth_word, next_word] ) else: - raise NotImplementedError() + raise NotImplementedError sgd_optimizer = paddle.optimizer.SGD(learning_rate=0.001) if use_bf16: diff --git a/test/deprecated/legacy_test/test_multiprocess_reader_exception.py b/test/deprecated/legacy_test/test_multiprocess_reader_exception.py index e885cffcb4fb0..30440c7860d9d 100644 --- a/test/deprecated/legacy_test/test_multiprocess_reader_exception.py +++ b/test/deprecated/legacy_test/test_multiprocess_reader_exception.py @@ -48,7 +48,7 @@ def __impl__(): np.random.uniform(low=-1, high=1, size=[10]) ), else: - raise ValueError() + raise ValueError return __impl__ @@ -94,7 +94,7 @@ def __impl__(): self.assertEqual(num, batch_num) except SystemError as ex: self.assertEqual(num, 0) - raise ReaderException() + raise ReaderException else: for _ in range(3): num = 0 @@ -110,7 +110,7 @@ def __impl__(): except SystemError as ex: self.assertTrue(self.raise_exception) self.assertEqual(num, 0) - raise ReaderException() + raise ReaderException def test_main(self): for p in self.places(): diff --git a/test/distributed_passes/auto_parallel_pass_test_base.py b/test/distributed_passes/auto_parallel_pass_test_base.py index a0ce48b9a21ea..c3fca091102cc 100644 --- a/test/distributed_passes/auto_parallel_pass_test_base.py +++ b/test/distributed_passes/auto_parallel_pass_test_base.py @@ -53,10 +53,10 @@ def init(self): pass def get_model(self, place, **kwargs): - raise NotImplementedError() + raise NotImplementedError def apply_passes(self): - raise NotImplementedError() + raise NotImplementedError def apply_no_passes(self): dist_strategy = fleet.DistributedStrategy() diff --git a/test/distributed_passes/dist_pass_test_base.py b/test/distributed_passes/dist_pass_test_base.py index 9b753912b480d..14bb4adde5a81 100644 --- a/test/distributed_passes/dist_pass_test_base.py +++ b/test/distributed_passes/dist_pass_test_base.py @@ -81,10 +81,10 @@ def init(self): pass def get_model(self, place, **kwargs): - raise NotImplementedError() + raise NotImplementedError def apply_passes(self, main_prog, startup_prog): - raise NotImplementedError() + raise NotImplementedError def check_main(self, model=None, gpus=None, **kwargs): pass_rets = self._distributed_launch( @@ -269,7 +269,7 @@ def setUp(self): super().setUp() def pass_config(self): - raise NotImplementedError() + raise NotImplementedError def apply_passes(self, main_prog, startup_prog): passes = self.pass_config() diff --git a/test/ir/inference/auto_scan_test.py b/test/ir/inference/auto_scan_test.py index 1473ca8a348b5..14f80ad919e37 100755 --- a/test/ir/inference/auto_scan_test.py +++ b/test/ir/inference/auto_scan_test.py @@ -473,13 +473,13 @@ def run_test(prog_config): self.fail_log( f"At least {min_success_num} programs need to ran successfully, but now only about {successful_ran_programs} programs satisfied." ) - raise AssertionError() + raise AssertionError used_time = time.time() - start_time if max_duration > 0 and used_time > max_duration: self.fail_log( f"The duration exceeds {max_duration} seconds, if this is necessary, try to set a larger number for parameter `max_duration`." ) - raise AssertionError() + raise AssertionError def run_test(self, quant=False, prog_configs=None): status = True diff --git a/test/ir/inference/test_trt_convert_prelu.py b/test/ir/inference/test_trt_convert_prelu.py index e999053fc5e29..285d3d397e387 100644 --- a/test/ir/inference/test_trt_convert_prelu.py +++ b/test/ir/inference/test_trt_convert_prelu.py @@ -43,7 +43,7 @@ def generate_input(attrs: list[dict[str, Any]], batch): elif attrs[0]["data_format"] == "NHWC": return np.random.random([batch, 16, 3]).astype(np.float32) else: - raise AssertionError() + raise AssertionError else: if attrs[0]["data_format"] == "NCHW": return np.random.random([batch, 3, 16, 32]).astype( @@ -72,7 +72,7 @@ def generate_alpha(attrs: list[dict[str, Any]]): elif attrs[0]["data_format"] == "NHWC": return np.random.random([1, 16, 3]).astype(np.float32) else: - raise AssertionError() + raise AssertionError else: if attrs[0]["data_format"] == "NCHW": return np.random.random([1, 3, 16, 32]).astype( @@ -83,7 +83,7 @@ def generate_alpha(attrs: list[dict[str, Any]]): np.float32 ) else: - raise AssertionError() + raise AssertionError for batch in [1, 4]: for dims in [0, 1, 2, 3, 4]: @@ -165,7 +165,7 @@ def generate_dynamic_shape(attrs): "input_data": [1, 16, 3] } else: - raise AssertionError() + raise AssertionError else: if attrs[0]["data_format"] == "NCHW": self.dynamic_shape.min_input_shape = { @@ -188,7 +188,7 @@ def generate_dynamic_shape(attrs): "input_data": [1, 16, 32, 3] } else: - raise AssertionError() + raise AssertionError def clear_dynamic_shape(): self.dynamic_shape.max_input_shape = {} diff --git a/test/legacy_test/check_nan_inf_base.py b/test/legacy_test/check_nan_inf_base.py index c1563ba6ec013..76b97a14eda58 100644 --- a/test/legacy_test/check_nan_inf_base.py +++ b/test/legacy_test/check_nan_inf_base.py @@ -99,7 +99,7 @@ def check(use_cuda): if __name__ == '__main__': try: check(use_cuda=False) - raise AssertionError() + raise AssertionError except Exception as e: print(e) print(type(e)) @@ -108,7 +108,7 @@ def check(use_cuda): if core.is_compiled_with_cuda(): try: check(use_cuda=True) - raise AssertionError() + raise AssertionError except Exception as e: print(e) print(type(e))