From 7398526abcd792fbc679f63091aab7767cb8db42 Mon Sep 17 00:00:00 2001 From: seatea Date: Thu, 28 May 2020 11:35:33 +0800 Subject: [PATCH] Fix pylint warning for test cases of optimizer, infer, parse and pynative. --- tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py | 2 +- tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py | 2 +- .../gtest_input/pipeline/parse/parser_integrate.py | 4 ++-- tests/ut/cpp/python_input/gtest_input/session/session_test.py | 2 +- tests/ut/python/pipeline/infer/infer.py | 2 +- tests/ut/python/pipeline/infer/test_hypermap_specialize.py | 2 +- tests/ut/python/pipeline/parse/test_for_stmt.py | 2 +- tests/ut/python/pipeline/parse/test_operator.py | 2 +- tests/ut/python/pipeline/parse/test_parse.py | 1 - tests/ut/python/pynative_mode/nn/test_activation.py | 1 - tests/ut/python/pynative_mode/nn/test_cell.py | 2 +- tests/ut/python/pynative_mode/nn/test_container.py | 2 +- 12 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py b/tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py index 9e7185a70b9..e38c61f16e8 100644 --- a/tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py +++ b/tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import numpy as np from dataclasses import dataclass +import numpy as np import mindspore as ms from mindspore.common.tensor import Tensor diff --git a/tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py b/tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py index 53fcb5dabd0..28a3d8e7d88 100644 --- a/tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py +++ b/tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py @@ -16,7 +16,7 @@ import numpy as np from mindspore import Tensor -from mindspore.ops import Primitive, PrimitiveWithInfer +from mindspore.ops import Primitive from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G diff --git a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py index f34bc12625b..fa5b1b90558 100644 --- a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py +++ b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py @@ -136,8 +136,8 @@ class Net(nn.Cell): super(Net, self).__init__() self.conv = nn.Conv2d(3, 64, 3, bias_init='zeros') - def construct(self, input): - return self.conv(input) + def construct(self, inputs): + return self.conv(inputs) class TestNet(nn.Cell): diff --git a/tests/ut/cpp/python_input/gtest_input/session/session_test.py b/tests/ut/cpp/python_input/gtest_input/session/session_test.py index 6a33d246ec5..f45c3d3ce98 100644 --- a/tests/ut/cpp/python_input/gtest_input/session/session_test.py +++ b/tests/ut/cpp/python_input/gtest_input/session/session_test.py @@ -25,7 +25,7 @@ max_pool = P.MaxPoolWithArgmax(padding="same", ksize=3, strides=2) def test_addn_cast(x, y, z): - mysum = addn((x, y)) + mysum = addn((x, y, z)) res = cast(mysum, ms.float16) return res diff --git a/tests/ut/python/pipeline/infer/infer.py b/tests/ut/python/pipeline/infer/infer.py index 5bd9ea8161c..4945b0ed4fc 100644 --- a/tests/ut/python/pipeline/infer/infer.py +++ b/tests/ut/python/pipeline/infer/infer.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ """ infer """ -import numpy as np from argparse import ArgumentParser +import numpy as np from mindspore import Tensor from ....dataset_mock import MindData diff --git a/tests/ut/python/pipeline/infer/test_hypermap_specialize.py b/tests/ut/python/pipeline/infer/test_hypermap_specialize.py index f2363884371..1f669f73554 100644 --- a/tests/ut/python/pipeline/infer/test_hypermap_specialize.py +++ b/tests/ut/python/pipeline/infer/test_hypermap_specialize.py @@ -53,4 +53,4 @@ def test_hypermap_specialize_param(): expected_ret = (Tensor(np.full(1, 5).astype(np.int32)), Tensor(np.full(2, 5).astype(np.int32))) ret = hypermap_specialize_param() - assert (ret == (expected_ret, expected_ret)) + assert ret == (expected_ret, expected_ret) diff --git a/tests/ut/python/pipeline/parse/test_for_stmt.py b/tests/ut/python/pipeline/parse/test_for_stmt.py index 995d4fc88bd..4930dae796d 100644 --- a/tests/ut/python/pipeline/parse/test_for_stmt.py +++ b/tests/ut/python/pipeline/parse/test_for_stmt.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ """ test_for_stmt """ -import numpy as np from dataclasses import dataclass +import numpy as np from mindspore import Tensor, Model, context from mindspore.nn import Cell diff --git a/tests/ut/python/pipeline/parse/test_operator.py b/tests/ut/python/pipeline/parse/test_operator.py index aa1a76f347f..7958abed719 100644 --- a/tests/ut/python/pipeline/parse/test_operator.py +++ b/tests/ut/python/pipeline/parse/test_operator.py @@ -163,7 +163,7 @@ def test_ops(): ret_floor = p // q + q // p ret = ret_pow + ret_mod + ret_floor if self.int > self.float: - if [1, 2, 3] != None: + if [1, 2, 3] is not None: if self.str_a + self.str_b == "helloworld": if q == 86: print("hello world") diff --git a/tests/ut/python/pipeline/parse/test_parse.py b/tests/ut/python/pipeline/parse/test_parse.py index 114ae0c1497..bbc32d0728d 100644 --- a/tests/ut/python/pipeline/parse/test_parse.py +++ b/tests/ut/python/pipeline/parse/test_parse.py @@ -25,7 +25,6 @@ import mindspore as ms import mindspore.nn as nn from mindspore import Tensor from mindspore.common.api import ms_function, _executor -from mindspore.ops.composite import core from mindspore.ops.functional import tensor_add from ...ut_filter import non_graph_engine diff --git a/tests/ut/python/pynative_mode/nn/test_activation.py b/tests/ut/python/pynative_mode/nn/test_activation.py index 1b8a6f5d764..0adccc2f345 100644 --- a/tests/ut/python/pynative_mode/nn/test_activation.py +++ b/tests/ut/python/pynative_mode/nn/test_activation.py @@ -14,7 +14,6 @@ # ============================================================================ """ test Activations """ import numpy as np -import pytest import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/ut/python/pynative_mode/nn/test_cell.py b/tests/ut/python/pynative_mode/nn/test_cell.py index 68bda4f1e5f..ea052ef56d3 100644 --- a/tests/ut/python/pynative_mode/nn/test_cell.py +++ b/tests/ut/python/pynative_mode/nn/test_cell.py @@ -305,4 +305,4 @@ def test_net_call(): net = ConvNet() input_x = Tensor( np.random.randint(0, 255, [1, 3, net.image_h, net.image_w]).astype(np.float32)) - output = net.construct(input_x) + net.construct(input_x) diff --git a/tests/ut/python/pynative_mode/nn/test_container.py b/tests/ut/python/pynative_mode/nn/test_container.py index 175389c3bb5..8b2e537b5c7 100644 --- a/tests/ut/python/pynative_mode/nn/test_container.py +++ b/tests/ut/python/pynative_mode/nn/test_container.py @@ -13,9 +13,9 @@ # limitations under the License. # ============================================================================ """ test_container """ +from collections import OrderedDict import numpy as np import pytest -from collections import OrderedDict import mindspore.nn as nn from mindspore import Tensor