From 5522edc4b57dbe20b93e9fcf25120403587aa278 Mon Sep 17 00:00:00 2001 From: Yang Date: Sat, 30 May 2020 11:30:00 +0800 Subject: [PATCH] !1713 [Dataset] Clean pylint. --- tests/ut/python/dataset/test_datasets_voc.py | 4 ++-- tests/ut/python/dataset/test_five_crop.py | 3 +-- tests/ut/python/dataset/test_random_crop_and_resize.py | 2 +- tests/ut/python/dataset/test_random_horizontal_flip.py | 2 +- tests/ut/python/dataset/test_sampler.py | 1 + tests/ut/python/dataset/test_sync_wait.py | 7 ++----- tests/ut/python/dataset/test_ten_crop.py | 8 ++++---- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/ut/python/dataset/test_datasets_voc.py b/tests/ut/python/dataset/test_datasets_voc.py index 0e53e9eec64..8db65e97340 100644 --- a/tests/ut/python/dataset/test_datasets_voc.py +++ b/tests/ut/python/dataset/test_datasets_voc.py @@ -124,12 +124,12 @@ def test_case_2(): num_iter = 0 for _ in dataset1.create_dict_iterator(): num_iter += 1 - assert (num_iter == 5) + assert num_iter == 5 num_iter = 0 for _ in dataset2.create_dict_iterator(): num_iter += 1 - assert (num_iter == 5) + assert num_iter == 5 def test_voc_exception(): diff --git a/tests/ut/python/dataset/test_five_crop.py b/tests/ut/python/dataset/test_five_crop.py index d7192584d27..b877ff5c22a 100644 --- a/tests/ut/python/dataset/test_five_crop.py +++ b/tests/ut/python/dataset/test_five_crop.py @@ -14,9 +14,8 @@ """ Testing FiveCrop in DE """ -import matplotlib.pyplot as plt -import numpy as np import pytest +import numpy as np import mindspore.dataset as ds import mindspore.dataset.transforms.vision.py_transforms as vision diff --git a/tests/ut/python/dataset/test_random_crop_and_resize.py b/tests/ut/python/dataset/test_random_crop_and_resize.py index 8249d6a18ab..d5f84b3b991 100644 --- a/tests/ut/python/dataset/test_random_crop_and_resize.py +++ b/tests/ut/python/dataset/test_random_crop_and_resize.py @@ -272,7 +272,7 @@ def test_random_crop_and_resize_05_py(): expected to raise ValueError """ logger.info("test_random_crop_and_resize_05_py") - + # Generate dataset data = ds.TFRecordDataset(DATA_DIR, SCHEMA_DIR, columns_list=["image"], shuffle=False) try: diff --git a/tests/ut/python/dataset/test_random_horizontal_flip.py b/tests/ut/python/dataset/test_random_horizontal_flip.py index 0fc3d16ff2d..a1106f5e3f7 100644 --- a/tests/ut/python/dataset/test_random_horizontal_flip.py +++ b/tests/ut/python/dataset/test_random_horizontal_flip.py @@ -215,7 +215,7 @@ def test_random_horizontal_comp(plot=False): image_py = (item2["image"].transpose(1, 2, 0) * 255).astype(np.uint8) images_list_c.append(image_c) images_list_py.append(image_py) - + # Check if the output images are the same mse = diff_mse(image_c, image_py) assert mse < 0.001 diff --git a/tests/ut/python/dataset/test_sampler.py b/tests/ut/python/dataset/test_sampler.py index 40d4b740c63..e5586655791 100644 --- a/tests/ut/python/dataset/test_sampler.py +++ b/tests/ut/python/dataset/test_sampler.py @@ -170,6 +170,7 @@ def test_subset_sampler(): map_ = {(172876, 0): 0, (54214, 0): 1, (54214, 1): 2, (173673, 0): 3, (64631, 1): 4} def test_config(num_samples, start_index, subset_size): + _ = num_samples sampler = ds.SubsetSampler(start_index, subset_size) d = ds.ManifestDataset(manifest_file, sampler=sampler) diff --git a/tests/ut/python/dataset/test_sync_wait.py b/tests/ut/python/dataset/test_sync_wait.py index 669df0a2193..a5727a29911 100644 --- a/tests/ut/python/dataset/test_sync_wait.py +++ b/tests/ut/python/dataset/test_sync_wait.py @@ -204,7 +204,6 @@ def test_sync_exception_03(): Test sync: with wrong batch size """ logger.info("test_sync_exception_03") - batch_size = 6 dataset = ds.GeneratorDataset(gen, column_names=["input"]) @@ -223,7 +222,6 @@ def test_sync_exception_04(): Test sync: with negative batch size in update """ logger.info("test_sync_exception_04") - batch_size = 6 dataset = ds.GeneratorDataset(gen, column_names=["input"]) @@ -233,7 +231,7 @@ def test_sync_exception_04(): dataset = dataset.map(input_columns=["input"], operations=[aug.preprocess]) count = 0 try: - for item in dataset.create_dict_iterator(): + for _ in dataset.create_dict_iterator(): count += 1 data = {"loss": count} # dataset.disable_sync() @@ -246,7 +244,6 @@ def test_sync_exception_05(): Test sync: with wrong batch size in update """ logger.info("test_sync_exception_05") - batch_size = 6 dataset = ds.GeneratorDataset(gen, column_names=["input"]) count = 0 @@ -255,7 +252,7 @@ def test_sync_exception_05(): dataset = dataset.sync_wait(condition_name="every batch", callback=aug.update) dataset = dataset.map(input_columns=["input"], operations=[aug.preprocess]) try: - for item in dataset.create_dict_iterator(): + for _ in dataset.create_dict_iterator(): dataset.disable_sync() count += 1 data = {"loss": count} diff --git a/tests/ut/python/dataset/test_ten_crop.py b/tests/ut/python/dataset/test_ten_crop.py index de860cb7d27..66a87a0dd2a 100644 --- a/tests/ut/python/dataset/test_ten_crop.py +++ b/tests/ut/python/dataset/test_ten_crop.py @@ -17,9 +17,9 @@ Testing TenCrop in DE import pytest import numpy as np +from util import visualize, save_and_check_md5 import mindspore.dataset as ds import mindspore.dataset.transforms.vision.py_transforms as vision -from util import visualize, save_and_check_md5 from mindspore import log as logger GENERATE_GOLDEN = False @@ -123,7 +123,7 @@ def test_ten_crop_list_size_error_msg(): logger.info("test_ten_crop_list_size_error_msg") with pytest.raises(TypeError) as info: - transforms = [ + _ = [ vision.Decode(), vision.TenCrop([200, 200, 200]), lambda images: np.stack([vision.ToTensor()(image) for image in images]) # 4D stack of 10 images @@ -139,7 +139,7 @@ def test_ten_crop_invalid_size_error_msg(): logger.info("test_ten_crop_invalid_size_error_msg") with pytest.raises(ValueError) as info: - transforms = [ + _ = [ vision.Decode(), vision.TenCrop(0), lambda images: np.stack([vision.ToTensor()(image) for image in images]) # 4D stack of 10 images @@ -148,7 +148,7 @@ def test_ten_crop_invalid_size_error_msg(): assert error_msg == str(info.value) with pytest.raises(ValueError) as info: - transforms = [ + _ = [ vision.Decode(), vision.TenCrop(-10), lambda images: np.stack([vision.ToTensor()(image) for image in images]) # 4D stack of 10 images