The following issues were found

numpy/testing/tests/test_utils.py
438 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import sys
import os
import itertools
import pytest
import weakref

import numpy as np
from numpy.testing import (
    assert_equal, assert_array_equal, assert_almost_equal,

            

Reported by Pylint.

Instance of '_GenericTest' has no '_assert_func' member
Error

Line: 23 Column: 9

              class _GenericTest:

    def _test_equal(self, a, b):
        self._assert_func(a, b)

    def _test_not_equal(self, a, b):
        with assert_raises(AssertionError):
            self._assert_func(a, b)


            

Reported by Pylint.

Instance of '_GenericTest' has no '_assert_func' member
Error

Line: 27 Column: 13

              
    def _test_not_equal(self, a, b):
        with assert_raises(AssertionError):
            self._assert_func(a, b)

    def test_array_rank1_eq(self):
        """Test two equal array of rank 1 are found equal."""
        a = np.array([1, 2])
        b = np.array([1, 2])

            

Reported by Pylint.

Module 'numpy.random' has no 'randn' member
Error

Line: 1146 Column: 13

              class TestULP:

    def test_equal(self):
        x = np.random.randn(10)
        assert_array_max_ulp(x, x, maxulp=0)

    def test_single(self):
        # Generate 1 + small deviation, check that adding eps gives a few UNL
        x = np.ones(10).astype(np.float32)

            

Reported by Pylint.

Module 'numpy.random' has no 'randn' member
Error

Line: 1152 Column: 21

                  def test_single(self):
        # Generate 1 + small deviation, check that adding eps gives a few UNL
        x = np.ones(10).astype(np.float32)
        x += 0.01 * np.random.randn(10).astype(np.float32)
        eps = np.finfo(np.float32).eps
        assert_array_max_ulp(x, x+eps, maxulp=20)

    def test_double(self):
        # Generate 1 + small deviation, check that adding eps gives a few UNL

            

Reported by Pylint.

Module 'numpy.random' has no 'randn' member
Error

Line: 1159 Column: 21

                  def test_double(self):
        # Generate 1 + small deviation, check that adding eps gives a few UNL
        x = np.ones(10).astype(np.float64)
        x += 0.01 * np.random.randn(10).astype(np.float64)
        eps = np.finfo(np.float64).eps
        assert_array_max_ulp(x, x+eps, maxulp=200)

    def test_inf(self):
        for dt in [np.float32, np.float64]:

            

Reported by Pylint.

class already defined line 1261
Error

Line: 1271 Column: 5

              
    # serial test scenario -- the __warningregistry__
    # attribute should be present
    class mod:
        def __init__(self):
            self.__warningregistry__ = {'warning1':1,
                                        'warning2':2}

    mod_inst = mod()

            

Reported by Pylint.

Attribute '_assert_func' defined outside __init__
Error

Line: 69 Column: 9

              class TestArrayEqual(_GenericTest):

    def setup(self):
        self._assert_func = assert_array_equal

    def test_generic_rank1(self):
        """Test rank 1 array for all dtypes."""
        def foo(t):
            a = np.empty(2, t)

            

Reported by Pylint.

Positional arguments appear to be out of order
Error

Line: 168 Column: 9

                      a = np.ma.MaskedArray([3., 4., 6.5], mask=[False, True, False])
        b = np.array([3., np.nan, 6.5])
        self._test_equal(a, b)
        self._test_equal(b, a)
        a = np.ma.MaskedArray([3., 4., 6.5], mask=[True, False, False])
        b = np.array([np.inf, 4., 6.5])
        self._test_equal(a, b)
        self._test_equal(b, a)


            

Reported by Pylint.

Positional arguments appear to be out of order
Error

Line: 172 Column: 9

                      a = np.ma.MaskedArray([3., 4., 6.5], mask=[True, False, False])
        b = np.array([np.inf, 4., 6.5])
        self._test_equal(a, b)
        self._test_equal(b, a)

    def test_subclass_that_overrides_eq(self):
        # While we cannot guarantee testing functions will always work for
        # subclasses, the tests should ideally rely only on subclasses having
        # comparison operators, not on them being able to store booleans

            

Reported by Pylint.

numpy/typing/tests/data/reveal/arithmetic.py
437 issues
Value 'np.floating' is unsubscriptable
Error

Line: 6 Column: 6

              import numpy.typing as npt

# Can't directly import `np.float128` as it is not available on all platforms
f16: np.floating[npt._128Bit]

c16 = np.complex128()
f8 = np.float64()
i8 = np.int64()
u8 = np.uint64()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 8 Column: 7

              # Can't directly import `np.float128` as it is not available on all platforms
f16: np.floating[npt._128Bit]

c16 = np.complex128()
f8 = np.float64()
i8 = np.int64()
u8 = np.uint64()

c8 = np.complex64()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 9 Column: 6

              f16: np.floating[npt._128Bit]

c16 = np.complex128()
f8 = np.float64()
i8 = np.int64()
u8 = np.uint64()

c8 = np.complex64()
f4 = np.float32()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 11 Column: 6

              c16 = np.complex128()
f8 = np.float64()
i8 = np.int64()
u8 = np.uint64()

c8 = np.complex64()
f4 = np.float32()
i4 = np.int32()
u4 = np.uint32()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 13 Column: 6

              i8 = np.int64()
u8 = np.uint64()

c8 = np.complex64()
f4 = np.float32()
i4 = np.int32()
u4 = np.uint32()

dt = np.datetime64(0, "D")

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 14 Column: 6

              u8 = np.uint64()

c8 = np.complex64()
f4 = np.float32()
i4 = np.int32()
u4 = np.uint32()

dt = np.datetime64(0, "D")
td = np.timedelta64(0, "D")

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 16 Column: 6

              c8 = np.complex64()
f4 = np.float32()
i4 = np.int32()
u4 = np.uint32()

dt = np.datetime64(0, "D")
td = np.timedelta64(0, "D")

b_ = np.bool_()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 21 Column: 6

              dt = np.datetime64(0, "D")
td = np.timedelta64(0, "D")

b_ = np.bool_()

b = bool()
c = complex()
f = float()
i = int()

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 28 Column: 7

              f = float()
i = int()

AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 29 Column: 7

              i = int()

AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]

            

Reported by Pylint.

numpy/core/tests/test_datetime.py
404 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import numpy
import numpy as np
import datetime
import pytest
from numpy.testing import (
    assert_, assert_equal, assert_raises, assert_warns, suppress_warnings,
    assert_raises_regex, assert_array_equal,
    )
from numpy.compat import pickle

            

Reported by Pylint.

No value for argument 'nb' in constructor call
Error

Line: 199 Column: 22

                                   np.datetime64('1950-03-12T13', 'm'))

        # Default construction means NaT
        assert_equal(np.datetime64(), np.datetime64('NaT'))

        # Some basic strings and repr
        assert_equal(str(np.datetime64('NaT')), 'NaT')
        assert_equal(repr(np.datetime64('NaT')),
                     "numpy.datetime64('NaT')")

            

Reported by Pylint.

No value for argument 'nb' in constructor call
Error

Line: 213 Column: 22

                      assert_equal(np.datetime64(None), np.datetime64('NaT'))

        # Default construction of NaT is in generic units
        assert_equal(np.datetime64().dtype, np.dtype('M8'))
        assert_equal(np.datetime64('NaT').dtype, np.dtype('M8'))

        # Construction from integers requires a specified unit
        assert_raises(ValueError, np.datetime64, 17)


            

Reported by Pylint.

No value for argument 'nb' in constructor call
Error

Line: 336 Column: 22

                                   np.timedelta64(2, 'm'))

        # Default construction means 0
        assert_equal(np.timedelta64(), np.timedelta64(0))

        # None gets constructed as NaT
        assert_equal(np.timedelta64(None), np.timedelta64('NaT'))

        # Some basic strings and repr

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 2314 Column: 22

                  def test_datetime_y2038(self):
        # Test parsing on either side of the Y2038 boundary
        a = np.datetime64('2038-01-19T03:14:07')
        assert_equal(a.view(np.int64), 2**31 - 1)
        a = np.datetime64('2038-01-19T03:14:08')
        assert_equal(a.view(np.int64), 2**31)

        # Test parsing on either side of the Y2038 boundary with
        # a manually specified timezone offset

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 2316 Column: 22

                      a = np.datetime64('2038-01-19T03:14:07')
        assert_equal(a.view(np.int64), 2**31 - 1)
        a = np.datetime64('2038-01-19T03:14:08')
        assert_equal(a.view(np.int64), 2**31)

        # Test parsing on either side of the Y2038 boundary with
        # a manually specified timezone offset
        with assert_warns(DeprecationWarning):
            a = np.datetime64('2038-01-19T04:14:07+0100')

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 2322 Column: 26

                      # a manually specified timezone offset
        with assert_warns(DeprecationWarning):
            a = np.datetime64('2038-01-19T04:14:07+0100')
            assert_equal(a.view(np.int64), 2**31 - 1)
        with assert_warns(DeprecationWarning):
            a = np.datetime64('2038-01-19T04:14:08+0100')
            assert_equal(a.view(np.int64), 2**31)

        # Test parsing a date after Y2038

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 2325 Column: 26

                          assert_equal(a.view(np.int64), 2**31 - 1)
        with assert_warns(DeprecationWarning):
            a = np.datetime64('2038-01-19T04:14:08+0100')
            assert_equal(a.view(np.int64), 2**31)

        # Test parsing a date after Y2038
        a = np.datetime64('2038-01-20T13:21:14')
        assert_equal(str(a), '2038-01-20T13:21:14')


            

Reported by Pylint.

Reimport 'numpy' (imported line 2)
Error

Line: 3 Column: 1

              
import numpy
import numpy as np
import datetime
import pytest
from numpy.testing import (
    assert_, assert_equal, assert_raises, assert_warns, suppress_warnings,
    assert_raises_regex, assert_array_equal,
    )

            

Reported by Pylint.

Redefining built-in 'RecursionError'
Error

Line: 22 Column: 5

              try:
    RecursionError
except NameError:
    RecursionError = RuntimeError  # python < 3.5


class TestDateTime:
    def test_datetime_dtype_creation(self):
        for unit in ['Y', 'M', 'W', 'D',

            

Reported by Pylint.

numpy/distutils/system_info.py
398 issues
Instance of 'system_info' has no 'calc_info' member
Error

Line: 841 Column: 17

                          flag = 1
            log.info(self.__class__.__name__ + ':')
            if hasattr(self, 'calc_info'):
                self.calc_info()
            if notfound_action:
                if not self.has_info():
                    if notfound_action == 1:
                        warnings.warn(self.notfounderror.__doc__, stacklevel=2)
                    elif notfound_action == 2:

            

Reported by Pylint.

Value 'env_var' is unsubscriptable
Error

Line: 873 Column: 22

                      env_var = self.dir_env_var
        if env_var:
            if is_sequence(env_var):
                e0 = env_var[-1]
                for e in env_var:
                    if e in os.environ:
                        e0 = e
                        break
                if not env_var[0] == e0:

            

Reported by Pylint.

Non-iterable value env_var is used in an iterating context
Error

Line: 874 Column: 26

                      if env_var:
            if is_sequence(env_var):
                e0 = env_var[-1]
                for e in env_var:
                    if e in os.environ:
                        e0 = e
                        break
                if not env_var[0] == e0:
                    log.info('Setting %s=%s' % (env_var[0], e0))

            

Reported by Pylint.

Value 'env_var' is unsubscriptable
Error

Line: 878 Column: 24

                                  if e in os.environ:
                        e0 = e
                        break
                if not env_var[0] == e0:
                    log.info('Setting %s=%s' % (env_var[0], e0))
                env_var = e0
        if env_var and env_var in os.environ:
            d = os.environ[env_var]
            if d == 'None':

            

Reported by Pylint.

Value 'env_var' is unsubscriptable
Error

Line: 879 Column: 49

                                      e0 = e
                        break
                if not env_var[0] == e0:
                    log.info('Setting %s=%s' % (env_var[0], e0))
                env_var = e0
        if env_var and env_var in os.environ:
            d = os.environ[env_var]
            if d == 'None':
                log.info('Disabled %s: %s',

            

Reported by Pylint.

Instance of 'system_info' has no '_lib_names' member
Error

Line: 896 Column: 34

                                  b = os.path.splitext(b)[0]
                    if b[:3] == 'lib':
                        log.info('Replacing _lib_names[0]==%r with %r' \
                              % (self._lib_names[0], b[3:]))
                        self._lib_names[0] = b[3:]
            else:
                ds = d.split(os.pathsep)
                ds2 = []
                for d in ds:

            

Reported by Pylint.

Instance of 'system_info' has no '_lib_names' member
Error

Line: 897 Column: 25

                                  if b[:3] == 'lib':
                        log.info('Replacing _lib_names[0]==%r with %r' \
                              % (self._lib_names[0], b[3:]))
                        self._lib_names[0] = b[3:]
            else:
                ds = d.split(os.pathsep)
                ds2 = []
                for d in ds:
                    if os.path.isdir(d):

            

Reported by Pylint.

Instance of 'system_info' has no '_lib_names' member
Error

Line: 951 Column: 47

              
    def get_libraries(self, key='libraries'):
        if hasattr(self, '_lib_names'):
            return self.get_libs(key, default=self._lib_names)
        else:
            return self.get_libs(key, '')

    def library_extensions(self):
        c = customized_ccompiler()

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 1275 Column: 13

                      if mklroot is None:
            system_info.__init__(self)
        else:
            from .cpuinfo import cpu
            if cpu.is_Itanium():
                plt = '64'
            elif cpu.is_Intel() and cpu.is_64bit():
                plt = 'intel64'
            else:

            

Reported by Pylint.

Using the global statement
Error

Line: 214 Column: 5

              global_compiler = None

def customized_ccompiler():
    global global_compiler
    if not global_compiler:
        global_compiler = _customized_ccompiler()
    return global_compiler



            

Reported by Pylint.

numpy/typing/tests/data/pass/arithmetic.py
393 issues
Value 'np.ndarray' is unsubscriptable
Error

Line: 28 Column: 28

              

class Object:
    def __array__(self) -> np.ndarray[Any, np.dtype[np.object_]]:
        ret = np.empty((), dtype=object)
        ret[()] = self
        return ret

    def __sub__(self, value: Any) -> Object:

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 58 Column: 7

                      return self


AR_b: np.ndarray[Any, np.dtype[np.bool_]] = np.array([True])
AR_u: np.ndarray[Any, np.dtype[np.uint32]] = np.array([1], dtype=np.uint32)
AR_i: np.ndarray[Any, np.dtype[np.int64]] = np.array([1])
AR_f: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 59 Column: 7

              

AR_b: np.ndarray[Any, np.dtype[np.bool_]] = np.array([True])
AR_u: np.ndarray[Any, np.dtype[np.uint32]] = np.array([1], dtype=np.uint32)
AR_i: np.ndarray[Any, np.dtype[np.int64]] = np.array([1])
AR_f: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64(1, "D")])

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 60 Column: 7

              
AR_b: np.ndarray[Any, np.dtype[np.bool_]] = np.array([True])
AR_u: np.ndarray[Any, np.dtype[np.uint32]] = np.array([1], dtype=np.uint32)
AR_i: np.ndarray[Any, np.dtype[np.int64]] = np.array([1])
AR_f: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64(1, "D")])
AR_O: np.ndarray[Any, np.dtype[np.object_]] = np.array([Object()])

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 61 Column: 7

              AR_b: np.ndarray[Any, np.dtype[np.bool_]] = np.array([True])
AR_u: np.ndarray[Any, np.dtype[np.uint32]] = np.array([1], dtype=np.uint32)
AR_i: np.ndarray[Any, np.dtype[np.int64]] = np.array([1])
AR_f: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64(1, "D")])
AR_O: np.ndarray[Any, np.dtype[np.object_]] = np.array([Object()])


            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 62 Column: 7

              AR_u: np.ndarray[Any, np.dtype[np.uint32]] = np.array([1], dtype=np.uint32)
AR_i: np.ndarray[Any, np.dtype[np.int64]] = np.array([1])
AR_f: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64(1, "D")])
AR_O: np.ndarray[Any, np.dtype[np.object_]] = np.array([Object()])

AR_LIKE_b = [True]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 63 Column: 7

              AR_i: np.ndarray[Any, np.dtype[np.int64]] = np.array([1])
AR_f: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64(1, "D")])
AR_O: np.ndarray[Any, np.dtype[np.object_]] = np.array([Object()])

AR_LIKE_b = [True]
AR_LIKE_u = [np.uint32(1)]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 64 Column: 7

              AR_f: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64(1, "D")])
AR_O: np.ndarray[Any, np.dtype[np.object_]] = np.array([Object()])

AR_LIKE_b = [True]
AR_LIKE_u = [np.uint32(1)]
AR_LIKE_i = [1]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 65 Column: 7

              AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64(1, "D")])
AR_O: np.ndarray[Any, np.dtype[np.object_]] = np.array([Object()])

AR_LIKE_b = [True]
AR_LIKE_u = [np.uint32(1)]
AR_LIKE_i = [1]
AR_LIKE_f = [1.0]

            

Reported by Pylint.

bad operand type for unary +: complex64
Error

Line: 335 Column: 1

              -AR_f

+c16
+c8
+f8
+f4
+i8
+i4
+u8

            

Reported by Pylint.

numpy/core/tests/test_indexing.py
385 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              import functools
import operator

import pytest

import numpy as np
from numpy.core._multiarray_tests import array_indexing
from itertools import product
from numpy.testing import (

            

Reported by Pylint.

Unable to import 'numpy.core._multiarray_tests'
Error

Line: 9 Column: 1

              import pytest

import numpy as np
from numpy.core._multiarray_tests import array_indexing
from itertools import product
from numpy.testing import (
    assert_, assert_equal, assert_raises, assert_raises_regex,
    assert_array_equal, assert_warns, HAS_REFCOUNT,
    )

            

Reported by Pylint.

Module 'numpy.random' has no 'uniform' member
Error

Line: 576 Column: 15

                      dt = np.dtype([("", dt)] * 2)
        dt = np.dtype([("", dt)] * 2)
        # The array should be large enough to likely run into threading issues
        arr = np.random.uniform(size=(6000, 8)).view(dt)[:, 0]

        rng = np.random.default_rng()
        def func(arr):
            indx = rng.integers(0, len(arr), size=6000, dtype=np.intp)
            arr[indx]

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 91 Column: 9

                      # Empty tuple index creates a view
        a = np.array([1, 2, 3])
        assert_equal(a[()], a)
        assert_(a[()].base is a)
        a = np.array(0)
        assert_(isinstance(a[()], np.int_))

    def test_void_scalar_empty_tuple(self):
        s = np.zeros((), dtype='V4')

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 93 Column: 9

                      assert_equal(a[()], a)
        assert_(a[()].base is a)
        a = np.array(0)
        assert_(isinstance(a[()], np.int_))

    def test_void_scalar_empty_tuple(self):
        s = np.zeros((), dtype='V4')
        assert_equal(s[()].dtype, s.dtype)
        assert_equal(s[()], s)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 139 Column: 9

                      a = np.array([[1, 2, 3],
                      [4, 5, 6],
                      [7, 8, 9]])
        assert_(a[...] is not a)
        assert_equal(a[...], a)
        # `a[...]` was `a` in numpy <1.9.
        assert_(a[...].base is a)

        # Slicing with ellipsis can skip an

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 142 Column: 9

                      assert_(a[...] is not a)
        assert_equal(a[...], a)
        # `a[...]` was `a` in numpy <1.9.
        assert_(a[...].base is a)

        # Slicing with ellipsis can skip an
        # arbitrary number of dimensions
        assert_equal(a[0, ...], a[0])
        assert_equal(a[0, ...], a[0,:])

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 319 Column: 9

                      # Before `...` would return a itself.
        a = np.arange(5)

        assert_(a is not a[()])
        assert_(a is not a[...])
        assert_(a is not a[:])

    def test_broaderrors_indexing(self):
        a = np.zeros((5, 5))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 320 Column: 9

                      a = np.arange(5)

        assert_(a is not a[()])
        assert_(a is not a[...])
        assert_(a is not a[:])

    def test_broaderrors_indexing(self):
        a = np.zeros((5, 5))
        assert_raises(IndexError, a.__getitem__, ([0, 1], [0, 1, 2]))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 321 Column: 9

              
        assert_(a is not a[()])
        assert_(a is not a[...])
        assert_(a is not a[:])

    def test_broaderrors_indexing(self):
        a = np.zeros((5, 5))
        assert_raises(IndexError, a.__getitem__, ([0, 1], [0, 1, 2]))
        assert_raises(IndexError, a.__setitem__, ([0, 1], [0, 1, 2]), 0)

            

Reported by Pylint.

numpy/core/tests/test_defchararray.py
357 issues
Instance of 'ndarray' has no 'upper' member
Error

Line: 155 Column: 22

              
    def test_it(self):
        assert_equal(self.A.shape, (4,))
        assert_equal(self.A.upper()[:2].tobytes(), b'AB')

class TestComparisons:
    def setup(self):
        self.A = np.array([['abc', '123'],
                           ['789', 'xyz']]).view(np.chararray)

            

Reported by Pylint.

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

Line: 219 Column: 28

                      assert_array_equal(np.char.str_len(self.B), [[3, 0], [5, 9], [12, 5]])

    def test_count(self):
        assert_(issubclass(self.A.count('').dtype.type, np.integer))
        assert_array_equal(self.A.count('a'), [[1, 0], [0, 1], [0, 0]])
        assert_array_equal(self.A.count('123'), [[0, 0], [1, 0], [1, 0]])
        # Python doesn't seem to like counting NULL characters
        # assert_array_equal(self.A.count('\0'), [[0, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.count('a', 0, 2), [[1, 0], [0, 0], [0, 0]])

            

Reported by Pylint.

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

Line: 220 Column: 28

              
    def test_count(self):
        assert_(issubclass(self.A.count('').dtype.type, np.integer))
        assert_array_equal(self.A.count('a'), [[1, 0], [0, 1], [0, 0]])
        assert_array_equal(self.A.count('123'), [[0, 0], [1, 0], [1, 0]])
        # Python doesn't seem to like counting NULL characters
        # assert_array_equal(self.A.count('\0'), [[0, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.count('a', 0, 2), [[1, 0], [0, 0], [0, 0]])
        assert_array_equal(self.B.count('a'), [[0, 0], [0, 1], [0, 0]])

            

Reported by Pylint.

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

Line: 221 Column: 28

                  def test_count(self):
        assert_(issubclass(self.A.count('').dtype.type, np.integer))
        assert_array_equal(self.A.count('a'), [[1, 0], [0, 1], [0, 0]])
        assert_array_equal(self.A.count('123'), [[0, 0], [1, 0], [1, 0]])
        # Python doesn't seem to like counting NULL characters
        # assert_array_equal(self.A.count('\0'), [[0, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.count('a', 0, 2), [[1, 0], [0, 0], [0, 0]])
        assert_array_equal(self.B.count('a'), [[0, 0], [0, 1], [0, 0]])
        assert_array_equal(self.B.count('123'), [[0, 0], [1, 0], [1, 0]])

            

Reported by Pylint.

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

Line: 224 Column: 28

                      assert_array_equal(self.A.count('123'), [[0, 0], [1, 0], [1, 0]])
        # Python doesn't seem to like counting NULL characters
        # assert_array_equal(self.A.count('\0'), [[0, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.count('a', 0, 2), [[1, 0], [0, 0], [0, 0]])
        assert_array_equal(self.B.count('a'), [[0, 0], [0, 1], [0, 0]])
        assert_array_equal(self.B.count('123'), [[0, 0], [1, 0], [1, 0]])
        # assert_array_equal(self.B.count('\0'), [[0, 0], [0, 0], [1, 0]])

    def test_endswith(self):

            

Reported by Pylint.

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

Line: 225 Column: 28

                      # Python doesn't seem to like counting NULL characters
        # assert_array_equal(self.A.count('\0'), [[0, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.count('a', 0, 2), [[1, 0], [0, 0], [0, 0]])
        assert_array_equal(self.B.count('a'), [[0, 0], [0, 1], [0, 0]])
        assert_array_equal(self.B.count('123'), [[0, 0], [1, 0], [1, 0]])
        # assert_array_equal(self.B.count('\0'), [[0, 0], [0, 0], [1, 0]])

    def test_endswith(self):
        assert_(issubclass(self.A.endswith('').dtype.type, np.bool_))

            

Reported by Pylint.

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

Line: 226 Column: 28

                      # assert_array_equal(self.A.count('\0'), [[0, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.count('a', 0, 2), [[1, 0], [0, 0], [0, 0]])
        assert_array_equal(self.B.count('a'), [[0, 0], [0, 1], [0, 0]])
        assert_array_equal(self.B.count('123'), [[0, 0], [1, 0], [1, 0]])
        # assert_array_equal(self.B.count('\0'), [[0, 0], [0, 0], [1, 0]])

    def test_endswith(self):
        assert_(issubclass(self.A.endswith('').dtype.type, np.bool_))
        assert_array_equal(self.A.endswith(' '), [[1, 0], [0, 0], [1, 0]])

            

Reported by Pylint.

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

Line: 230 Column: 28

                      # assert_array_equal(self.B.count('\0'), [[0, 0], [0, 0], [1, 0]])

    def test_endswith(self):
        assert_(issubclass(self.A.endswith('').dtype.type, np.bool_))
        assert_array_equal(self.A.endswith(' '), [[1, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.endswith('3', 0, 3), [[0, 0], [1, 0], [1, 0]])

        def fail():
            self.A.endswith('3', 'fdjk')

            

Reported by Pylint.

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

Line: 231 Column: 28

              
    def test_endswith(self):
        assert_(issubclass(self.A.endswith('').dtype.type, np.bool_))
        assert_array_equal(self.A.endswith(' '), [[1, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.endswith('3', 0, 3), [[0, 0], [1, 0], [1, 0]])

        def fail():
            self.A.endswith('3', 'fdjk')


            

Reported by Pylint.

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

Line: 232 Column: 28

                  def test_endswith(self):
        assert_(issubclass(self.A.endswith('').dtype.type, np.bool_))
        assert_array_equal(self.A.endswith(' '), [[1, 0], [0, 0], [1, 0]])
        assert_array_equal(self.A.endswith('3', 0, 3), [[0, 0], [1, 0], [1, 0]])

        def fail():
            self.A.endswith('3', 'fdjk')

        assert_raises(TypeError, fail)

            

Reported by Pylint.

numpy/lib/tests/test_histograms.py
343 issues
Unable to import 'pytest'
Error

Line: 9 Column: 1

                  assert_array_almost_equal, assert_raises, assert_allclose,
    assert_array_max_ulp, assert_raises_regex, suppress_warnings,
    )
import pytest


class TestHistogram:

    def setup(self):

            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 22 Column: 13

              
    def test_simple(self):
        n = 100
        v = np.random.rand(n)
        (a, b) = histogram(v)
        # check if the sum of the bins equals the number of samples
        assert_equal(np.sum(a, axis=0), n)
        # check that the bin counts are evenly spaced when the data is from
        # a linear function

            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 47 Column: 17

                          rec = sup.record(np.VisibleDeprecationWarning, '.*normed.*')
            # Check that the integral of the density equals 1.
            n = 100
            v = np.random.rand(n)
            a, b = histogram(v, normed=True)
            area = np.sum(a * np.diff(b))
            assert_almost_equal(area, 1)
            assert_equal(len(rec), 1)


            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 68 Column: 13

                  def test_density(self):
        # Check that the integral of the density equals 1.
        n = 100
        v = np.random.rand(n)
        a, b = histogram(v, density=True)
        area = np.sum(a * np.diff(b))
        assert_almost_equal(area, 1)

        # Check with non-constant bin widths

            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 168 Column: 13

                          assert_array_equal(edges, int_edges)

    def test_weights(self):
        v = np.random.rand(100)
        w = np.ones(100) * 5
        a, b = histogram(v)
        na, nb = histogram(v, density=True)
        wa, wb = histogram(v, weights=w)
        nwa, nwb = histogram(v, weights=w, density=True)

            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 550 Column: 19

                      """Verify that Scott's rule and Stone's rule converges for normally distributed data"""

        def nbins_ratio(seed, size):
            rng = np.random.RandomState(seed)
            x = rng.normal(loc=0, scale=2, size=size)
            a, b = len(np.histogram(x, 'stone')[0]), len(np.histogram(x, 'scott')[0])
            return a / (a + b)

        ll = [[nbins_ratio(seed, size) for size in np.geomspace(start=10, stop=100, num=4).round().astype(int)]

            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 656 Column: 13

                      # All possible permutations for bins of different lengths in 3D.
        bins = ((5, 4, 6), (6, 4, 5), (5, 6, 4), (4, 6, 5), (6, 5, 4),
                (4, 5, 6))
        r = np.random.rand(10, 3)
        for b in bins:
            H, edges = histogramdd(r, b)
            assert_(H.shape == b)

    def test_shape_4d(self):

            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 670 Column: 13

                              (6, 5, 4, 7), (4, 7, 6, 5), (4, 5, 6, 7), (7, 6, 4, 5),
                (5, 4, 7, 6), (5, 6, 7, 4), (6, 4, 5, 7), (7, 5, 6, 4))

        r = np.random.rand(10, 4)
        for b in bins:
            H, edges = histogramdd(r, b)
            assert_(H.shape == b)

    def test_weights(self):

            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 676 Column: 13

                          assert_(H.shape == b)

    def test_weights(self):
        v = np.random.rand(100, 2)
        hist, edges = histogramdd(v)
        n_hist, edges = histogramdd(v, density=True)
        w_hist, edges = histogramdd(v, weights=np.ones(100))
        assert_array_equal(w_hist, hist)
        w_hist, edges = histogramdd(v, weights=np.ones(100) * 2, density=True)

            

Reported by Pylint.

Module 'numpy.random' has no 'random' member
Error

Line: 743 Column: 16

                      assert_(hist[1] == 0.0)

    def test_finite_range(self):
        vals = np.random.random((100, 3))
        histogramdd(vals, range=[[0.0, 1.0], [0.25, 0.75], [0.25, 0.5]])
        assert_raises(ValueError, histogramdd, vals,
                      range=[[0.0, 1.0], [0.25, 0.75], [0.25, np.inf]])
        assert_raises(ValueError, histogramdd, vals,
                      range=[[0.0, 1.0], [np.nan, 0.75], [0.25, 0.5]])

            

Reported by Pylint.

numpy/lib/tests/test_nanfunctions.py
342 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import warnings
import pytest

import numpy as np
from numpy.lib.nanfunctions import _nan_mask, _replace_nan
from numpy.testing import (
    assert_, assert_equal, assert_almost_equal, assert_no_warnings,
    assert_raises, assert_array_equal, suppress_warnings
    )

            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 491 Column: 18

                      for f in self.nanfuncs:
            d = np.ones((3, 5, 7, 11))
            # Randomly set some elements to NaN:
            rs = np.random.RandomState(0)
            d[rs.rand(*d.shape) < 0.5] = np.nan
            res = f(d, axis=None)
            assert_equal(res.shape, (1155,))
            for axis in np.arange(4):
                res = f(d, axis=axis)

            

Reported by Pylint.

Module 'numpy.random' has no 'random' member
Error

Line: 617 Column: 13

              
        d = np.ones((3, 5, 7, 11))
        # Randomly set some elements to NaN:
        w = np.random.random((4, 200)) * np.array(d.shape)[:, None]
        w = w.astype(np.intp)
        d[tuple(w)] = np.nan
        with suppress_warnings() as sup:
            sup.filter(RuntimeWarning)
            res = np.nanmedian(d, axis=None, keepdims=True)

            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 636 Column: 15

                          assert_equal(res.shape, (1, 1, 7, 1))

    def test_out(self):
        mat = np.random.rand(3, 3)
        nan_mat = np.insert(mat, [0, 2], np.nan, axis=1)
        resout = np.zeros(3)
        tgt = np.median(mat, axis=1)
        res = np.nanmedian(nan_mat, axis=1, out=resout)
        assert_almost_equal(res, resout)

            

Reported by Pylint.

Module 'numpy.random' has no 'randn' member
Error

Line: 656 Column: 17

                  def test_small_large(self):
        # test the small and large code paths, current cutoff 400 elements
        for s in [5, 20, 51, 200, 1000]:
            d = np.random.randn(4, s)
            # Randomly set some elements to NaN:
            w = np.random.randint(0, d.size, size=d.size // 5)
            d.ravel()[w] = np.nan
            d[:,0] = 1.  # ensure at least one good value
            # use normal median without nans to compare

            

Reported by Pylint.

Module 'numpy.random' has no 'randint' member
Error

Line: 658 Column: 17

                      for s in [5, 20, 51, 200, 1000]:
            d = np.random.randn(4, s)
            # Randomly set some elements to NaN:
            w = np.random.randint(0, d.size, size=d.size // 5)
            d.ravel()[w] = np.nan
            d[:,0] = 1.  # ensure at least one good value
            # use normal median without nans to compare
            tgt = []
            for x in d:

            

Reported by Pylint.

Module 'numpy.random' has no 'random' member
Error

Line: 792 Column: 13

              
        d = np.ones((3, 5, 7, 11))
        # Randomly set some elements to NaN:
        w = np.random.random((4, 200)) * np.array(d.shape)[:, None]
        w = w.astype(np.intp)
        d[tuple(w)] = np.nan
        with suppress_warnings() as sup:
            sup.filter(RuntimeWarning)
            res = np.nanpercentile(d, 90, axis=None, keepdims=True)

            

Reported by Pylint.

Module 'numpy.random' has no 'rand' member
Error

Line: 811 Column: 15

                          assert_equal(res.shape, (1, 1, 7, 1))

    def test_out(self):
        mat = np.random.rand(3, 3)
        nan_mat = np.insert(mat, [0, 2], np.nan, axis=1)
        resout = np.zeros(3)
        tgt = np.percentile(mat, 42, axis=1)
        res = np.nanpercentile(nan_mat, 42, axis=1, out=resout)
        assert_almost_equal(res, resout)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 56 Column: 17

                          for axis in [None, 0, 1]:
                tgt = rf(mat, axis=axis, keepdims=True)
                res = nf(mat, axis=axis, keepdims=True)
                assert_(res.ndim == tgt.ndim)

    def test_out(self):
        mat = np.eye(3)
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            resout = np.zeros(3)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 74 Column: 17

                              mat = np.eye(3, dtype=c)
                tgt = rf(mat, axis=1).dtype.type
                res = nf(mat, axis=1).dtype.type
                assert_(res is tgt)
                # scalar case
                tgt = rf(mat, axis=None).dtype.type
                res = nf(mat, axis=None).dtype.type
                assert_(res is tgt)


            

Reported by Pylint.

numpy/lib/tests/test_arraypad.py
311 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              """Tests for the array padding functions.

"""
import pytest

import numpy as np
from numpy.testing import assert_array_equal, assert_allclose, assert_equal
from numpy.lib.arraypad import _as_pairs


            

Reported by Pylint.

Unused argument 'iaxis'
Error

Line: 1198 Column: 41

              

def test_legacy_vector_functionality():
    def _padwithtens(vector, pad_width, iaxis, kwargs):
        vector[:pad_width[0]] = 10
        vector[-pad_width[1]:] = 10

    a = np.arange(6).reshape(2, 3)
    a = np.pad(a, 2, _padwithtens)

            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 1198 Column: 48

              

def test_legacy_vector_functionality():
    def _padwithtens(vector, pad_width, iaxis, kwargs):
        vector[:pad_width[0]] = 10
        vector[-pad_width[1]:] = 10

    a = np.arange(6).reshape(2, 3)
    a = np.pad(a, 2, _padwithtens)

            

Reported by Pylint.

Too many lines in module (1364/1000)
Error

Line: 1 Column: 1

              """Tests for the array padding functions.

"""
import pytest

import numpy as np
from numpy.testing import assert_array_equal, assert_allclose, assert_equal
from numpy.lib.arraypad import _as_pairs


            

Reported by Pylint.

Missing class docstring
Error

Line: 32 Column: 1

              }


class TestAsPairs:
    def test_single_value(self):
        """Test casting for a single value."""
        expected = np.array([[3, 3]] * 10)
        for x in (3, [3], [[3]]):
            result = _as_pairs(x, 10)

            

Reported by Pylint.

Method could be a function
Error

Line: 33 Column: 5

              

class TestAsPairs:
    def test_single_value(self):
        """Test casting for a single value."""
        expected = np.array([[3, 3]] * 10)
        for x in (3, [3], [[3]]):
            result = _as_pairs(x, 10)
            assert_equal(result, expected)

            

Reported by Pylint.

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

Line: 36 Column: 13

                  def test_single_value(self):
        """Test casting for a single value."""
        expected = np.array([[3, 3]] * 10)
        for x in (3, [3], [[3]]):
            result = _as_pairs(x, 10)
            assert_equal(result, expected)
        # Test with dtype=object
        obj = object()
        assert_equal(

            

Reported by Pylint.

Method could be a function
Error

Line: 46 Column: 5

                          np.array([[obj, obj]] * 10)
        )

    def test_two_values(self):
        """Test proper casting for two different values."""
        # Broadcasting in the first dimension with numbers
        expected = np.array([[3, 4]] * 10)
        for x in ([3, 4], [[3, 4]]):
            result = _as_pairs(x, 10)

            

Reported by Pylint.

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

Line: 50 Column: 13

                      """Test proper casting for two different values."""
        # Broadcasting in the first dimension with numbers
        expected = np.array([[3, 4]] * 10)
        for x in ([3, 4], [[3, 4]]):
            result = _as_pairs(x, 10)
            assert_equal(result, expected)
        # and with dtype=object
        obj = object()
        assert_equal(

            

Reported by Pylint.

Method could be a function
Error

Line: 71 Column: 5

                          np.array([["a", "a"], [obj, obj]])
        )

    def test_with_none(self):
        expected = ((None, None), (None, None), (None, None))
        assert_equal(
            _as_pairs(None, 3, as_index=False),
            expected
        )

            

Reported by Pylint.