The following issues were found

numpy/lib/function_base.py
306 issues
Unexpected keyword argument 'shape' in function call
Error

Line: 1958 Column: 24

                      arrays = tuple(np.empty(shape=shape, dtype=dtype)
                       for shape, dtype in zip(shapes, dtypes))
    else:
        arrays = tuple(np.empty_like(result, shape=shape, dtype=dtype)
                       for result, shape, dtype
                       in zip(results, shapes, dtypes))
    return arrays



            

Reported by Pylint.

Redefining built-in 'sum'
Error

Line: 19 Column: 1

                  pi, add, arctan2, frompyfunc, cos, less_equal, sqrt, sin,
    mod, exp, not_equal, subtract
    )
from numpy.core.fromnumeric import (
    ravel, nonzero, partition, mean, any, sum
    )
from numpy.core.numerictypes import typecodes
from numpy.core.overrides import set_module
from numpy.core import overrides

            

Reported by Pylint.

Redefining built-in 'any'
Error

Line: 19 Column: 1

                  pi, add, arctan2, frompyfunc, cos, less_equal, sqrt, sin,
    mod, exp, not_equal, subtract
    )
from numpy.core.fromnumeric import (
    ravel, nonzero, partition, mean, any, sum
    )
from numpy.core.numerictypes import typecodes
from numpy.core.overrides import set_module
from numpy.core import overrides

            

Reported by Pylint.

Unused histogram imported from numpy.lib.histograms
Error

Line: 36 Column: 1

              import builtins

# needed in this module for compatibility
from numpy.lib.histograms import histogram, histogramdd


array_function_dispatch = functools.partial(
    overrides.array_function_dispatch, module='numpy')


            

Reported by Pylint.

Unused histogramdd imported from numpy.lib.histograms
Error

Line: 36 Column: 1

              import builtins

# needed in this module for compatibility
from numpy.lib.histograms import histogram, histogramdd


array_function_dispatch = functools.partial(
    overrides.array_function_dispatch, module='numpy')


            

Reported by Pylint.

Unused argument 'k'
Error

Line: 55 Column: 26

                  ]


def _rot90_dispatcher(m, k=None, axes=None):
    return (m,)


@array_function_dispatch(_rot90_dispatcher)
def rot90(m, k=1, axes=(0, 1)):

            

Reported by Pylint.

Unused argument 'axes'
Error

Line: 55 Column: 34

                  ]


def _rot90_dispatcher(m, k=None, axes=None):
    return (m,)


@array_function_dispatch(_rot90_dispatcher)
def rot90(m, k=1, axes=(0, 1)):

            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 149 Column: 25

                      return flip(transpose(m, axes_list), axes[1])


def _flip_dispatcher(m, axis=None):
    return (m,)


@array_function_dispatch(_flip_dispatcher)
def flip(m, axis=None):

            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 279 Column: 28

                  return True


def _average_dispatcher(a, axis=None, weights=None, returned=None):
    return (a, weights)


@array_function_dispatch(_average_dispatcher)
def average(a, axis=None, weights=None, returned=False):

            

Reported by Pylint.

Unused argument 'returned'
Error

Line: 279 Column: 53

                  return True


def _average_dispatcher(a, axis=None, weights=None, returned=None):
    return (a, weights)


@array_function_dispatch(_average_dispatcher)
def average(a, axis=None, weights=None, returned=False):

            

Reported by Pylint.

numpy/lib/tests/test_shape_base.py
304 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import numpy as np
import functools
import sys
import pytest

from numpy.lib.shape_base import (
    apply_along_axis, apply_over_axes, array_split, split, hsplit, dsplit,
    vsplit, dstack, column_stack, kron, tile, expand_dims, take_along_axis,
    put_along_axis

            

Reported by Pylint.

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

Line: 228 Column: 45

                      res = apply_along_axis(f1to2, 0, a)
        assert_(isinstance(res, np.ma.masked_array))
        assert_equal(res.ndim, 3)
        assert_array_equal(res[:,:,0].mask, f1to2(a[:,0]).mask)
        assert_array_equal(res[:,:,1].mask, f1to2(a[:,1]).mask)
        assert_array_equal(res[:,:,2].mask, f1to2(a[:,2]).mask)

    def test_tuple_func1d(self):
        def sample_1d(x):

            

Reported by Pylint.

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

Line: 229 Column: 45

                      assert_(isinstance(res, np.ma.masked_array))
        assert_equal(res.ndim, 3)
        assert_array_equal(res[:,:,0].mask, f1to2(a[:,0]).mask)
        assert_array_equal(res[:,:,1].mask, f1to2(a[:,1]).mask)
        assert_array_equal(res[:,:,2].mask, f1to2(a[:,2]).mask)

    def test_tuple_func1d(self):
        def sample_1d(x):
            return x[1], x[0]

            

Reported by Pylint.

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

Line: 230 Column: 45

                      assert_equal(res.ndim, 3)
        assert_array_equal(res[:,:,0].mask, f1to2(a[:,0]).mask)
        assert_array_equal(res[:,:,1].mask, f1to2(a[:,1]).mask)
        assert_array_equal(res[:,:,2].mask, f1to2(a[:,2]).mask)

    def test_tuple_func1d(self):
        def sample_1d(x):
            return x[1], x[0]
        res = np.apply_along_axis(sample_1d, 1, np.array([[1, 2], [3, 4]]))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 134 Column: 9

                      expected = np.array([[0, 2], [4, 6]]).view(MyNDArray)

        result = apply_along_axis(double, 0, m)
        assert_(isinstance(result, MyNDArray))
        assert_array_equal(result, expected)

        result = apply_along_axis(double, 1, m)
        assert_(isinstance(result, MyNDArray))
        assert_array_equal(result, expected)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 138 Column: 9

                      assert_array_equal(result, expected)

        result = apply_along_axis(double, 1, m)
        assert_(isinstance(result, MyNDArray))
        assert_array_equal(result, expected)

    def test_subclass(self):
        class MinimalSubclass(np.ndarray):
            data = 1

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 157 Column: 9

                  def test_scalar_array(self, cls=np.ndarray):
        a = np.ones((6, 3)).view(cls)
        res = apply_along_axis(np.sum, 0, a)
        assert_(isinstance(res, cls))
        assert_array_equal(res, np.array([6, 6, 6]).view(cls))

    def test_0d_array(self, cls=np.ndarray):
        def sum_to_0d(x):
            """ Sum x, returning a 0d array of the same class """

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 167 Column: 9

                          return np.squeeze(np.sum(x, keepdims=True))
        a = np.ones((6, 3)).view(cls)
        res = apply_along_axis(sum_to_0d, 0, a)
        assert_(isinstance(res, cls))
        assert_array_equal(res, np.array([6, 6, 6]).view(cls))

        res = apply_along_axis(sum_to_0d, 1, a)
        assert_(isinstance(res, cls))
        assert_array_equal(res, np.array([3, 3, 3, 3, 3, 3]).view(cls))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 171 Column: 9

                      assert_array_equal(res, np.array([6, 6, 6]).view(cls))

        res = apply_along_axis(sum_to_0d, 1, a)
        assert_(isinstance(res, cls))
        assert_array_equal(res, np.array([3, 3, 3, 3, 3, 3]).view(cls))

    def test_axis_insertion(self, cls=np.ndarray):
        def f1to2(x):
            """produces an asymmetric non-square matrix from x"""

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 226 Column: 9

                          return np.ma.masked_where(res%5==0, res)
        a = np.arange(6*3).reshape((6, 3))
        res = apply_along_axis(f1to2, 0, a)
        assert_(isinstance(res, np.ma.masked_array))
        assert_equal(res.ndim, 3)
        assert_array_equal(res[:,:,0].mask, f1to2(a[:,0]).mask)
        assert_array_equal(res[:,:,1].mask, f1to2(a[:,1]).mask)
        assert_array_equal(res[:,:,2].mask, f1to2(a[:,2]).mask)


            

Reported by Pylint.

numpy/distutils/misc_util.py
296 issues
No value for argument 'a' in function call
Error

Line: 193 Column: 18

                      joined = ''
    else:
        # njoin('a', 'b')
        joined = os.path.join(*path)
    if os.path.sep != '/':
        joined = joined.replace('/', os.path.sep)
    return minrelpath(joined)

def get_mathlibs(path=None):

            

Reported by Pylint.

Instance of 'Configuration' has no 'packages' member
Error

Line: 836 Column: 13

                              self.extra_keys.append(n)

        if os.path.exists(njoin(package_path, '__init__.py')):
            self.packages.append(self.name)
            self.package_dir[self.name] = package_path

        self.options = dict(
            ignore_setup_xxx_py = False,
            assume_default_configuration = False,

            

Reported by Pylint.

Instance of 'Configuration' has no 'package_dir' member
Error

Line: 837 Column: 13

              
        if os.path.exists(njoin(package_path, '__init__.py')):
            self.packages.append(self.name)
            self.package_dir[self.name] = package_path

        self.options = dict(
            ignore_setup_xxx_py = False,
            assume_default_configuration = False,
            delegate_options_to_subpackages = False,

            

Reported by Pylint.

Instance of 'Configuration' has no 'data_files' member
Error

Line: 1182 Column: 26

                      if dist is not None and dist.data_files is not None:
            data_files = dist.data_files
        else:
            data_files = self.data_files

        for path in paths:
            for d1, f in list(general_source_directories_files(path)):
                target_path = os.path.join(self.path_in_package, d, d1)
                data_files.append((target_path, f))

            

Reported by Pylint.

Instance of 'Configuration' has no 'data_files' member
Error

Line: 1191 Column: 25

              
    def _optimize_data_files(self):
        data_dict = {}
        for p, files in self.data_files:
            if p not in data_dict:
                data_dict[p] = set()
            for f in files:
                data_dict[p].add(f)
        self.data_files[:] = [(p, list(files)) for p, files in data_dict.items()]

            

Reported by Pylint.

Instance of 'Configuration' has no 'data_files' member
Error

Line: 1196 Column: 9

                              data_dict[p] = set()
            for f in files:
                data_dict[p].add(f)
        self.data_files[:] = [(p, list(files)) for p, files in data_dict.items()]

    def add_data_files(self,*files):
        """Add data files to configuration data_files.

        Parameters

            

Reported by Pylint.

Instance of 'Configuration' has no 'data_files' member
Error

Line: 1345 Column: 26

                      if dist is not None and dist.data_files is not None:
            data_files = dist.data_files
        else:
            data_files = self.data_files

        data_files.append((os.path.join(self.path_in_package, d), paths))

    ### XXX Implement add_py_modules


            

Reported by Pylint.

Instance of 'Configuration' has no 'define_macros' member
Error

Line: 1364 Column: 13

                              dist.define_macros = []
            dist.define_macros.extend(macros)
        else:
            self.define_macros.extend(macros)


    def add_include_dirs(self,*paths):
        """Add paths to configuration include directories.


            

Reported by Pylint.

Instance of 'Configuration' has no 'include_dirs' member
Error

Line: 1381 Column: 13

                              dist.include_dirs = []
            dist.include_dirs.extend(include_dirs)
        else:
            self.include_dirs.extend(include_dirs)

    def add_headers(self,*files):
        """Add installable headers to configuration.

        Add the given sequence of files to the beginning of the headers list.

            

Reported by Pylint.

Instance of 'Configuration' has no 'headers' member
Error

Line: 1415 Column: 13

                              dist.headers = []
            dist.headers.extend(headers)
        else:
            self.headers.extend(headers)

    def paths(self,*paths,**kws):
        """Apply glob to paths and prepend local_path if needed.

        Applies glob.glob(...) to each path in the sequence (if needed) and

            

Reported by Pylint.

numpy/core/tests/test_shape_base.py
296 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest
import numpy as np
from numpy.core import (
    array, arange, atleast_1d, atleast_2d, atleast_3d, block, vstack, hstack,
    newaxis, concatenate, stack
    )
from numpy.core.shape_base import (_block_dispatcher, _block_setup,
                                   _block_concatenate, _block_slicing)
from numpy.testing import (

            

Reported by Pylint.

Unexpected keyword argument 'dtype' in function call
Error

Line: 259 Column: 13

                      r = np.concatenate((a, b), axis=None)
        assert_equal(r.size, a.size + len(b))
        assert_equal(r.dtype, a.dtype)
        r = np.concatenate((a, b, c), axis=None, dtype="U")
        d = array(['0.0', '1.0', '2.0', '3.0',
                   '0', '1', '2', 'x'])
        assert_array_equal(r, d)

        out = np.zeros(a.size + len(b))

            

Reported by Pylint.

Unexpected keyword argument 'casting' in function call
Error

Line: 379 Column: 15

                  def test_dtype_with_promotion(self, arrs, string_dt, axis):
        # Note that U0 and S0 should be deprecated eventually and changed to
        # actually give the empty string result (together with `np.array`)
        res = np.concatenate(arrs, axis=axis, dtype=string_dt, casting="unsafe")
        # The actual dtype should be identical to a cast (of a double array):
        assert res.dtype == np.array(1.).astype(string_dt).dtype

    @pytest.mark.parametrize("axis", [None, 0])
    def test_string_dtype_does_not_inspect(self, axis):

            

Reported by Pylint.

Unexpected keyword argument 'dtype' in function call
Error

Line: 379 Column: 15

                  def test_dtype_with_promotion(self, arrs, string_dt, axis):
        # Note that U0 and S0 should be deprecated eventually and changed to
        # actually give the empty string result (together with `np.array`)
        res = np.concatenate(arrs, axis=axis, dtype=string_dt, casting="unsafe")
        # The actual dtype should be identical to a cast (of a double array):
        assert res.dtype == np.array(1.).astype(string_dt).dtype

    @pytest.mark.parametrize("axis", [None, 0])
    def test_string_dtype_does_not_inspect(self, axis):

            

Reported by Pylint.

Unexpected keyword argument 'dtype' in function call
Error

Line: 386 Column: 13

                  @pytest.mark.parametrize("axis", [None, 0])
    def test_string_dtype_does_not_inspect(self, axis):
        with pytest.raises(TypeError):
            np.concatenate(([None], [1]), dtype="S", axis=axis)
        with pytest.raises(TypeError):
            np.concatenate(([None], [1]), dtype="U", axis=axis)

    @pytest.mark.parametrize("axis", [None, 0])
    def test_subarray_error(self, axis):

            

Reported by Pylint.

Unexpected keyword argument 'dtype' in function call
Error

Line: 388 Column: 13

                      with pytest.raises(TypeError):
            np.concatenate(([None], [1]), dtype="S", axis=axis)
        with pytest.raises(TypeError):
            np.concatenate(([None], [1]), dtype="U", axis=axis)

    @pytest.mark.parametrize("axis", [None, 0])
    def test_subarray_error(self, axis):
        with pytest.raises(TypeError, match=".*subarray dtype"):
            np.concatenate(([1], [1]), dtype="(2,)i", axis=axis)

            

Reported by Pylint.

Unexpected keyword argument 'dtype' in function call
Error

Line: 393 Column: 13

                  @pytest.mark.parametrize("axis", [None, 0])
    def test_subarray_error(self, axis):
        with pytest.raises(TypeError, match=".*subarray dtype"):
            np.concatenate(([1], [1]), dtype="(2,)i", axis=axis)


def test_stack():
    # non-iterable input
    assert_raises(TypeError, stack, 1)

            

Reported by Pylint.

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

Line: 415 Column: 15

                  assert_array_equal(np.stack(list([a, b])), r1)
    assert_array_equal(np.stack(array([a, b])), r1)
    # all shapes for 1d input
    arrays = [np.random.randn(3) for _ in range(10)]
    axes = [0, 1, -1, -2]
    expected_shapes = [(10, 3), (3, 10), (3, 10), (10, 3)]
    for axis, expected_shape in zip(axes, expected_shapes):
        assert_equal(np.stack(arrays, axis).shape, expected_shape)
    assert_raises_regex(np.AxisError, 'out of bounds', stack, arrays, axis=2)

            

Reported by Pylint.

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

Line: 423 Column: 15

                  assert_raises_regex(np.AxisError, 'out of bounds', stack, arrays, axis=2)
    assert_raises_regex(np.AxisError, 'out of bounds', stack, arrays, axis=-3)
    # all shapes for 2d input
    arrays = [np.random.randn(3, 4) for _ in range(10)]
    axes = [0, 1, 2, -1, -2, -3]
    expected_shapes = [(10, 3, 4), (3, 10, 4), (3, 4, 10),
                       (3, 4, 10), (3, 10, 4), (10, 3, 4)]
    for axis, expected_shape in zip(axes, expected_shapes):
        assert_equal(np.stack(arrays, axis).shape, expected_shape)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 49 Column: 9

                  def test_r1array(self):
        """ Test to make sure equivalent Travis O's r1array function
        """
        assert_(atleast_1d(3).shape == (1,))
        assert_(atleast_1d(3j).shape == (1,))
        assert_(atleast_1d(3.0).shape == (1,))
        assert_(atleast_1d([[2, 3], [4, 5]]).shape == (2, 2))



            

Reported by Pylint.

numpy/core/tests/test_scalarmath.py
293 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              import itertools
import operator
import platform
import pytest
from hypothesis import given, settings, Verbosity, assume
from hypothesis.strategies import sampled_from

import numpy as np
from numpy.testing import (

            

Reported by Pylint.

Unable to import 'hypothesis'
Error

Line: 8 Column: 1

              import operator
import platform
import pytest
from hypothesis import given, settings, Verbosity, assume
from hypothesis.strategies import sampled_from

import numpy as np
from numpy.testing import (
    assert_, assert_equal, assert_raises, assert_almost_equal,

            

Reported by Pylint.

Unable to import 'hypothesis.strategies'
Error

Line: 9 Column: 1

              import platform
import pytest
from hypothesis import given, settings, Verbosity, assume
from hypothesis.strategies import sampled_from

import numpy as np
from numpy.testing import (
    assert_, assert_equal, assert_raises, assert_almost_equal,
    assert_array_equal, IS_PYPY, suppress_warnings, _gen_alignment_data,

            

Reported by Pylint.

Instance of 'float96' has no '__int__' member; maybe '__init__'?
Error

Line: 434 Column: 38

                  @pytest.mark.skipif(not IS_PYPY, reason="Test is PyPy only (gh-9972)")
    def test_int_from_infinite_longdouble___int__(self):
        x = np.longdouble(np.inf)
        assert_raises(OverflowError, x.__int__)
        with suppress_warnings() as sup:
            sup.record(np.ComplexWarning)
            x = np.clongdouble(np.inf)
            assert_raises(OverflowError, x.__int__)
            assert_equal(len(sup.log), 1)

            

Reported by Pylint.

Instance of 'complex192' has no '__int__' member; maybe '__init__'?
Error

Line: 438 Column: 42

                      with suppress_warnings() as sup:
            sup.record(np.ComplexWarning)
            x = np.clongdouble(np.inf)
            assert_raises(OverflowError, x.__int__)
            assert_equal(len(sup.log), 1)

    @pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
                        reason="long double is same as double")
    @pytest.mark.skipif(platform.machine().startswith("ppc"),

            

Reported by Pylint.

Class 'int' has no 'nbytes' member
Error

Line: 572 Column: 44

                      def test_equal_nbytes(self):
            for type in types:
                x = type(0)
                assert_(sys.getsizeof(x) > x.nbytes)

        def test_error(self):
            d = np.float32()
            assert_raises(TypeError, d.__sizeof__, "a")


            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 575 Column: 17

                              assert_(sys.getsizeof(x) > x.nbytes)

        def test_error(self):
            d = np.float32()
            assert_raises(TypeError, d.__sizeof__, "a")


class TestMultiply:
    def test_seq_repeat(self):

            

Reported by Pylint.

Unused assume imported from hypothesis
Error

Line: 8 Column: 1

              import operator
import platform
import pytest
from hypothesis import given, settings, Verbosity, assume
from hypothesis.strategies import sampled_from

import numpy as np
from numpy.testing import (
    assert_, assert_equal, assert_raises, assert_almost_equal,

            

Reported by Pylint.

Unused assert_raises_regex imported from numpy.testing
Error

Line: 12 Column: 1

              from hypothesis.strategies import sampled_from

import numpy as np
from numpy.testing import (
    assert_, assert_equal, assert_raises, assert_almost_equal,
    assert_array_equal, IS_PYPY, suppress_warnings, _gen_alignment_data,
    assert_warns, assert_raises_regex,
    )


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 33 Column: 13

                  def test_types(self):
        for atype in types:
            a = atype(1)
            assert_(a == 1, "error with %r: got %r" % (atype, a))

    def test_type_add(self):
        # list of types
        for k, atype in enumerate(types):
            a_scalar = atype(3)

            

Reported by Pylint.

numpy/core/tests/test_einsum.py
288 issues
Module 'numpy.random' has no 'normal' member
Error

Line: 709 Column: 13

                  def test_einsum_fixed_collapsingbug(self):
        # Issue #5147.
        # The bug only occurred when output argument of einssum was used.
        x = np.random.normal(0, 1, (5, 5, 5, 5))
        y1 = np.zeros((5, 5))
        np.einsum('aabb->ab', x, out=y1)
        idx = np.arange(5)
        y2 = x[idx[:, None], idx[:, None], idx, idx]
        assert_equal(y1, y2)

            

Reported by Pylint.

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

Line: 719 Column: 18

                  def test_einsum_failed_on_p9_and_s390x(self):
        # Issues gh-14692 and gh-12689
        # Bug with signed vs unsigned char errored on power9 and s390x Linux
        tensor = np.random.random_sample((10, 10, 10, 10))
        x = np.einsum('ijij->', tensor)
        y = tensor.trace(axis1=0, axis2=2).trace()
        assert_allclose(x, y)

    def test_einsum_all_contig_non_contig_output(self):

            

Reported by Pylint.

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

Line: 770 Column: 29

                          terms = subscripts.split('->')[0].split(',')
            for term in terms:
                dims = [global_size_dict[x] for x in term]
                args.append(np.random.rand(*dims))
        else:
            args = [subscripts] + operands

        noopt = np.einsum(*args, optimize=False)
        opt = np.einsum(*args, optimize='greedy')

            

Reported by Pylint.

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

Line: 866 Column: 13

                  def test_broadcasting_dot_cases(self):
        # Ensures broadcasting cases are not mistaken for GEMM

        a = np.random.rand(1, 5, 4)
        b = np.random.rand(4, 6)
        c = np.random.rand(5, 6)
        d = np.random.rand(10)

        self.optimize_compare('ijk,kl,jl', operands=[a, b, c])

            

Reported by Pylint.

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

Line: 867 Column: 13

                      # Ensures broadcasting cases are not mistaken for GEMM

        a = np.random.rand(1, 5, 4)
        b = np.random.rand(4, 6)
        c = np.random.rand(5, 6)
        d = np.random.rand(10)

        self.optimize_compare('ijk,kl,jl', operands=[a, b, c])
        self.optimize_compare('ijk,kl,jl,i->i', operands=[a, b, c, d])

            

Reported by Pylint.

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

Line: 868 Column: 13

              
        a = np.random.rand(1, 5, 4)
        b = np.random.rand(4, 6)
        c = np.random.rand(5, 6)
        d = np.random.rand(10)

        self.optimize_compare('ijk,kl,jl', operands=[a, b, c])
        self.optimize_compare('ijk,kl,jl,i->i', operands=[a, b, c, d])


            

Reported by Pylint.

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

Line: 869 Column: 13

                      a = np.random.rand(1, 5, 4)
        b = np.random.rand(4, 6)
        c = np.random.rand(5, 6)
        d = np.random.rand(10)

        self.optimize_compare('ijk,kl,jl', operands=[a, b, c])
        self.optimize_compare('ijk,kl,jl,i->i', operands=[a, b, c, d])

        e = np.random.rand(1, 1, 5, 4)

            

Reported by Pylint.

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

Line: 874 Column: 13

                      self.optimize_compare('ijk,kl,jl', operands=[a, b, c])
        self.optimize_compare('ijk,kl,jl,i->i', operands=[a, b, c, d])

        e = np.random.rand(1, 1, 5, 4)
        f = np.random.rand(7, 7)
        self.optimize_compare('abjk,kl,jl', operands=[e, b, c])
        self.optimize_compare('abjk,kl,jl,ab->ab', operands=[e, b, c, f])

        # Edge case found in gh-11308

            

Reported by Pylint.

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

Line: 875 Column: 13

                      self.optimize_compare('ijk,kl,jl,i->i', operands=[a, b, c, d])

        e = np.random.rand(1, 1, 5, 4)
        f = np.random.rand(7, 7)
        self.optimize_compare('abjk,kl,jl', operands=[e, b, c])
        self.optimize_compare('abjk,kl,jl,ab->ab', operands=[e, b, c, f])

        # Edge case found in gh-11308
        g = np.arange(64).reshape(2, 4, 8)

            

Reported by Pylint.

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

Line: 927 Column: 29

                      terms = string.split('->')[0].split(',')
        for term in terms:
            dims = [size_dict[x] for x in term]
            operands.append(np.random.rand(*dims))

        return operands

    def assert_path_equal(self, comp, benchmark):
        # Checks if list of tuples are equivalent

            

Reported by Pylint.

numpy/distutils/ccompiler_opt.py
284 issues
Instance of '_Config' has no 'cc_noopt' member
Error

Line: 310 Column: 12

                      class attribute `conf_features`, also its override
        any options that been set in 'conf_features'.
        """
        if self.cc_noopt:
            # optimization is disabled
            return {}

        on_x86 = self.cc_on_x86 or self.cc_on_x64
        is_unix = self.cc_is_gcc or self.cc_is_clang

            

Reported by Pylint.

Instance of '_Config' has no 'cc_on_x86' member
Error

Line: 314 Column: 18

                          # optimization is disabled
            return {}

        on_x86 = self.cc_on_x86 or self.cc_on_x64
        is_unix = self.cc_is_gcc or self.cc_is_clang

        if on_x86 and is_unix: return dict(
            SSE    = dict(flags="-msse"),
            SSE2   = dict(flags="-msse2"),

            

Reported by Pylint.

Instance of '_Config' has no 'cc_on_x64' member
Error

Line: 314 Column: 36

                          # optimization is disabled
            return {}

        on_x86 = self.cc_on_x86 or self.cc_on_x64
        is_unix = self.cc_is_gcc or self.cc_is_clang

        if on_x86 and is_unix: return dict(
            SSE    = dict(flags="-msse"),
            SSE2   = dict(flags="-msse2"),

            

Reported by Pylint.

Instance of '_Config' has no 'cc_is_gcc' member
Error

Line: 315 Column: 19

                          return {}

        on_x86 = self.cc_on_x86 or self.cc_on_x64
        is_unix = self.cc_is_gcc or self.cc_is_clang

        if on_x86 and is_unix: return dict(
            SSE    = dict(flags="-msse"),
            SSE2   = dict(flags="-msse2"),
            SSE3   = dict(flags="-msse3"),

            

Reported by Pylint.

Instance of '_Config' has no 'cc_is_clang' member
Error

Line: 315 Column: 37

                          return {}

        on_x86 = self.cc_on_x86 or self.cc_on_x64
        is_unix = self.cc_is_gcc or self.cc_is_clang

        if on_x86 and is_unix: return dict(
            SSE    = dict(flags="-msse"),
            SSE2   = dict(flags="-msse2"),
            SSE3   = dict(flags="-msse3"),

            

Reported by Pylint.

Instance of '_Config' has no 'cc_is_icc' member
Error

Line: 344 Column: 23

                              flags="-mavx512vbmi2 -mavx512bitalg -mavx512vpopcntdq"
            )
        )
        if on_x86 and self.cc_is_icc: return dict(
            SSE    = dict(flags="-msse"),
            SSE2   = dict(flags="-msse2"),
            SSE3   = dict(flags="-msse3"),
            SSSE3  = dict(flags="-mssse3"),
            SSE41  = dict(flags="-msse4.1"),

            

Reported by Pylint.

Instance of '_Config' has no 'cc_is_iccw' member
Error

Line: 375 Column: 23

                          AVX512_CNL = dict(flags="-xCANNONLAKE"),
            AVX512_ICL = dict(flags="-xICELAKE-CLIENT"),
        )
        if on_x86 and self.cc_is_iccw: return dict(
            SSE    = dict(flags="/arch:SSE"),
            SSE2   = dict(flags="/arch:SSE2"),
            SSE3   = dict(flags="/arch:SSE3"),
            SSSE3  = dict(flags="/arch:SSSE3"),
            SSE41  = dict(flags="/arch:SSE4.1"),

            

Reported by Pylint.

Instance of '_Config' has no 'cc_is_msvc' member
Error

Line: 408 Column: 23

                          AVX512_CNL = dict(flags="/Qx:CANNONLAKE"),
            AVX512_ICL = dict(flags="/Qx:ICELAKE-CLIENT")
        )
        if on_x86 and self.cc_is_msvc: return dict(
            SSE    = dict(flags="/arch:SSE"),
            SSE2   = dict(flags="/arch:SSE2"),
            SSE3   = {},
            SSSE3  = {},
            SSE41  = {},

            

Reported by Pylint.

Instance of '_Config' has no 'cc_on_ppc64' member
Error

Line: 447 Column: 42

                          AVX512_ICL = {}
        )

        on_power = self.cc_on_ppc64le or self.cc_on_ppc64
        if on_power:
            partial = dict(
                VSX = dict(
                    implies=("VSX2" if self.cc_on_ppc64le else ""),
                    flags="-mvsx"

            

Reported by Pylint.

Instance of '_Config' has no 'cc_on_ppc64le' member
Error

Line: 447 Column: 20

                          AVX512_ICL = {}
        )

        on_power = self.cc_on_ppc64le or self.cc_on_ppc64
        if on_power:
            partial = dict(
                VSX = dict(
                    implies=("VSX2" if self.cc_on_ppc64le else ""),
                    flags="-mvsx"

            

Reported by Pylint.

numpy/f2py/tests/test_array_from_pyobj.py
277 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import sys
import copy
import platform
import pytest

import numpy as np

from numpy.testing import assert_, assert_equal
from numpy.core.multiarray import typeinfo

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

              
from numpy.testing import assert_, assert_equal
from numpy.core.multiarray import typeinfo
from . import util

wrap = None


def setup_module():

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 124 Column: 39

              # when numpy gains an aligned allocator the tests could be enabled again
#
# Furthermore, on macOS ARM64, LONGDOUBLE is an alias for DOUBLE.
if ((np.intp().dtype.itemsize != 4 or np.clongdouble().dtype.alignment <= 8) and
        sys.platform != 'win32' and
        (platform.system(), platform.processor()) != ('Darwin', 'arm')):
    _type_names.extend(['LONGDOUBLE', 'CDOUBLE', 'CLONGDOUBLE'])
    _cast_dict['LONGDOUBLE'] = _cast_dict['LONG'] + \
        ['ULONG', 'FLOAT', 'DOUBLE', 'LONGDOUBLE']

            

Reported by Pylint.

Method 'dtype' has no 'alignment' member
Error

Line: 124 Column: 39

              # when numpy gains an aligned allocator the tests could be enabled again
#
# Furthermore, on macOS ARM64, LONGDOUBLE is an alias for DOUBLE.
if ((np.intp().dtype.itemsize != 4 or np.clongdouble().dtype.alignment <= 8) and
        sys.platform != 'win32' and
        (platform.system(), platform.processor()) != ('Darwin', 'arm')):
    _type_names.extend(['LONGDOUBLE', 'CDOUBLE', 'CLONGDOUBLE'])
    _cast_dict['LONGDOUBLE'] = _cast_dict['LONG'] + \
        ['ULONG', 'FLOAT', 'DOUBLE', 'LONGDOUBLE']

            

Reported by Pylint.

Value 'self.pyarr.flags' is unsubscriptable
Error

Line: 241 Column: 17

                          assert_(self.pyarr.dtype == typ,
                    repr((self.pyarr.dtype, typ)))
        self.pyarr.setflags(write=self.arr.flags['WRITEABLE'])
        assert_(self.pyarr.flags['OWNDATA'], (obj, intent))
        self.pyarr_attr = wrap.array_attrs(self.pyarr)

        if len(dims) > 1:
            if self.intent.is_intent('c'):
                assert_(not self.pyarr.flags['FORTRAN'])

            

Reported by Pylint.

Value 'self.pyarr.flags' is unsubscriptable
Error

Line: 246 Column: 29

              
        if len(dims) > 1:
            if self.intent.is_intent('c'):
                assert_(not self.pyarr.flags['FORTRAN'])
                assert_(self.pyarr.flags['CONTIGUOUS'])
                assert_(not self.pyarr_attr[6] & wrap.FORTRAN)
            else:
                assert_(self.pyarr.flags['FORTRAN'])
                assert_(not self.pyarr.flags['CONTIGUOUS'])

            

Reported by Pylint.

Value 'self.pyarr.flags' is unsubscriptable
Error

Line: 247 Column: 25

                      if len(dims) > 1:
            if self.intent.is_intent('c'):
                assert_(not self.pyarr.flags['FORTRAN'])
                assert_(self.pyarr.flags['CONTIGUOUS'])
                assert_(not self.pyarr_attr[6] & wrap.FORTRAN)
            else:
                assert_(self.pyarr.flags['FORTRAN'])
                assert_(not self.pyarr.flags['CONTIGUOUS'])
                assert_(self.pyarr_attr[6] & wrap.FORTRAN)

            

Reported by Pylint.

Value 'self.pyarr.flags' is unsubscriptable
Error

Line: 250 Column: 25

                              assert_(self.pyarr.flags['CONTIGUOUS'])
                assert_(not self.pyarr_attr[6] & wrap.FORTRAN)
            else:
                assert_(self.pyarr.flags['FORTRAN'])
                assert_(not self.pyarr.flags['CONTIGUOUS'])
                assert_(self.pyarr_attr[6] & wrap.FORTRAN)

        assert_(self.arr_attr[1] == self.pyarr_attr[1])  # nd
        assert_(self.arr_attr[2] == self.pyarr_attr[2])  # dimensions

            

Reported by Pylint.

Value 'self.pyarr.flags' is unsubscriptable
Error

Line: 251 Column: 29

                              assert_(not self.pyarr_attr[6] & wrap.FORTRAN)
            else:
                assert_(self.pyarr.flags['FORTRAN'])
                assert_(not self.pyarr.flags['CONTIGUOUS'])
                assert_(self.pyarr_attr[6] & wrap.FORTRAN)

        assert_(self.arr_attr[1] == self.pyarr_attr[1])  # nd
        assert_(self.arr_attr[2] == self.pyarr_attr[2])  # dimensions
        if self.arr_attr[1] <= 1:

            

Reported by Pylint.

Instance of 'TestSharedMemory' has no 'array' member
Error

Line: 321 Column: 13

                          Array(Type(request.param), dims, intent, obj)

    def test_in_from_2seq(self):
        a = self.array([2], intent.in_, self.num2seq)
        assert_(not a.has_shared_memory())

    def test_in_from_2casttype(self):
        for t in self.type.cast_types():
            obj = np.array(self.num2seq, dtype=t.dtype)

            

Reported by Pylint.

numpy/polynomial/tests/test_classes.py
274 issues
Unable to import 'pytest'
Error

Line: 9 Column: 1

              import operator as op
from numbers import Number

import pytest
import numpy as np
from numpy.polynomial import (
    Polynomial, Legendre, Chebyshev, Laguerre, Hermite, HermiteE)
from numpy.testing import (
    assert_almost_equal, assert_raises, assert_equal, assert_,

            

Reported by Pylint.

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

Line: 35 Column: 10

              #
# helper functions
#
random = np.random.random


def assert_poly_almost_equal(p1, p2, msg=""):
    try:
        assert_(np.all(p1.domain == p2.domain))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 40 Column: 9

              
def assert_poly_almost_equal(p1, p2, msg=""):
    try:
        assert_(np.all(p1.domain == p2.domain))
        assert_(np.all(p1.window == p2.window))
        assert_almost_equal(p1.coef, p2.coef)
    except AssertionError:
        msg = f"Result: {p1}\nTarget: {p2}"
        raise AssertionError(msg)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 41 Column: 9

              def assert_poly_almost_equal(p1, p2, msg=""):
    try:
        assert_(np.all(p1.domain == p2.domain))
        assert_(np.all(p1.window == p2.window))
        assert_almost_equal(p1.coef, p2.coef)
    except AssertionError:
        msg = f"Result: {p1}\nTarget: {p2}"
        raise AssertionError(msg)


            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 45 Column: 9

                      assert_almost_equal(p1.coef, p2.coef)
    except AssertionError:
        msg = f"Result: {p1}\nTarget: {p2}"
        raise AssertionError(msg)


#
# Test conversion methods that depend on combinations of two classes.
#

            

Reported by Pylint.

Redefining name 'Poly2' from outer scope (line 53)
Error

Line: 56 Column: 28

              Poly2 = Poly


def test_conversion(Poly1, Poly2):
    x = np.linspace(0, 1, 10)
    coef = random((3,))

    d1 = Poly1.domain + random((2,))*.25
    w1 = Poly1.window + random((2,))*.25

            

Reported by Pylint.

Redefining name 'Poly1' from outer scope (line 52)
Error

Line: 56 Column: 21

              Poly2 = Poly


def test_conversion(Poly1, Poly2):
    x = np.linspace(0, 1, 10)
    coef = random((3,))

    d1 = Poly1.domain + random((2,))*.25
    w1 = Poly1.window + random((2,))*.25

            

Reported by Pylint.

Redefining name 'Poly1' from outer scope (line 52)
Error

Line: 73 Column: 15

                  assert_almost_equal(p2(x), p1(x))


def test_cast(Poly1, Poly2):
    x = np.linspace(0, 1, 10)
    coef = random((3,))

    d1 = Poly1.domain + random((2,))*.25
    w1 = Poly1.window + random((2,))*.25

            

Reported by Pylint.

Redefining name 'Poly2' from outer scope (line 53)
Error

Line: 73 Column: 22

                  assert_almost_equal(p2(x), p1(x))


def test_cast(Poly1, Poly2):
    x = np.linspace(0, 1, 10)
    coef = random((3,))

    d1 = Poly1.domain + random((2,))*.25
    w1 = Poly1.window + random((2,))*.25

            

Reported by Pylint.

Redefining name 'Poly' from outer scope (line 29)
Error

Line: 95 Column: 19

              #


def test_identity(Poly):
    d = Poly.domain + random((2,))*.25
    w = Poly.window + random((2,))*.25
    x = np.linspace(d[0], d[1], 11)
    p = Poly.identity(domain=d, window=w)
    assert_equal(p.domain, d)

            

Reported by Pylint.

numpy/testing/_private/utils.py
274 issues
Unable to import 'win32pdh'
Error

Line: 166 Column: 9

                      # See http://msdn.microsoft.com/library/en-us/dnperfmo/html/perfmonpt2.asp (dead link)
        # My older explanation for this was that the "AddCounter" process
        # forced the CPU to 100%, but the above makes more sense :)
        import win32pdh
        if format is None:
            format = win32pdh.PDH_FMT_LONG
        path = win32pdh.MakeCounterPath( (machine, object, instance, None,
                                          inum, counter))
        hq = win32pdh.OpenQuery()

            

Reported by Pylint.

Unable to import 'win32pdh'
Error

Line: 185 Column: 9

              
    def memusage(processName="python", instance=0):
        # from win32pdhutil, part of the win32all package
        import win32pdh
        return GetPerformanceAttributes("Process", "Virtual Bytes",
                                        processName, instance,
                                        win32pdh.PDH_FMT_LONG, None)
elif sys.platform[:5] == 'linux':


            

Reported by Pylint.

bad operand type for unary ~: bool_
Error

Line: 784 Column: 22

                              flagged = func_assert_same_pos(x, y, func=isnat, hasval="NaT")

        if flagged.ndim > 0:
            x, y = x[~flagged], y[~flagged]
            # Only do the comparison if actual values are left
            if x.size == 0:
                return
        elif flagged:
            # no sense doing comparison if everything is flagged.

            

Reported by Pylint.

bad operand type for unary ~: bool_
Error

Line: 784 Column: 35

                              flagged = func_assert_same_pos(x, y, func=isnat, hasval="NaT")

        if flagged.ndim > 0:
            x, y = x[~flagged], y[~flagged]
            # Only do the comparison if actual values are left
            if x.size == 0:
                return
        elif flagged:
            # no sense doing comparison if everything is flagged.

            

Reported by Pylint.

bad operand type for unary ~: bool_
Error

Line: 829 Column: 28

                                  # used by assert_allclose (found in np.isclose)
                    # Filter values where the divisor would be zero
                    nonzero = bool_(y != 0)
                    if all(~nonzero):
                        max_rel_error = array(inf)
                    else:
                        max_rel_error = max(error[nonzero] / abs(y[nonzero]))
                    if getattr(error, 'dtype', object_) == object_:
                        remarks.append('Max relative difference: '

            

Reported by Pylint.

Instance of 'suppress_warnings' has no '_orig_showmsg' member
Error

Line: 2276 Column: 17

                              self._orig_show(message, category, filename, lineno,
                                *args, **kwargs)
            else:
                self._orig_showmsg(use_warnmsg)
            return

        if self._forwarding_rule == "once":
            signature = (message.args, category)
        elif self._forwarding_rule == "module":

            

Reported by Pylint.

Instance of 'suppress_warnings' has no '_orig_showmsg' member
Error

Line: 2293 Column: 13

                          self._orig_show(message, category, filename, lineno, *args,
                            **kwargs)
        else:
            self._orig_showmsg(use_warnmsg)

    def __call__(self, func):
        """
        Function decorator to apply certain suppressions to a whole
        function.

            

Reported by Pylint.

Unable to import 'pytest'
Error

Line: 2414 Column: 5

              
def requires_memory(free_bytes):
    """Decorator to skip a test if not enough memory is available"""
    import pytest

    def decorator(func):
        @wraps(func)
        def wrapper(*a, **kw):
            msg = check_free_memory(free_bytes)

            

Reported by Pylint.

Unused array imported from numpy.core
Error

Line: 21 Column: 1

              import pprint

import numpy as np
from numpy.core import(
     intp, float32, empty, arange, array_repr, ndarray, isnat, array)
import numpy.linalg.lapack_lite

from io import StringIO


            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 44 Column: 5

              
class KnownFailureException(Exception):
    '''Raise this exception to mark a test as a known failing test.'''
    pass


KnownFailureTest = KnownFailureException  # backwards compat
verbose = 0


            

Reported by Pylint.