clean pylint

pull/1343/head
jinyaohui 5 years ago
parent d9c74e0acd
commit fbdba6e4da

@ -21,7 +21,6 @@ from mindspore import context
from mindspore.ops import operations as P
from ..mindspore_test import mindspore_test
from ..pipeline.gradient.compare_gradient import pipeline_for_compare_inputs_grad_with_npy_for_case_by_case_config
from ...vm_impl import *
verification_set = [
('MatMul', {

@ -13,15 +13,15 @@
# limitations under the License.
# ============================================================================
import pytest
from mindspore import Tensor
from mindspore.ops import operations as P
from mindspore.ops.operations import _grad_ops as G
import mindspore.nn as nn
from mindspore.common.api import ms_function
import numpy as np
import pytest
import mindspore.context as context
import mindspore.nn as nn
from mindspore import Tensor
from mindspore.common import dtype as mstype
from mindspore.common.api import ms_function
from mindspore.ops.operations import _grad_ops as G
context.set_context(mode=context.GRAPH_MODE, device_target='CPU')
@ -54,5 +54,6 @@ def test_slice():
print("output:\n", output)
assert (output.asnumpy() == expect).all()
if __name__ == '__main__':
test_slice()

@ -13,13 +13,14 @@
# limitations under the License.
# ============================================================================
import pytest
from mindspore import Tensor
from mindspore.ops import operations as P
import mindspore.nn as nn
import numpy as np
import pytest
import mindspore.context as context
import mindspore.nn as nn
from mindspore import Tensor
from mindspore.common import dtype as mstype
from mindspore.ops import operations as P
context.set_context(mode=context.GRAPH_MODE, device_target='CPU')
@ -45,6 +46,6 @@ def test_slice():
print("output:\n", output)
assert (output.asnumpy() == expect).all()
if __name__ == '__main__':
test_slice()

@ -12,15 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
import pytest
import numpy as np
import mindspore.nn as nn
import pytest
from cus_add3 import CusAdd3
import mindspore.context as context
import mindspore.nn as nn
from mindspore import Tensor
from mindspore.ops import composite as C
from cus_add3 import CusAdd3
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
class Net(nn.Cell):
"""Net definition"""
@ -31,6 +33,7 @@ class Net(nn.Cell):
def construct(self, input1, input2):
return self.add3(input1, input2)
@pytest.mark.level0
@pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_arm_ascend_training

@ -19,16 +19,14 @@
@Desc : parser class method function.
"""
import logging
import numpy as np
import sys
from collections import *
import mindspore.nn as nn
from mindspore.common.parameter import Parameter
from mindspore.common.tensor import Tensor
from mindspore.ops import Primitive, prim_attr_register
from mindspore.ops import functional as F
from mindspore.train.model import Model
log = logging.getLogger("test")
log.setLevel(level=logging.ERROR)

@ -201,6 +201,7 @@ def get_resolve_fn(x, y):
# Test:no return function
# pylint: disable=pointless-statement
def get_no_return_fn(x, y):
x + y
@ -339,6 +340,7 @@ def func_call(x, y, *var, a=0, b=1, **kwargs):
return x + y + var[0] + a + b + kwargs["z"]
# pylint: disable=repeated-keyword
def test_call_variable():
t = (1, 2, 3)
d = {"z": 10, "e": 11}

@ -434,6 +434,7 @@ def test_batch_exception_11():
assert "drop_remainder" in str(e)
# pylint: disable=redundant-keyword-arg
def test_batch_exception_12():
"""
Test batch exception: wrong input order, drop_remainder wrongly used as batch_size

@ -106,6 +106,7 @@ def test_center_crop_comp(height=375, width=375, plot=False):
visualize(image, image_cropped)
# pylint: disable=unnecessary-lambda
def test_crop_grayscale(height=375, width=375):
"""
Test that centercrop works with pad and grayscale images

@ -19,7 +19,6 @@ import mindspore.common.dtype as mstype
import mindspore.dataset as ds
import mindspore.dataset.transforms.c_transforms as C
import mindspore.dataset.transforms.vision.c_transforms as cde
from mindspore import log as logger
DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"]
SCHEMA_DIR = "../data/dataset/test_tf_file_3_images/datasetSchema.json"
@ -255,6 +254,7 @@ def filter_func_map(col1, col2):
return False
# pylint: disable=simplifiable-if-statement
def filter_func_map_part(col1):
if col1 < 3:
return True

@ -36,6 +36,7 @@ def normalize_np(image):
return image
# pylint: disable=inconsistent-return-statements
def get_normalized(image_id):
"""
Reads the image using DE ops and then normalizes using Numpy

@ -13,10 +13,10 @@
# limitations under the License.
# ==============================================================================
import numpy as np
import pytest
import mindspore.dataset as ds
# Generate 1d int numpy array from 0 - 63
def generator_1d():
for i in range(64):
@ -33,7 +33,7 @@ def test_case_0():
data1 = data1.shuffle(2)
data1 = data1.map(["data"], operations=(lambda x : x))
data1 = data1.map(["data"], operations=(lambda x: x))
data1 = data1.batch(2)

@ -70,6 +70,7 @@ def test_pad_op():
assert mse < 0.01
# pylint: disable=unnecessary-lambda
def test_pad_grayscale():
"""
Tests that the pad works for grayscale images

@ -253,6 +253,7 @@ def test_random_color_adjust_op_hue(plot=False):
visualize(c_image, mse, py_image)
# pylint: disable=unnecessary-lambda
def test_random_color_adjust_grayscale():
"""
Tests that the random color adjust works for grayscale images

@ -15,7 +15,6 @@
import numpy as np
import mindspore.dataset as ds
import mindspore.dataset.transforms.vision.c_transforms as vision
from mindspore import log as logger

@ -19,6 +19,7 @@ import pytest
import mindspore.dataset as ds
# pylint: disable=comparison-with-itself
def test_basic():
x = np.array([["ab", "cde", "121"], ["x", "km", "789"]], dtype='S')
# x = np.array(["ab", "cde"], dtype='S')

@ -137,16 +137,19 @@ def test_dict_set_or_get_item_3():
net = DictNet()
assert net() == Tensor(np.ones([4, 2, 3], np.float32))
def test_dict_set_item():
class DictSetNet(Cell):
def __init__(self):
super(DictSetNet, self).__init__()
self.attrs = ("abc", "edf", "ghi", "jkl")
def construct(self, x):
my_dict = {"def": x, "abc":x, "edf":x, "ghi":x, "jkl":x}
my_dict = {"def": x, "abc": x, "edf": x, "ghi": x, "jkl": x}
for i in range(len(self.attrs)):
my_dict[self.attrs[i]] = x - i
return my_dict["jkl"], my_dict["edf"]
x = Tensor(np.ones([2, 2, 3], np.float32))
net = DictSetNet()
out = net(x)

@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""test mnist to mindrecord tool"""
import cv2
import gzip
import pytest
import numpy as np
import os
import cv2
import numpy as np
import pytest
from mindspore import log as logger
from mindspore.mindrecord import FileReader
from mindspore.mindrecord import MnistToMR
@ -144,10 +145,10 @@ def test_mnist_to_mindrecord_compare_data(fixture_file):
assert np.array(x['label']) == label
reader.close()
def test_mnist_to_mindrecord_multi_partition(fixture_file):
"""test transform mnist dataset to multiple mindrecord files."""
mnist_transformer = MnistToMR(MNIST_DIR, FILE_NAME, PARTITION_NUM)
mnist_transformer.transform()
read("mnist_train.mindrecord0", "mnist_test.mindrecord0")

@ -1,3 +1,4 @@
# Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");

@ -13,8 +13,8 @@
# limitations under the License.
# ============================================================================
""" test control ops """
import pytest
import numpy as np
import pytest
import mindspore as ms
from mindspore import Tensor
@ -436,6 +436,7 @@ def test_index_to_switch_layer():
Tensor(np.full([128, 96], 0.6, dtype=np.float32)))
C.grad_all(net)(index, Tensor(np.full([128, 96], 0.6, dtype=np.float32)))
def test_control_depend_check():
with pytest.raises(TypeError) as e:
depend = P.ControlDepend(0.0)

@ -50,6 +50,7 @@ class Net(Cell):
return x
# pylint: disable=comparison-with-itself
class DropoutFactory:
def __init__(self, input_shape, keep_prob, seed0, seed1, strategy0=None):
size = 1

@ -13,11 +13,12 @@
# limitations under the License.
# ============================================================================
import numpy as np
import mindspore as ms
from mindspore import context, Tensor, Parameter
from mindspore.nn import Cell, TrainOneStepCell, Momentum
from mindspore.ops import operations as P
from mindspore.common.api import _executor
from mindspore.nn import Cell
from mindspore.ops import operations as P
class Net(Cell):
@ -54,7 +55,7 @@ def test_train_and_eval():
context.set_context(save_graphs=True, mode=0)
context.set_auto_parallel_context(parallel_mode="semi_auto_parallel", device_num=16)
strategy1 = ((4, 4), (4, 4))
strategy2 = ((4, 4), )
strategy2 = ((4, 4),)
net = Net(_w1, strategy1, strategy2)
eval_net = EvalNet(net, strategy2=strategy2)
net.set_train()

@ -50,6 +50,7 @@ def test_parser_three_default_mixed_args_subnet():
assert net(tensor1, tensor2) == tensor1
# pylint: disable=keyword-arg-before-vararg
def test_net_vararg_kwonlyarg_kwarg():
class FirstNet(Cell):
def __init__(self):
@ -76,6 +77,7 @@ def test_net_vararg_kwonlyarg_kwarg():
net()
# pylint: disable=keyword-arg-before-vararg
def test_net_vararg_normal_input():
class FirstNet(Cell):
def __init__(self):

@ -34,6 +34,7 @@ def run_test(netclass, count):
# np.testing.assert_array_almost_equal(output_np, output_ms.asnumpy(), decimal=3)
# pylint: disable=unnecessary-pass
class for_loop_with_break(Cell):
def __init__(self):
super().__init__()
@ -70,7 +71,7 @@ class for_loop_with_continue(Cell):
def test_for_loop_with_continue():
run_test(for_loop_with_continue, 10)
# pylint: disable=unnecessary-pass
class for_loop_with_cont_break(Cell):
def __init__(self):
super().__init__()

@ -38,6 +38,7 @@ def vm_impl_tensor_add(self):
return vm_impl
# pylint: disable=used-before-assignment
@vm_impl_getters.register(P.LogicalNot)
def vm_impl_logical_not(self):
x = x.asnumpy()

Loading…
Cancel
Save