The following issues were found

numpy/distutils/fcompiler/__init__.py
108 issues
Unable to import '__init__.environment'
Error

Line: 36 Column: 1

              from numpy.distutils.exec_command import find_executable
from numpy.distutils import _shell_utils

from .environment import EnvironmentConfig

__metaclass__ = type

class CompilerNotFound(Exception):
    pass

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 243 Column: 5

                  # Use properties for the attributes used by CCompiler. Setting them
    # as attributes from the self.executables dictionary is error-prone,
    # so we get them from there each time.
    def _command_property(key):
        def fget(self):
            assert self._is_customised
            return self.executables[key]
        return property(fget=fget)
    version_cmd = _command_property('version_cmd')

            

Reported by Pylint.

Class 'CCompiler' has no 'get_version' member
Error

Line: 424 Column: 19

              
    def get_version(self, force=False, ok_status=[0]):
        assert self._is_customised
        version = CCompiler.get_version(self, force=force, ok_status=ok_status)
        if version is None:
            raise CompilerNotFound()
        return version



            

Reported by Pylint.

Unexpected keyword argument 'display' in method call
Error

Line: 610 Column: 13

                      display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,
                              src)
        try:
            self.spawn(command, display=display)
        except DistutilsExecError as e:
            msg = str(e)
            raise CompileError(msg) from None

    def module_options(self, module_dirs, module_build_dir):

            

Reported by Pylint.

XXX: needs preprocessor
Error

Line: 141 Column: 3

              
    language_map = {'.f': 'f77',
                    '.for': 'f77',
                    '.F': 'f77',    # XXX: needs preprocessor
                    '.ftn': 'f77',
                    '.f77': 'f77',
                    '.f90': 'f90',
                    '.F90': 'f90',  # XXX: needs preprocessor
                    '.f95': 'f90',

            

Reported by Pylint.

XXX: needs preprocessor
Error

Line: 145 Column: 3

                                  '.ftn': 'f77',
                    '.f77': 'f77',
                    '.f90': 'f90',
                    '.F90': 'f90',  # XXX: needs preprocessor
                    '.f95': 'f90',
                    }
    language_order = ['f90', 'f77']



            

Reported by Pylint.

Access to a protected member _is_customised of a client class
Error

Line: 245 Column: 20

                  # so we get them from there each time.
    def _command_property(key):
        def fget(self):
            assert self._is_customised
            return self.executables[key]
        return property(fget=fget)
    version_cmd = _command_property('version_cmd')
    compiler_f77 = _command_property('compiler_f77')
    compiler_f90 = _command_property('compiler_f90')

            

Reported by Pylint.

Unused variable 'verify_command_form'
Error

Line: 302 Column: 9

                          fc_exe = find_executable(exe)
            exe_cache[exe] = exe_cache[fc_exe] = fc_exe
            return fc_exe
        def verify_command_form(name, value):
            if value is not None and not is_sequence_of_strings(value):
                raise ValueError(
                    "%s value %r is invalid in class %s" %
                    (name, value, self.__class__.__name__))
        def set_exe(exe_key, f77=None, f90=None):

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 368 Column: 9

                      the command, which will be replaced by the found F77 or F90
        compiler.
        """
        pass

    def get_flags(self):
        """List of flags common to all compiler types."""
        return [] + self.pic_flags


            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 422 Column: 5

                      """List of compiler library directories."""
        return self.library_dirs[:]

    def get_version(self, force=False, ok_status=[0]):
        assert self._is_customised
        version = CCompiler.get_version(self, force=force, ok_status=ok_status)
        if version is None:
            raise CompilerNotFound()
        return version

            

Reported by Pylint.

benchmarks/benchmarks/bench_linalg.py
108 issues
Attempted relative import beyond top-level package
Error

Line: 1 Column: 1

              from .common import Benchmark, get_squares_, get_indexes_rand, TYPES1

import numpy as np


class Eindot(Benchmark):
    def setup(self):
        self.a = np.arange(60000.0).reshape(150, 400)
        self.ac = self.a.copy()

            

Reported by Pylint.

Attribute 'a' defined outside __init__
Error

Line: 8 Column: 9

              
class Eindot(Benchmark):
    def setup(self):
        self.a = np.arange(60000.0).reshape(150, 400)
        self.ac = self.a.copy()
        self.at = self.a.T
        self.atc = self.a.T.copy()
        self.b = np.arange(240000.0).reshape(400, 600)
        self.c = np.arange(600)

            

Reported by Pylint.

Attribute 'ac' defined outside __init__
Error

Line: 9 Column: 9

              class Eindot(Benchmark):
    def setup(self):
        self.a = np.arange(60000.0).reshape(150, 400)
        self.ac = self.a.copy()
        self.at = self.a.T
        self.atc = self.a.T.copy()
        self.b = np.arange(240000.0).reshape(400, 600)
        self.c = np.arange(600)
        self.d = np.arange(400)

            

Reported by Pylint.

Attribute 'at' defined outside __init__
Error

Line: 10 Column: 9

                  def setup(self):
        self.a = np.arange(60000.0).reshape(150, 400)
        self.ac = self.a.copy()
        self.at = self.a.T
        self.atc = self.a.T.copy()
        self.b = np.arange(240000.0).reshape(400, 600)
        self.c = np.arange(600)
        self.d = np.arange(400)


            

Reported by Pylint.

Attribute 'atc' defined outside __init__
Error

Line: 11 Column: 9

                      self.a = np.arange(60000.0).reshape(150, 400)
        self.ac = self.a.copy()
        self.at = self.a.T
        self.atc = self.a.T.copy()
        self.b = np.arange(240000.0).reshape(400, 600)
        self.c = np.arange(600)
        self.d = np.arange(400)

        self.a3 = np.arange(480000.).reshape(60, 80, 100)

            

Reported by Pylint.

Attribute 'b' defined outside __init__
Error

Line: 12 Column: 9

                      self.ac = self.a.copy()
        self.at = self.a.T
        self.atc = self.a.T.copy()
        self.b = np.arange(240000.0).reshape(400, 600)
        self.c = np.arange(600)
        self.d = np.arange(400)

        self.a3 = np.arange(480000.).reshape(60, 80, 100)
        self.b3 = np.arange(192000.).reshape(80, 60, 40)

            

Reported by Pylint.

Attribute 'c' defined outside __init__
Error

Line: 13 Column: 9

                      self.at = self.a.T
        self.atc = self.a.T.copy()
        self.b = np.arange(240000.0).reshape(400, 600)
        self.c = np.arange(600)
        self.d = np.arange(400)

        self.a3 = np.arange(480000.).reshape(60, 80, 100)
        self.b3 = np.arange(192000.).reshape(80, 60, 40)


            

Reported by Pylint.

Attribute 'd' defined outside __init__
Error

Line: 14 Column: 9

                      self.atc = self.a.T.copy()
        self.b = np.arange(240000.0).reshape(400, 600)
        self.c = np.arange(600)
        self.d = np.arange(400)

        self.a3 = np.arange(480000.).reshape(60, 80, 100)
        self.b3 = np.arange(192000.).reshape(80, 60, 40)

    def time_dot_a_b(self):

            

Reported by Pylint.

Attribute 'a3' defined outside __init__
Error

Line: 16 Column: 9

                      self.c = np.arange(600)
        self.d = np.arange(400)

        self.a3 = np.arange(480000.).reshape(60, 80, 100)
        self.b3 = np.arange(192000.).reshape(80, 60, 40)

    def time_dot_a_b(self):
        np.dot(self.a, self.b)


            

Reported by Pylint.

Attribute 'b3' defined outside __init__
Error

Line: 17 Column: 9

                      self.d = np.arange(400)

        self.a3 = np.arange(480000.).reshape(60, 80, 100)
        self.b3 = np.arange(192000.).reshape(80, 60, 40)

    def time_dot_a_b(self):
        np.dot(self.a, self.b)

    def time_dot_d_dot_b_c(self):

            

Reported by Pylint.

tools/swig/test/testArray.py
107 issues
Unable to import 'Array'
Error

Line: 14 Column: 1

              else:
    BadListError = ValueError

import Array

######################################################################

class Array1TestCase(unittest.TestCase):


            

Reported by Pylint.

Redefining name 'result' from outer scope (line 380)
Error

Line: 234 Column: 9

              
    def testAsString(self):
        "Test Array2 asString method"
        result = """\
[ [ 0, 1, 2, 3 ],
  [ 1, 2, 3, 4 ],
  [ 2, 3, 4, 5 ],
  [ 3, 4, 5, 6 ],
  [ 4, 5, 6, 7 ] ]

            

Reported by Pylint.

Redefining name 'result' from outer scope (line 380)
Error

Line: 248 Column: 9

              
    def testStr(self):
        "Test Array2 __str__ method"
        result = """\
[ [ 0, -1, -2, -3 ],
  [ 1, 0, -1, -2 ],
  [ 2, 1, 0, -1 ],
  [ 3, 2, 1, 0 ],
  [ 4, 3, 2, 1 ] ]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
# System imports
import sys
import unittest

# Import NumPy
import numpy as np
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
if major == 0:

            

Reported by Pylint.

Module name "testArray" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
# System imports
import sys
import unittest

# Import NumPy
import numpy as np
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
if major == 0:

            

Reported by Pylint.

Import "import Array" should be placed at the top of the module
Error

Line: 14 Column: 1

              else:
    BadListError = ValueError

import Array

######################################################################

class Array1TestCase(unittest.TestCase):


            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

              
######################################################################

class Array1TestCase(unittest.TestCase):

    def setUp(self):
        self.length = 5
        self.array1 = Array.Array1(self.length)


            

Reported by Pylint.

Method name "testConstructor0" doesn't conform to snake_case naming style
Error

Line: 24 Column: 5

                      self.length = 5
        self.array1 = Array.Array1(self.length)

    def testConstructor0(self):
        "Test Array1 default constructor"
        a = Array.Array1()
        self.assertTrue(isinstance(a, Array.Array1))
        self.assertTrue(len(a) == 0)


            

Reported by Pylint.

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

Line: 26 Column: 9

              
    def testConstructor0(self):
        "Test Array1 default constructor"
        a = Array.Array1()
        self.assertTrue(isinstance(a, Array.Array1))
        self.assertTrue(len(a) == 0)

    def testConstructor1(self):
        "Test Array1 length constructor"

            

Reported by Pylint.

Method name "testConstructor1" doesn't conform to snake_case naming style
Error

Line: 30 Column: 5

                      self.assertTrue(isinstance(a, Array.Array1))
        self.assertTrue(len(a) == 0)

    def testConstructor1(self):
        "Test Array1 length constructor"
        self.assertTrue(isinstance(self.array1, Array.Array1))

    def testConstructor2(self):
        "Test Array1 array constructor"

            

Reported by Pylint.

versioneer.py
107 issues
Unable to import 'cx_Freeze.dist'
Error

Line: 1594 Column: 9

                  cmds["build_ext"] = cmd_build_ext

    if "cx_Freeze" in sys.modules:  # cx_freeze enabled?
        from cx_Freeze.dist import build_exe as _build_exe
        # nczeczulin reports that py2exe won't like the pep440-style string
        # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.
        # setup(console=[{
        #   "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION
        #   "product_version": versioneer.get_version(),

            

Reported by Pylint.

Unable to import 'py2exe.distutils_buildexe'
Error

Line: 1626 Column: 9

                      del cmds["build_py"]

    if 'py2exe' in sys.modules:  # py2exe enabled?
        from py2exe.distutils_buildexe import py2exe as _py2exe

        class cmd_py2exe(_py2exe):
            def run(self):
                root = get_root()
                cfg = get_config_from_root(root)

            

Reported by Pylint.

Attribute 'VCS' defined outside __init__
Error

Line: 345 Column: 5

                          return parser.get("versioneer", name)
        return None
    cfg = VersioneerConfig()
    cfg.VCS = VCS
    cfg.style = get(parser, "style") or ""
    cfg.versionfile_source = get(parser, "versionfile_source")
    cfg.versionfile_build = get(parser, "versionfile_build")
    cfg.tag_prefix = get(parser, "tag_prefix")
    if cfg.tag_prefix in ("''", '""'):

            

Reported by Pylint.

Attribute 'style' defined outside __init__
Error

Line: 346 Column: 5

                      return None
    cfg = VersioneerConfig()
    cfg.VCS = VCS
    cfg.style = get(parser, "style") or ""
    cfg.versionfile_source = get(parser, "versionfile_source")
    cfg.versionfile_build = get(parser, "versionfile_build")
    cfg.tag_prefix = get(parser, "tag_prefix")
    if cfg.tag_prefix in ("''", '""'):
        cfg.tag_prefix = ""

            

Reported by Pylint.

Attribute 'versionfile_source' defined outside __init__
Error

Line: 347 Column: 5

                  cfg = VersioneerConfig()
    cfg.VCS = VCS
    cfg.style = get(parser, "style") or ""
    cfg.versionfile_source = get(parser, "versionfile_source")
    cfg.versionfile_build = get(parser, "versionfile_build")
    cfg.tag_prefix = get(parser, "tag_prefix")
    if cfg.tag_prefix in ("''", '""'):
        cfg.tag_prefix = ""
    cfg.parentdir_prefix = get(parser, "parentdir_prefix")

            

Reported by Pylint.

Attribute 'versionfile_build' defined outside __init__
Error

Line: 348 Column: 5

                  cfg.VCS = VCS
    cfg.style = get(parser, "style") or ""
    cfg.versionfile_source = get(parser, "versionfile_source")
    cfg.versionfile_build = get(parser, "versionfile_build")
    cfg.tag_prefix = get(parser, "tag_prefix")
    if cfg.tag_prefix in ("''", '""'):
        cfg.tag_prefix = ""
    cfg.parentdir_prefix = get(parser, "parentdir_prefix")
    cfg.verbose = get(parser, "verbose")

            

Reported by Pylint.

Attribute 'tag_prefix' defined outside __init__
Error

Line: 349 Column: 5

                  cfg.style = get(parser, "style") or ""
    cfg.versionfile_source = get(parser, "versionfile_source")
    cfg.versionfile_build = get(parser, "versionfile_build")
    cfg.tag_prefix = get(parser, "tag_prefix")
    if cfg.tag_prefix in ("''", '""'):
        cfg.tag_prefix = ""
    cfg.parentdir_prefix = get(parser, "parentdir_prefix")
    cfg.verbose = get(parser, "verbose")
    return cfg

            

Reported by Pylint.

Attribute 'tag_prefix' defined outside __init__
Error

Line: 351 Column: 9

                  cfg.versionfile_build = get(parser, "versionfile_build")
    cfg.tag_prefix = get(parser, "tag_prefix")
    if cfg.tag_prefix in ("''", '""'):
        cfg.tag_prefix = ""
    cfg.parentdir_prefix = get(parser, "parentdir_prefix")
    cfg.verbose = get(parser, "verbose")
    return cfg



            

Reported by Pylint.

Attribute 'parentdir_prefix' defined outside __init__
Error

Line: 352 Column: 5

                  cfg.tag_prefix = get(parser, "tag_prefix")
    if cfg.tag_prefix in ("''", '""'):
        cfg.tag_prefix = ""
    cfg.parentdir_prefix = get(parser, "parentdir_prefix")
    cfg.verbose = get(parser, "verbose")
    return cfg


class NotThisMethod(Exception):

            

Reported by Pylint.

Attribute 'verbose' defined outside __init__
Error

Line: 353 Column: 5

                  if cfg.tag_prefix in ("''", '""'):
        cfg.tag_prefix = ""
    cfg.parentdir_prefix = get(parser, "parentdir_prefix")
    cfg.verbose = get(parser, "verbose")
    return cfg


class NotThisMethod(Exception):
    """Exception raised if a method is not valid for the current scenario."""

            

Reported by Pylint.

numpy/polynomial/tests/test_printing.py
107 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest
from numpy.core import array, arange, printoptions
import numpy.polynomial as poly
from numpy.testing import assert_equal, assert_

# For testing polynomial printing with object arrays
from fractions import Fraction
from decimal import Decimal


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 226 Column: 17

                      with printoptions(linewidth=lw):
            assert_equal(str(p), tgt)
            for line in str(p).split('\n'):
                assert_(len(line) < lw)


def test_set_default_printoptions():
    p = poly.Polynomial([1, 2, 3])
    c = poly.Chebyshev([1, 2, 3])

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 351 Column: 34

                      # right now we ignore the formatting of scalars in our tests, since
        # it makes them too verbose. Ideally, the formatting of scalars will
        # be fixed such that tests below continue to pass
        obj._repr_latex_scalar = lambda x: str(x)
        try:
            return obj._repr_latex_()
        finally:
            del obj._repr_latex_scalar


            

Reported by Pylint.

Access to a protected member _repr_latex_scalar of a client class
Error

Line: 351 Column: 9

                      # right now we ignore the formatting of scalars in our tests, since
        # it makes them too verbose. Ideally, the formatting of scalars will
        # be fixed such that tests below continue to pass
        obj._repr_latex_scalar = lambda x: str(x)
        try:
            return obj._repr_latex_()
        finally:
            del obj._repr_latex_scalar


            

Reported by Pylint.

Access to a protected member _repr_latex_ of a client class
Error

Line: 353 Column: 20

                      # be fixed such that tests below continue to pass
        obj._repr_latex_scalar = lambda x: str(x)
        try:
            return obj._repr_latex_()
        finally:
            del obj._repr_latex_scalar

    def test_simple_polynomial(self):
        # default input

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest
from numpy.core import array, arange, printoptions
import numpy.polynomial as poly
from numpy.testing import assert_equal, assert_

# For testing polynomial printing with object arrays
from fractions import Fraction
from decimal import Decimal


            

Reported by Pylint.

standard import "from fractions import Fraction" should be placed before "import pytest"
Error

Line: 7 Column: 1

              from numpy.testing import assert_equal, assert_

# For testing polynomial printing with object arrays
from fractions import Fraction
from decimal import Decimal


class TestStrUnicodeSuperSubscripts:


            

Reported by Pylint.

standard import "from decimal import Decimal" should be placed before "import pytest"
Error

Line: 8 Column: 1

              
# For testing polynomial printing with object arrays
from fractions import Fraction
from decimal import Decimal


class TestStrUnicodeSuperSubscripts:

    @pytest.fixture(scope='class', autouse=True)

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from decimal import Decimal


class TestStrUnicodeSuperSubscripts:

    @pytest.fixture(scope='class', autouse=True)
    def use_unicode(self):
        poly.set_default_printstyle('unicode')


            

Reported by Pylint.

Method could be a function
Error

Line: 14 Column: 5

              class TestStrUnicodeSuperSubscripts:

    @pytest.fixture(scope='class', autouse=True)
    def use_unicode(self):
        poly.set_default_printstyle('unicode')

    @pytest.mark.parametrize(('inp', 'tgt'), (
        ([1, 2, 3], "1.0 + 2.0·x¹ + 3.0·x²"),
        ([-1, 0, 3, -1], "-1.0 + 0.0·x¹ + 3.0·x² - 1.0·x³"),

            

Reported by Pylint.

numpy/lib/polynomial.py
105 issues
Module 'numpy.core.numeric' has no 'sqrt' member; maybe 'sort'?
Error

Line: 661 Column: 13

                          rhs *= w

    # scale lhs to improve condition number and solve
    scale = NX.sqrt((lhs*lhs).sum(axis=0))
    lhs /= scale
    c, resids, rank, s = lstsq(lhs, rhs, rcond)
    c = (c.T/scale).T  # broadcast scale coefficients

    # warn on rank reduction, which indicates an ill conditioned matrix

            

Reported by Pylint.

bad operand type for unary -: tuple
Error

Line: 1323 Column: 23

                      return polyval(self.coeffs, val)

    def __neg__(self):
        return poly1d(-self.coeffs)

    def __pos__(self):
        return self

    def __mul__(self, other):

            

Reported by Pylint.

bad operand type for unary -: list
Error

Line: 1323 Column: 23

                      return polyval(self.coeffs, val)

    def __neg__(self):
        return poly1d(-self.coeffs)

    def __pos__(self):
        return self

    def __mul__(self, other):

            

Reported by Pylint.

Redefining built-in 'abs'
Error

Line: 14 Column: 1

              import warnings
import numpy.core.numeric as NX

from numpy.core import (isscalar, abs, finfo, atleast_1d, hstack, dot, array,
                        ones)
from numpy.core import overrides
from numpy.core.overrides import set_module
from numpy.lib.twodim_base import diag, vander
from numpy.lib.function_base import trim_zeros

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 37 Column: 5

                  `RankWarning` being issued, see `polyfit`.

    """
    pass


def _poly_dispatcher(seq_of_zeros):
    return seq_of_zeros


            

Reported by Pylint.

Redefining name 'roots' from outer scope (line 173)
Error

Line: 161 Column: 9

              
    if issubclass(a.dtype.type, NX.complexfloating):
        # if complex roots are all complex conjugates, the roots are real.
        roots = NX.asarray(seq_of_zeros, complex)
        if NX.all(NX.sort(roots) == NX.sort(roots.conjugate())):
            a = a.real.copy()

    return a


            

Reported by Pylint.

Redefining name 'roots' from outer scope (line 173)
Error

Line: 255 Column: 9

                      # build companion matrix and find its eigenvalues (the roots)
        A = diag(NX.ones((N-2,), p.dtype), -1)
        A[0,:] = -p[1:] / p[0]
        roots = eigvals(A)
    else:
        roots = NX.array([])

    # tack any zeros onto the back of the array
    roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))

            

Reported by Pylint.

Unused argument 'k'
Error

Line: 264 Column: 36

                  return roots


def _polyint_dispatcher(p, m=None, k=None):
    return (p,)


@array_function_dispatch(_polyint_dispatcher)
def polyint(p, m=1, k=None):

            

Reported by Pylint.

Unused argument 'm'
Error

Line: 264 Column: 28

                  return roots


def _polyint_dispatcher(p, m=None, k=None):
    return (p,)


@array_function_dispatch(_polyint_dispatcher)
def polyint(p, m=1, k=None):

            

Reported by Pylint.

Unused argument 'm'
Error

Line: 369 Column: 28

                      return val


def _polyder_dispatcher(p, m=None):
    return (p,)


@array_function_dispatch(_polyder_dispatcher)
def polyder(p, m=1):

            

Reported by Pylint.

numpy/core/tests/test_half.py
105 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import platform
import pytest

import numpy as np
from numpy import uint16, float16, float32, float64
from numpy.testing import assert_, assert_equal


def assert_raises_fpe(strmatch, callable, *args, **kwargs):

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 90 Column: 23

                  @pytest.mark.parametrize("float_t", [np.float32, np.float64])
    def test_half_conversion_rounding(self, float_t, shift, offset):
        # Assumes that round to even is used during casting.
        max_pattern = np.float16(np.finfo(np.float16).max).view(np.uint16)

        # Test all (positive) finite numbers, denormals are most interesting
        # however:
        f16s_patterns = np.arange(0, max_pattern+1, dtype=np.uint16)
        f16s_float = f16s_patterns.view(np.float16).astype(float_t)

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 149 Column: 26

                      # whether round to even should occur (i.e. no bits are lost at the
        # end. Compare also gh-12721. The most bits can get lost for the
        # smallest denormal:
        smallest_value = np.uint16(1).view(np.float16).astype(float_t)
        assert smallest_value == 2**-24

        # Will be rounded to zero based on round to even rule:
        rounded_to_zero = smallest_value / float_t(2)
        assert rounded_to_zero.astype(np.float16) == 0

            

Reported by Pylint.

Instance of 'ndarray' has no '__array_interface__' member
Error

Line: 551 Column: 33

              
        a = np.ones((1,), dtype=float16)
        b = Dummy()
        b.__array_interface__ = a.__array_interface__
        c = np.array(b)
        assert_(c.dtype == float16)
        assert_equal(a, c)

            

Reported by Pylint.

Redefining built-in 'callable'
Error

Line: 9 Column: 33

              from numpy.testing import assert_, assert_equal


def assert_raises_fpe(strmatch, callable, *args, **kwargs):
    try:
        callable(*args, **kwargs)
    except FloatingPointError as exc:
        assert_(str(exc).find(strmatch) >= 0,
                "Did not raise floating point %s error" % strmatch)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 13 Column: 9

                  try:
        callable(*args, **kwargs)
    except FloatingPointError as exc:
        assert_(str(exc).find(strmatch) >= 0,
                "Did not raise floating point %s error" % strmatch)
    else:
        assert_(False,
                "Did not raise floating point %s error" % strmatch)


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 16 Column: 9

                      assert_(str(exc).find(strmatch) >= 0,
                "Did not raise floating point %s error" % strmatch)
    else:
        assert_(False,
                "Did not raise floating point %s error" % strmatch)

class TestHalf:
    def setup(self):
        # An array of all possible float16 values

            

Reported by Pylint.

Attribute 'all_f16' defined outside __init__
Error

Line: 22 Column: 9

              class TestHalf:
    def setup(self):
        # An array of all possible float16 values
        self.all_f16 = np.arange(0x10000, dtype=uint16)
        self.all_f16.dtype = float16
        self.all_f32 = np.array(self.all_f16, dtype=float32)
        self.all_f64 = np.array(self.all_f16, dtype=float64)

        # An array of all non-NaN float16 values, in sorted order

            

Reported by Pylint.

Attribute 'all_f32' defined outside __init__
Error

Line: 24 Column: 9

                      # An array of all possible float16 values
        self.all_f16 = np.arange(0x10000, dtype=uint16)
        self.all_f16.dtype = float16
        self.all_f32 = np.array(self.all_f16, dtype=float32)
        self.all_f64 = np.array(self.all_f16, dtype=float64)

        # An array of all non-NaN float16 values, in sorted order
        self.nonan_f16 = np.concatenate(
                                (np.arange(0xfc00, 0x7fff, -1, dtype=uint16),

            

Reported by Pylint.

Attribute 'all_f64' defined outside __init__
Error

Line: 25 Column: 9

                      self.all_f16 = np.arange(0x10000, dtype=uint16)
        self.all_f16.dtype = float16
        self.all_f32 = np.array(self.all_f16, dtype=float32)
        self.all_f64 = np.array(self.all_f16, dtype=float64)

        # An array of all non-NaN float16 values, in sorted order
        self.nonan_f16 = np.concatenate(
                                (np.arange(0xfc00, 0x7fff, -1, dtype=uint16),
                                 np.arange(0x0000, 0x7c01, 1, dtype=uint16)))

            

Reported by Pylint.

numpy/typing/tests/data/pass/bitwise_ops.py
103 issues
bad operand type for unary ~: int64
Error

Line: 126 Column: 1

              b_ ^ i
b_ & i

~i8
~i4
~u8
~u4
~b_
~AR

            

Reported by Pylint.

bad operand type for unary ~: int32
Error

Line: 127 Column: 1

              b_ & i

~i8
~i4
~u8
~u4
~b_
~AR

            

Reported by Pylint.

bad operand type for unary ~: uint64
Error

Line: 128 Column: 1

              
~i8
~i4
~u8
~u4
~b_
~AR

            

Reported by Pylint.

bad operand type for unary ~: uint32
Error

Line: 129 Column: 1

              ~i8
~i4
~u8
~u4
~b_
~AR

            

Reported by Pylint.

bad operand type for unary ~: bool_
Error

Line: 130 Column: 1

              ~i4
~u8
~u4
~b_
~AR

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 18 Column: 1

              AR.setflags(write=False)


i8 << i8
i8 >> i8
i8 | i8
i8 ^ i8
i8 & i8


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 19 Column: 1

              

i8 << i8
i8 >> i8
i8 | i8
i8 ^ i8
i8 & i8

i8 << AR

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 20 Column: 1

              
i8 << i8
i8 >> i8
i8 | i8
i8 ^ i8
i8 & i8

i8 << AR
i8 >> AR

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 21 Column: 1

              i8 << i8
i8 >> i8
i8 | i8
i8 ^ i8
i8 & i8

i8 << AR
i8 >> AR
i8 | AR

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 22 Column: 1

              i8 >> i8
i8 | i8
i8 ^ i8
i8 & i8

i8 << AR
i8 >> AR
i8 | AR
i8 ^ AR

            

Reported by Pylint.

numpy/typing/tests/data/reveal/bitwise_ops.py
103 issues
Undefined variable 'reveal_type'
Error

Line: 18 Column: 1

              AR.setflags(write=False)


reveal_type(i8 << i8)  # E: {int64}
reveal_type(i8 >> i8)  # E: {int64}
reveal_type(i8 | i8)  # E: {int64}
reveal_type(i8 ^ i8)  # E: {int64}
reveal_type(i8 & i8)  # E: {int64}


            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 19 Column: 1

              

reveal_type(i8 << i8)  # E: {int64}
reveal_type(i8 >> i8)  # E: {int64}
reveal_type(i8 | i8)  # E: {int64}
reveal_type(i8 ^ i8)  # E: {int64}
reveal_type(i8 & i8)  # E: {int64}

reveal_type(i8 << AR)  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 20 Column: 1

              
reveal_type(i8 << i8)  # E: {int64}
reveal_type(i8 >> i8)  # E: {int64}
reveal_type(i8 | i8)  # E: {int64}
reveal_type(i8 ^ i8)  # E: {int64}
reveal_type(i8 & i8)  # E: {int64}

reveal_type(i8 << AR)  # E: Any
reveal_type(i8 >> AR)  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 21 Column: 1

              reveal_type(i8 << i8)  # E: {int64}
reveal_type(i8 >> i8)  # E: {int64}
reveal_type(i8 | i8)  # E: {int64}
reveal_type(i8 ^ i8)  # E: {int64}
reveal_type(i8 & i8)  # E: {int64}

reveal_type(i8 << AR)  # E: Any
reveal_type(i8 >> AR)  # E: Any
reveal_type(i8 | AR)  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 22 Column: 1

              reveal_type(i8 >> i8)  # E: {int64}
reveal_type(i8 | i8)  # E: {int64}
reveal_type(i8 ^ i8)  # E: {int64}
reveal_type(i8 & i8)  # E: {int64}

reveal_type(i8 << AR)  # E: Any
reveal_type(i8 >> AR)  # E: Any
reveal_type(i8 | AR)  # E: Any
reveal_type(i8 ^ AR)  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 24 Column: 1

              reveal_type(i8 ^ i8)  # E: {int64}
reveal_type(i8 & i8)  # E: {int64}

reveal_type(i8 << AR)  # E: Any
reveal_type(i8 >> AR)  # E: Any
reveal_type(i8 | AR)  # E: Any
reveal_type(i8 ^ AR)  # E: Any
reveal_type(i8 & AR)  # E: Any


            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 25 Column: 1

              reveal_type(i8 & i8)  # E: {int64}

reveal_type(i8 << AR)  # E: Any
reveal_type(i8 >> AR)  # E: Any
reveal_type(i8 | AR)  # E: Any
reveal_type(i8 ^ AR)  # E: Any
reveal_type(i8 & AR)  # E: Any

reveal_type(i4 << i4)  # E: {int32}

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 26 Column: 1

              
reveal_type(i8 << AR)  # E: Any
reveal_type(i8 >> AR)  # E: Any
reveal_type(i8 | AR)  # E: Any
reveal_type(i8 ^ AR)  # E: Any
reveal_type(i8 & AR)  # E: Any

reveal_type(i4 << i4)  # E: {int32}
reveal_type(i4 >> i4)  # E: {int32}

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 27 Column: 1

              reveal_type(i8 << AR)  # E: Any
reveal_type(i8 >> AR)  # E: Any
reveal_type(i8 | AR)  # E: Any
reveal_type(i8 ^ AR)  # E: Any
reveal_type(i8 & AR)  # E: Any

reveal_type(i4 << i4)  # E: {int32}
reveal_type(i4 >> i4)  # E: {int32}
reveal_type(i4 | i4)  # E: {int32}

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 28 Column: 1

              reveal_type(i8 >> AR)  # E: Any
reveal_type(i8 | AR)  # E: Any
reveal_type(i8 ^ AR)  # E: Any
reveal_type(i8 & AR)  # E: Any

reveal_type(i4 << i4)  # E: {int32}
reveal_type(i4 >> i4)  # E: {int32}
reveal_type(i4 | i4)  # E: {int32}
reveal_type(i4 ^ i4)  # E: {int32}

            

Reported by Pylint.

numpy/matrixlib/tests/test_masked_matrix.py
102 issues
Module 'numpy.random' has no 'rand' member
Error

Line: 163 Column: 44

              
    def test_view(self):
        # Test view w/ flexible dtype
        iterator = list(zip(np.arange(10), np.random.rand(10)))
        data = np.array(iterator)
        a = masked_array(iterator, dtype=[('a', float), ('b', float)])
        a.mask[0] = (1, 0)
        test = a.view((float, 2), np.matrix)
        assert_equal(test, data)

            

Reported by Pylint.

Method 'tofile' is abstract in class 'MaskedArray' but is not overridden
Error

Line: 12 Column: 1

              from numpy.compat import pickle


class MMatrix(MaskedArray, np.matrix,):

    def __new__(cls, data, mask=nomask):
        mat = np.matrix(data)
        _data = MaskedArray.__new__(cls, data=mat, mask=mask)
        return _data

            

Reported by Pylint.

Signature differs from overridden '__new__' method
Error

Line: 14 Column: 5

              
class MMatrix(MaskedArray, np.matrix,):

    def __new__(cls, data, mask=nomask):
        mat = np.matrix(data)
        _data = MaskedArray.__new__(cls, data=mat, mask=mask)
        return _data

    def __array_finalize__(self, obj):

            

Reported by Pylint.

Access to a protected member _sharedmask of a client class
Error

Line: 27 Column: 9

                  @property
    def _series(self):
        _view = self.view(MaskedArray)
        _view._sharedmask = False
        return _view


class TestMaskedMatrix:
    def test_matrix_indexing(self):

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 42 Column: 9

                      str(x2)  # raises?
        repr(x2)  # raises?
        # tests of indexing
        assert_(type(x2[1, 0]) is type(x1[1, 0]))
        assert_(x1[1, 0] == x2[1, 0])
        assert_(x2[1, 1] is masked)
        assert_equal(x1[0, 2], x2[0, 2])
        assert_equal(x1[0, 1:], x2[0, 1:])
        assert_equal(x1[:, 2], x2[:, 2])

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 43 Column: 9

                      repr(x2)  # raises?
        # tests of indexing
        assert_(type(x2[1, 0]) is type(x1[1, 0]))
        assert_(x1[1, 0] == x2[1, 0])
        assert_(x2[1, 1] is masked)
        assert_equal(x1[0, 2], x2[0, 2])
        assert_equal(x1[0, 1:], x2[0, 1:])
        assert_equal(x1[:, 2], x2[:, 2])
        assert_equal(x1[:], x2[:])

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 44 Column: 9

                      # tests of indexing
        assert_(type(x2[1, 0]) is type(x1[1, 0]))
        assert_(x1[1, 0] == x2[1, 0])
        assert_(x2[1, 1] is masked)
        assert_equal(x1[0, 2], x2[0, 2])
        assert_equal(x1[0, 1:], x2[0, 1:])
        assert_equal(x1[:, 2], x2[:, 2])
        assert_equal(x1[:], x2[:])
        assert_equal(x1[1:], x3[1:])

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 62 Column: 9

                      assert_equal(x1, x2)
        x2[0, :] = x1[0, :]
        x2[0, 1] = masked
        assert_(allequal(getmask(x2), np.array([[0, 1, 0], [0, 1, 0]])))
        x3[1, :] = masked_array([1, 2, 3], [1, 1, 0])
        assert_(allequal(getmask(x3)[1], masked_array([1, 1, 0])))
        assert_(allequal(getmask(x3[1]), masked_array([1, 1, 0])))
        x4[1, :] = masked_array([1, 2, 3], [1, 1, 0])
        assert_(allequal(getmask(x4[1]), masked_array([1, 1, 0])))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 64 Column: 9

                      x2[0, 1] = masked
        assert_(allequal(getmask(x2), np.array([[0, 1, 0], [0, 1, 0]])))
        x3[1, :] = masked_array([1, 2, 3], [1, 1, 0])
        assert_(allequal(getmask(x3)[1], masked_array([1, 1, 0])))
        assert_(allequal(getmask(x3[1]), masked_array([1, 1, 0])))
        x4[1, :] = masked_array([1, 2, 3], [1, 1, 0])
        assert_(allequal(getmask(x4[1]), masked_array([1, 1, 0])))
        assert_(allequal(x4[1], masked_array([1, 2, 3])))
        x1 = np.matrix(np.arange(5) * 1.0)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 65 Column: 9

                      assert_(allequal(getmask(x2), np.array([[0, 1, 0], [0, 1, 0]])))
        x3[1, :] = masked_array([1, 2, 3], [1, 1, 0])
        assert_(allequal(getmask(x3)[1], masked_array([1, 1, 0])))
        assert_(allequal(getmask(x3[1]), masked_array([1, 1, 0])))
        x4[1, :] = masked_array([1, 2, 3], [1, 1, 0])
        assert_(allequal(getmask(x4[1]), masked_array([1, 1, 0])))
        assert_(allequal(x4[1], masked_array([1, 2, 3])))
        x1 = np.matrix(np.arange(5) * 1.0)
        x2 = masked_values(x1, 3.0)

            

Reported by Pylint.