The following issues were found

torch/ao/sparsity/__init__.py
12 issues
Unable to import '__init__._mappings'
Error

Line: 2 Column: 1

              # Variables
from ._mappings import get_dynamic_sparse_quantized_mapping
from ._mappings import get_static_sparse_quantized_mapping

# Sparsifier
from .sparsifier.base_sparsifier import BaseSparsifier
from .sparsifier.weight_norm_sparsifier import WeightNormSparsifier

# Scheduler

            

Reported by Pylint.

Unable to import '__init__._mappings'
Error

Line: 3 Column: 1

              # Variables
from ._mappings import get_dynamic_sparse_quantized_mapping
from ._mappings import get_static_sparse_quantized_mapping

# Sparsifier
from .sparsifier.base_sparsifier import BaseSparsifier
from .sparsifier.weight_norm_sparsifier import WeightNormSparsifier

# Scheduler

            

Reported by Pylint.

Unable to import '__init__.sparsifier.base_sparsifier'
Error

Line: 6 Column: 1

              from ._mappings import get_static_sparse_quantized_mapping

# Sparsifier
from .sparsifier.base_sparsifier import BaseSparsifier
from .sparsifier.weight_norm_sparsifier import WeightNormSparsifier

# Scheduler
from .scheduler.base_scheduler import BaseScheduler
from .scheduler.lambda_scheduler import LambdaSL

            

Reported by Pylint.

Unable to import '__init__.sparsifier.weight_norm_sparsifier'
Error

Line: 7 Column: 1

              
# Sparsifier
from .sparsifier.base_sparsifier import BaseSparsifier
from .sparsifier.weight_norm_sparsifier import WeightNormSparsifier

# Scheduler
from .scheduler.base_scheduler import BaseScheduler
from .scheduler.lambda_scheduler import LambdaSL


            

Reported by Pylint.

Unable to import '__init__.scheduler.base_scheduler'
Error

Line: 10 Column: 1

              from .sparsifier.weight_norm_sparsifier import WeightNormSparsifier

# Scheduler
from .scheduler.base_scheduler import BaseScheduler
from .scheduler.lambda_scheduler import LambdaSL

# Parametrizations
from .sparsifier.utils import FakeSparsity


            

Reported by Pylint.

Unable to import '__init__.scheduler.lambda_scheduler'
Error

Line: 11 Column: 1

              
# Scheduler
from .scheduler.base_scheduler import BaseScheduler
from .scheduler.lambda_scheduler import LambdaSL

# Parametrizations
from .sparsifier.utils import FakeSparsity

# === Experimental ===

            

Reported by Pylint.

Unable to import '__init__.sparsifier.utils'
Error

Line: 14 Column: 1

              from .scheduler.lambda_scheduler import LambdaSL

# Parametrizations
from .sparsifier.utils import FakeSparsity

# === Experimental ===

# Parametrizations
from .experimental.pruner.parametrization import PruningParametrization

            

Reported by Pylint.

Unable to import '__init__.experimental.pruner.parametrization'
Error

Line: 19 Column: 1

              # === Experimental ===

# Parametrizations
from .experimental.pruner.parametrization import PruningParametrization
from .experimental.pruner.parametrization import LinearActivationReconstruction
from .experimental.pruner.parametrization import Conv2dActivationReconstruction

# Pruner
from .experimental.pruner.base_pruner import BasePruner

            

Reported by Pylint.

Unable to import '__init__.experimental.pruner.parametrization'
Error

Line: 20 Column: 1

              
# Parametrizations
from .experimental.pruner.parametrization import PruningParametrization
from .experimental.pruner.parametrization import LinearActivationReconstruction
from .experimental.pruner.parametrization import Conv2dActivationReconstruction

# Pruner
from .experimental.pruner.base_pruner import BasePruner

            

Reported by Pylint.

Unable to import '__init__.experimental.pruner.parametrization'
Error

Line: 21 Column: 1

              # Parametrizations
from .experimental.pruner.parametrization import PruningParametrization
from .experimental.pruner.parametrization import LinearActivationReconstruction
from .experimental.pruner.parametrization import Conv2dActivationReconstruction

# Pruner
from .experimental.pruner.base_pruner import BasePruner

            

Reported by Pylint.

test/jit/test_fuser_common.py
12 issues
Unable to import 'torch'
Error

Line: 1 Column: 1

              import torch
from torch.testing._internal.jit_utils import JitTestCase

class TestFuserCommon(JitTestCase):
    def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)

            

Reported by Pylint.

Unable to import 'torch.testing._internal.jit_utils'
Error

Line: 2 Column: 1

              import torch
from torch.testing._internal.jit_utils import JitTestCase

class TestFuserCommon(JitTestCase):
    def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 13 Column: 17

              
            x = torch.randn(5, requires_grad=not rq)
            # cause optimization to be created
            for i in range(5):
                fn(x)
            # test fallback when optimization is not applicable
            y = fn(torch.randn(5, requires_grad=rq))
            self.assertEqual(y.requires_grad, rq)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import torch
from torch.testing._internal.jit_utils import JitTestCase

class TestFuserCommon(JitTestCase):
    def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              import torch
from torch.testing._internal.jit_utils import JitTestCase

class TestFuserCommon(JitTestCase):
    def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 4 Column: 1

              import torch
from torch.testing._internal.jit_utils import JitTestCase

class TestFuserCommon(JitTestCase):
    def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 5

              from torch.testing._internal.jit_utils import JitTestCase

class TestFuserCommon(JitTestCase):
    def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)


            

Reported by Pylint.

Variable name "rq" doesn't conform to snake_case naming style
Error

Line: 6 Column: 13

              
class TestFuserCommon(JitTestCase):
    def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)

            x = torch.randn(5, requires_grad=not rq)

            

Reported by Pylint.

Argument name "x" doesn't conform to snake_case naming style
Error

Line: 8 Column: 13

                  def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)

            x = torch.randn(5, requires_grad=not rq)
            # cause optimization to be created
            for i in range(5):

            

Reported by Pylint.

Function name "fn" doesn't conform to snake_case naming style
Error

Line: 8 Column: 13

                  def test_autodiff_fallback(self):
        for rq in [True, False]:
            @torch.jit.script
            def fn(x):
                return torch.max(x**2.0, x**3.0)

            x = torch.randn(5, requires_grad=not rq)
            # cause optimization to be created
            for i in range(5):

            

Reported by Pylint.

caffe2/python/operator_test/sparse_normalize_test.py
12 issues
Unable to import 'hypothesis'
Error

Line: 2 Column: 1

              import caffe2.python.hypothesis_test_util as hu
import hypothesis
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core
from hypothesis import HealthCheck, given, settings


class TestSparseNormalize(hu.HypothesisTestCase):

            

Reported by Pylint.

Unable to import 'hypothesis.strategies'
Error

Line: 3 Column: 1

              import caffe2.python.hypothesis_test_util as hu
import hypothesis
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core
from hypothesis import HealthCheck, given, settings


class TestSparseNormalize(hu.HypothesisTestCase):

            

Reported by Pylint.

Unable to import 'hypothesis'
Error

Line: 6 Column: 1

              import hypothesis.strategies as st
import numpy as np
from caffe2.python import core
from hypothesis import HealthCheck, given, settings


class TestSparseNormalize(hu.HypothesisTestCase):
    @staticmethod
    def ref_normalize(param_in, use_max_norm, norm):

            

Reported by Pylint.

Unused argument 'dc'
Error

Line: 29 Column: 72

                      **hu.gcs_cpu_only
    )
    def test_sparse_normalize(
        self, inputs, use_max_norm, norm, data_strategy, use_fp16, gc, dc
    ):
        param, grad = inputs
        param += 0.02 * np.sign(param)
        param[param == 0.0] += 0.02


            

Reported by Pylint.

Unused argument 'grad'
Error

Line: 75 Column: 50

                          norm=norm,
        )

        def ref_sparse_normalize(param, indices, grad=None):
            param_out = np.copy(param)
            for _, index in enumerate(indices):
                param_out[index] = self.ref_normalize(param[index], use_max_norm, norm)
            return (param_out,)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import caffe2.python.hypothesis_test_util as hu
import hypothesis
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core
from hypothesis import HealthCheck, given, settings


class TestSparseNormalize(hu.HypothesisTestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              from hypothesis import HealthCheck, given, settings


class TestSparseNormalize(hu.HypothesisTestCase):
    @staticmethod
    def ref_normalize(param_in, use_max_norm, norm):
        param_norm = np.linalg.norm(param_in) + 1e-12
        if (use_max_norm and param_norm > norm) or not use_max_norm:
            param_in = param_in * norm / param_norm

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              
class TestSparseNormalize(hu.HypothesisTestCase):
    @staticmethod
    def ref_normalize(param_in, use_max_norm, norm):
        param_norm = np.linalg.norm(param_in) + 1e-12
        if (use_max_norm and param_norm > norm) or not use_max_norm:
            param_in = param_in * norm / param_norm
        return param_in


            

Reported by Pylint.

Too many arguments (8/5)
Error

Line: 27 Column: 5

                      data_strategy=st.data(),
        use_fp16=st.booleans(),
        **hu.gcs_cpu_only
    )
    def test_sparse_normalize(
        self, inputs, use_max_norm, norm, data_strategy, use_fp16, gc, dc
    ):
        param, grad = inputs
        param += 0.02 * np.sign(param)

            

Reported by Pylint.

Argument name "gc" doesn't conform to snake_case naming style
Error

Line: 27 Column: 5

                      data_strategy=st.data(),
        use_fp16=st.booleans(),
        **hu.gcs_cpu_only
    )
    def test_sparse_normalize(
        self, inputs, use_max_norm, norm, data_strategy, use_fp16, gc, dc
    ):
        param, grad = inputs
        param += 0.02 * np.sign(param)

            

Reported by Pylint.

caffe2/python/operator_test/weighted_multi_sample_test.py
12 issues
Unable to import 'hypothesis'
Error

Line: 8 Column: 1

              
import numpy as np

from hypothesis import given
import hypothesis.strategies as st

from caffe2.python import core
from caffe2.python import workspace
import caffe2.python.hypothesis_test_util as hu

            

Reported by Pylint.

Unable to import 'hypothesis.strategies'
Error

Line: 9 Column: 1

              import numpy as np

from hypothesis import given
import hypothesis.strategies as st

from caffe2.python import core
from caffe2.python import workspace
import caffe2.python.hypothesis_test_util as hu


            

Reported by Pylint.

Unused argument 'gc'
Error

Line: 22 Column: 65

                      data_len=st.integers(min_value=0, max_value=10000),
        **hu.gcs_cpu_only
    )
    def test_weighted_multi_sample(self, num_samples, data_len, gc, dc):
        weights = np.zeros((data_len))
        expected_indices = []
        if data_len > 0:
            weights[-1] = 1.5
            expected_indices = np.repeat(data_len - 1, num_samples)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              




import numpy as np

from hypothesis import given
import hypothesis.strategies as st

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import caffe2.python.hypothesis_test_util as hu


class TestWeightedMultiSample(hu.HypothesisTestCase):
    @given(
        num_samples=st.integers(min_value=0, max_value=128),
        data_len=st.integers(min_value=0, max_value=10000),
        **hu.gcs_cpu_only
    )

            

Reported by Pylint.

Argument name "gc" doesn't conform to snake_case naming style
Error

Line: 21 Column: 5

                      num_samples=st.integers(min_value=0, max_value=128),
        data_len=st.integers(min_value=0, max_value=10000),
        **hu.gcs_cpu_only
    )
    def test_weighted_multi_sample(self, num_samples, data_len, gc, dc):
        weights = np.zeros((data_len))
        expected_indices = []
        if data_len > 0:
            weights[-1] = 1.5

            

Reported by Pylint.

Argument name "dc" doesn't conform to snake_case naming style
Error

Line: 21 Column: 5

                      num_samples=st.integers(min_value=0, max_value=128),
        data_len=st.integers(min_value=0, max_value=10000),
        **hu.gcs_cpu_only
    )
    def test_weighted_multi_sample(self, num_samples, data_len, gc, dc):
        weights = np.zeros((data_len))
        expected_indices = []
        if data_len > 0:
            weights[-1] = 1.5

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 5

                      num_samples=st.integers(min_value=0, max_value=128),
        data_len=st.integers(min_value=0, max_value=10000),
        **hu.gcs_cpu_only
    )
    def test_weighted_multi_sample(self, num_samples, data_len, gc, dc):
        weights = np.zeros((data_len))
        expected_indices = []
        if data_len > 0:
            weights[-1] = 1.5

            

Reported by Pylint.

Variable name "op" doesn't conform to snake_case naming style
Error

Line: 31 Column: 9

              
        workspace.FeedBlob("weights", weights.astype(np.float32))

        op = core.CreateOperator(
            "WeightedMultiSampling",
            ["weights"],
            ["sample_indices"],
            num_samples=num_samples,
        )

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 58
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      workspace.RunOperatorOnce(op2)
        result_indices_2 = workspace.FetchBlob("sample_indices_2")
        if data_len > 0:
            assert len(result_indices_2) == num_samples
            for i in range(num_samples):
                assert 0 <= result_indices_2[i] < data_len
        else:
            assert len(result_indices_2) == 0


            

Reported by Bandit.

caffe2/python/operator_test/pad_test.py
12 issues
Unable to import 'hypothesis.strategies'
Error

Line: 8 Column: 1

              from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
import unittest


class TestPad(serial.SerializedTestCase):

            

Reported by Pylint.

Unused argument 'mode'
Error

Line: 26 Column: 19

                         **hu.gcs)
    def test_crop(self,
                  pad_t, pad_l, pad_b, pad_r,
                  mode,
                  size_w, size_h, size_c, size_n,
                  gc, dc):
        op = core.CreateOperator(
            "PadImage",
            ["X"],

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              



from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np

            

Reported by Pylint.

standard import "import unittest" should be placed before "from caffe2.python import core"
Error

Line: 10 Column: 1

              import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
import unittest


class TestPad(serial.SerializedTestCase):
    @serial.given(pad_t=st.integers(-5, 0),
           pad_l=st.integers(-5, 0),

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              import unittest


class TestPad(serial.SerializedTestCase):
    @serial.given(pad_t=st.integers(-5, 0),
           pad_l=st.integers(-5, 0),
           pad_b=st.integers(-5, 0),
           pad_r=st.integers(-5, 0),
           mode=st.sampled_from(["constant", "reflect", "edge"]),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                         size_c=st.integers(1, 4),
           size_n=st.integers(1, 4),
           **hu.gcs)
    def test_crop(self,
                  pad_t, pad_l, pad_b, pad_r,
                  mode,
                  size_w, size_h, size_c, size_n,
                  gc, dc):
        op = core.CreateOperator(

            

Reported by Pylint.

Too many arguments (12/5)
Error

Line: 24 Column: 5

                         size_c=st.integers(1, 4),
           size_n=st.integers(1, 4),
           **hu.gcs)
    def test_crop(self,
                  pad_t, pad_l, pad_b, pad_r,
                  mode,
                  size_w, size_h, size_c, size_n,
                  gc, dc):
        op = core.CreateOperator(

            

Reported by Pylint.

Argument name "dc" doesn't conform to snake_case naming style
Error

Line: 24 Column: 5

                         size_c=st.integers(1, 4),
           size_n=st.integers(1, 4),
           **hu.gcs)
    def test_crop(self,
                  pad_t, pad_l, pad_b, pad_r,
                  mode,
                  size_w, size_h, size_c, size_n,
                  gc, dc):
        op = core.CreateOperator(

            

Reported by Pylint.

Argument name "gc" doesn't conform to snake_case naming style
Error

Line: 24 Column: 5

                         size_c=st.integers(1, 4),
           size_n=st.integers(1, 4),
           **hu.gcs)
    def test_crop(self,
                  pad_t, pad_l, pad_b, pad_r,
                  mode,
                  size_w, size_h, size_c, size_n,
                  gc, dc):
        op = core.CreateOperator(

            

Reported by Pylint.

Variable name "op" doesn't conform to snake_case naming style
Error

Line: 29 Column: 9

                                mode,
                  size_w, size_h, size_c, size_n,
                  gc, dc):
        op = core.CreateOperator(
            "PadImage",
            ["X"],
            ["Y"],
            pad_t=pad_t,
            pad_l=pad_l,

            

Reported by Pylint.

caffe2/python/operator_test/mod_op_test.py
12 issues
Unable to import 'hypothesis'
Error

Line: 4 Column: 1

              import numpy

from caffe2.python import core
from hypothesis import given, settings

import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np


            

Reported by Pylint.

Unable to import 'hypothesis.strategies'
Error

Line: 7 Column: 1

              from hypothesis import given, settings

import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np


@st.composite
def _data(draw):

            

Reported by Pylint.

Reimport 'numpy' (imported line 1)
Error

Line: 8 Column: 1

              
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np


@st.composite
def _data(draw):
    return draw(

            

Reported by Pylint.

Unused argument 'dc'
Error

Line: 35 Column: 64

                      **hu.gcs
    )
    def test_mod(
        self, data, divisor, inplace, sign_follow_divisor, gc, dc
    ):
        if divisor == 0:
            # invalid test case
            return None


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy

from caffe2.python import core
from hypothesis import given, settings

import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np


            

Reported by Pylint.

Imports from package numpy are not grouped
Error

Line: 8 Column: 1

              
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np


@st.composite
def _data(draw):
    return draw(

            

Reported by Pylint.

Missing class docstring
Error

Line: 23 Column: 1

                  )


class TestMod(hu.HypothesisTestCase):
    @settings(deadline=None)
    @given(
        data=_data(),
        divisor=st.integers(
            min_value=np.iinfo(np.int64).min, max_value=np.iinfo(np.int64).max

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 5

                      inplace=st.booleans(),
        sign_follow_divisor=st.booleans(),
        **hu.gcs
    )
    def test_mod(
        self, data, divisor, inplace, sign_follow_divisor, gc, dc
    ):
        if divisor == 0:
            # invalid test case

            

Reported by Pylint.

Too many arguments (7/5)
Error

Line: 33 Column: 5

                      inplace=st.booleans(),
        sign_follow_divisor=st.booleans(),
        **hu.gcs
    )
    def test_mod(
        self, data, divisor, inplace, sign_follow_divisor, gc, dc
    ):
        if divisor == 0:
            # invalid test case

            

Reported by Pylint.

Argument name "dc" doesn't conform to snake_case naming style
Error

Line: 33 Column: 5

                      inplace=st.booleans(),
        sign_follow_divisor=st.booleans(),
        **hu.gcs
    )
    def test_mod(
        self, data, divisor, inplace, sign_follow_divisor, gc, dc
    ):
        if divisor == 0:
            # invalid test case

            

Reported by Pylint.

caffe2/python/operator_test/mean_op_test.py
12 issues
Unable to import 'hypothesis.strategies'
Error

Line: 9 Column: 1

              from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
import unittest


class TestMean(serial.SerializedTestCase):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              




from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st

            

Reported by Pylint.

standard import "import unittest" should be placed before "from caffe2.python import core"
Error

Line: 11 Column: 1

              import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
import unittest


class TestMean(serial.SerializedTestCase):
    @serial.given(
        k=st.integers(1, 5),

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              import unittest


class TestMean(serial.SerializedTestCase):
    @serial.given(
        k=st.integers(1, 5),
        n=st.integers(1, 10),
        m=st.integers(1, 10),
        in_place=st.booleans(),

            

Reported by Pylint.

Too many arguments (8/5)
Error

Line: 22 Column: 5

                      in_place=st.booleans(),
        seed=st.integers(0, 2**32 - 1),
        **hu.gcs
    )
    def test_mean(self, k, n, m, in_place, seed, gc, dc):
        np.random.seed(seed)
        input_names = []
        input_vars = []


            

Reported by Pylint.

Argument name "m" doesn't conform to snake_case naming style
Error

Line: 22 Column: 5

                      in_place=st.booleans(),
        seed=st.integers(0, 2**32 - 1),
        **hu.gcs
    )
    def test_mean(self, k, n, m, in_place, seed, gc, dc):
        np.random.seed(seed)
        input_names = []
        input_vars = []


            

Reported by Pylint.

Argument name "gc" doesn't conform to snake_case naming style
Error

Line: 22 Column: 5

                      in_place=st.booleans(),
        seed=st.integers(0, 2**32 - 1),
        **hu.gcs
    )
    def test_mean(self, k, n, m, in_place, seed, gc, dc):
        np.random.seed(seed)
        input_names = []
        input_vars = []


            

Reported by Pylint.

Argument name "dc" doesn't conform to snake_case naming style
Error

Line: 22 Column: 5

                      in_place=st.booleans(),
        seed=st.integers(0, 2**32 - 1),
        **hu.gcs
    )
    def test_mean(self, k, n, m, in_place, seed, gc, dc):
        np.random.seed(seed)
        input_names = []
        input_vars = []


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                      in_place=st.booleans(),
        seed=st.integers(0, 2**32 - 1),
        **hu.gcs
    )
    def test_mean(self, k, n, m, in_place, seed, gc, dc):
        np.random.seed(seed)
        input_names = []
        input_vars = []


            

Reported by Pylint.

Argument name "n" doesn't conform to snake_case naming style
Error

Line: 22 Column: 5

                      in_place=st.booleans(),
        seed=st.integers(0, 2**32 - 1),
        **hu.gcs
    )
    def test_mean(self, k, n, m, in_place, seed, gc, dc):
        np.random.seed(seed)
        input_names = []
        input_vars = []


            

Reported by Pylint.

test/custom_operator/model.py
12 issues
Unable to import 'torch'
Error

Line: 5 Column: 1

              import os.path
import sys

import torch


def get_custom_op_library_path():
    if sys.platform.startswith("win32"):
        library_filename = "custom_ops.dll"

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 26 Column: 23

                      self.p = torch.nn.Parameter(torch.eye(5))

    @torch.jit.script_method
    def forward(self, input):
        return torch.ops.custom.op_with_defaults(input)[0] + 1


def main():
    parser = argparse.ArgumentParser(

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import argparse
import os.path
import sys

import torch


def get_custom_op_library_path():
    if sys.platform.startswith("win32"):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              import torch


def get_custom_op_library_path():
    if sys.platform.startswith("win32"):
        library_filename = "custom_ops.dll"
    elif sys.platform.startswith("darwin"):
        library_filename = "libcustom_ops.dylib"
    else:

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 16
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  else:
        library_filename = "libcustom_ops.so"
    path = os.path.abspath("build/{}".format(library_filename))
    assert os.path.exists(path), path
    return path


class Model(torch.jit.ScriptModule):
    def __init__(self):

            

Reported by Bandit.

Missing class docstring
Error

Line: 20 Column: 1

                  return path


class Model(torch.jit.ScriptModule):
    def __init__(self):
        super(Model, self).__init__()
        self.p = torch.nn.Parameter(torch.eye(5))

    @torch.jit.script_method

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 20 Column: 1

                  return path


class Model(torch.jit.ScriptModule):
    def __init__(self):
        super(Model, self).__init__()
        self.p = torch.nn.Parameter(torch.eye(5))

    @torch.jit.script_method

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 22 Column: 9

              
class Model(torch.jit.ScriptModule):
    def __init__(self):
        super(Model, self).__init__()
        self.p = torch.nn.Parameter(torch.eye(5))

    @torch.jit.script_method
    def forward(self, input):
        return torch.ops.custom.op_with_defaults(input)[0] + 1

            

Reported by Pylint.

Attribute name "p" doesn't conform to snake_case naming style
Error

Line: 23 Column: 9

              class Model(torch.jit.ScriptModule):
    def __init__(self):
        super(Model, self).__init__()
        self.p = torch.nn.Parameter(torch.eye(5))

    @torch.jit.script_method
    def forward(self, input):
        return torch.ops.custom.op_with_defaults(input)[0] + 1


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                      self.p = torch.nn.Parameter(torch.eye(5))

    @torch.jit.script_method
    def forward(self, input):
        return torch.ops.custom.op_with_defaults(input)[0] + 1


def main():
    parser = argparse.ArgumentParser(

            

Reported by Pylint.

caffe2/python/operator_test/flatten_op_test.py
12 issues
Unable to import 'hypothesis'
Error

Line: 6 Column: 1

              


from hypothesis import given
import numpy as np

from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu


            

Reported by Pylint.

Cell variable axis defined in loop
Error

Line: 26 Column: 40

              
            def flatten_ref(X):
                shape = X.shape
                outer = np.prod(shape[:axis]).astype(int)
                inner = np.prod(shape[axis:]).astype(int)
                return np.copy(X).reshape(outer, inner),

            self.assertReferenceChecks(gc, op, [X], flatten_ref)


            

Reported by Pylint.

Cell variable axis defined in loop
Error

Line: 27 Column: 39

                          def flatten_ref(X):
                shape = X.shape
                outer = np.prod(shape[:axis]).astype(int)
                inner = np.prod(shape[axis:]).astype(int)
                return np.copy(X).reshape(outer, inner),

            self.assertReferenceChecks(gc, op, [X], flatten_ref)

        # Check over multiple devices

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              




from hypothesis import given
import numpy as np

from caffe2.python import core

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              import caffe2.python.hypothesis_test_util as hu


class TestFlatten(hu.HypothesisTestCase):
    @given(X=hu.tensor(min_dim=2, max_dim=4),
           **hu.gcs)
    def test_flatten(self, X, gc, dc):
        for axis in range(X.ndim + 1):
            op = core.CreateOperator(

            

Reported by Pylint.

Argument name "X" doesn't conform to snake_case naming style
Error

Line: 16 Column: 5

              class TestFlatten(hu.HypothesisTestCase):
    @given(X=hu.tensor(min_dim=2, max_dim=4),
           **hu.gcs)
    def test_flatten(self, X, gc, dc):
        for axis in range(X.ndim + 1):
            op = core.CreateOperator(
                "Flatten",
                ["X"],
                ["Y"],

            

Reported by Pylint.

Argument name "gc" doesn't conform to snake_case naming style
Error

Line: 16 Column: 5

              class TestFlatten(hu.HypothesisTestCase):
    @given(X=hu.tensor(min_dim=2, max_dim=4),
           **hu.gcs)
    def test_flatten(self, X, gc, dc):
        for axis in range(X.ndim + 1):
            op = core.CreateOperator(
                "Flatten",
                ["X"],
                ["Y"],

            

Reported by Pylint.

Argument name "dc" doesn't conform to snake_case naming style
Error

Line: 16 Column: 5

              class TestFlatten(hu.HypothesisTestCase):
    @given(X=hu.tensor(min_dim=2, max_dim=4),
           **hu.gcs)
    def test_flatten(self, X, gc, dc):
        for axis in range(X.ndim + 1):
            op = core.CreateOperator(
                "Flatten",
                ["X"],
                ["Y"],

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              class TestFlatten(hu.HypothesisTestCase):
    @given(X=hu.tensor(min_dim=2, max_dim=4),
           **hu.gcs)
    def test_flatten(self, X, gc, dc):
        for axis in range(X.ndim + 1):
            op = core.CreateOperator(
                "Flatten",
                ["X"],
                ["Y"],

            

Reported by Pylint.

Variable name "op" doesn't conform to snake_case naming style
Error

Line: 18 Column: 13

                         **hu.gcs)
    def test_flatten(self, X, gc, dc):
        for axis in range(X.ndim + 1):
            op = core.CreateOperator(
                "Flatten",
                ["X"],
                ["Y"],
                axis=axis)


            

Reported by Pylint.

caffe2/python/operator_test/find_op_test.py
12 issues
Unable to import 'hypothesis.strategies'
Error

Line: 10 Column: 1

              import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial

import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np


class TestFindOperator(serial.SerializedTestCase):

            

Reported by Pylint.

Unable to import 'hypothesis'
Error

Line: 11 Column: 1

              import caffe2.python.serialized_test.serialized_test_util as serial

import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np


class TestFindOperator(serial.SerializedTestCase):


            

Reported by Pylint.

Unused argument 'dc'
Error

Line: 21 Column: 41

                      idxsize=st.sampled_from([2, 4, 8, 1000, 5000]),
        **hu.gcs)
    @settings(deadline=10000)
    def test_find(self, n, idxsize, gc, dc):
        maxval = 10

        def findop(idx, X):
            res = []
            for j in list(X.flatten()):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              




from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial


            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              import numpy as np


class TestFindOperator(serial.SerializedTestCase):

    @given(n=st.sampled_from([1, 4, 8, 31, 79, 150]),
        idxsize=st.sampled_from([2, 4, 8, 1000, 5000]),
        **hu.gcs)
    @settings(deadline=10000)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 5

                      idxsize=st.sampled_from([2, 4, 8, 1000, 5000]),
        **hu.gcs)
    @settings(deadline=10000)
    def test_find(self, n, idxsize, gc, dc):
        maxval = 10

        def findop(idx, X):
            res = []
            for j in list(X.flatten()):

            

Reported by Pylint.

Argument name "dc" doesn't conform to snake_case naming style
Error

Line: 21 Column: 5

                      idxsize=st.sampled_from([2, 4, 8, 1000, 5000]),
        **hu.gcs)
    @settings(deadline=10000)
    def test_find(self, n, idxsize, gc, dc):
        maxval = 10

        def findop(idx, X):
            res = []
            for j in list(X.flatten()):

            

Reported by Pylint.

Argument name "gc" doesn't conform to snake_case naming style
Error

Line: 21 Column: 5

                      idxsize=st.sampled_from([2, 4, 8, 1000, 5000]),
        **hu.gcs)
    @settings(deadline=10000)
    def test_find(self, n, idxsize, gc, dc):
        maxval = 10

        def findop(idx, X):
            res = []
            for j in list(X.flatten()):

            

Reported by Pylint.

Argument name "n" doesn't conform to snake_case naming style
Error

Line: 21 Column: 5

                      idxsize=st.sampled_from([2, 4, 8, 1000, 5000]),
        **hu.gcs)
    @settings(deadline=10000)
    def test_find(self, n, idxsize, gc, dc):
        maxval = 10

        def findop(idx, X):
            res = []
            for j in list(X.flatten()):

            

Reported by Pylint.

Argument name "X" doesn't conform to snake_case naming style
Error

Line: 24 Column: 9

                  def test_find(self, n, idxsize, gc, dc):
        maxval = 10

        def findop(idx, X):
            res = []
            for j in list(X.flatten()):
                i = np.where(idx == j)[0]
                if len(i) == 0:
                    res.append(-1)

            

Reported by Pylint.