The following issues were found

numpy/polynomial/polyutils.py
55 issues
Unnecessary pass statement
Error

Line: 45 Column: 5

              
class RankWarning(UserWarning):
    """Issued by chebfit when the design matrix is rank deficient."""
    pass

#
# Helper functions to convert inputs to 1-D arrays
#
def trimseq(seq):

            

Reported by Pylint.

Redefining built-in 'pow'
Error

Line: 683 Column: 20

                      return c


def _pow(mul_f, c, pow, maxpower):
    """
    Helper function used to implement the ``<type>pow`` functions.

    Parameters
    ----------

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 711 Column: 13

                      # This can be made more efficient by using powers of two
        # in the usual way.
        prd = c
        for i in range(2, power + 1):
            prd = mul_f(prd, c)
        return prd


def _deprecate_as_int(x, desc):

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 71 Column: 5

                  Do not lose the type info if the sequence contains unknown objects.

    """
    if len(seq) == 0:
        return seq
    else:
        for i in range(len(seq) - 1, -1, -1):
            if seq[i] != 0:
                break

            

Reported by Pylint.

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

Line: 140 Column: 13

              
    if any(a.dtype == np.dtype(object) for a in arrays):
        ret = []
        for a in arrays:
            if a.dtype != np.dtype(object):
                tmp = np.empty(len(a), dtype=np.dtype(object))
                tmp[:] = a[:]
                ret.append(tmp)
            else:

            

Reported by Pylint.

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

Line: 150 Column: 9

                  else:
        try:
            dtype = np.common_type(*arrays)
        except Exception as e:
            raise ValueError("Coefficient arrays have no common type") from e
        ret = [np.array(a, copy=True, dtype=dtype) for a in arrays]
    return ret



            

Reported by Pylint.

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

Line: 156 Column: 1

                  return ret


def trimcoef(c, tol=0):
    """
    Remove "small" "trailing" coefficients from a polynomial.

    "Small" means "small in absolute value" and is controlled by the
    parameter `tol`; "trailing" means highest order coefficient(s), e.g., in

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 205 Column: 5

              
    [c] = as_series([c])
    [ind] = np.nonzero(np.abs(c) > tol)
    if len(ind) == 0:
        return c[:1]*0
    else:
        return c[:ind[-1] + 1].copy()

def getdomain(x):

            

Reported by Pylint.

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

Line: 210 Column: 1

                  else:
        return c[:ind[-1] + 1].copy()

def getdomain(x):
    """
    Return a domain suitable for given abscissae.

    Find a domain suitable for a polynomial or Chebyshev series
    defined at the values supplied.

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 249 Column: 5

              
    """
    [x] = as_series([x], trim=False)
    if x.dtype.char in np.typecodes['Complex']:
        rmin, rmax = x.real.min(), x.real.max()
        imin, imax = x.imag.min(), x.imag.max()
        return np.array((complex(rmin, imin), complex(rmax, imax)))
    else:
        return np.array((x.min(), x.max()))

            

Reported by Pylint.

setup.py
55 issues
Unused import numpy.distutils.command.sdist
Error

Line: 79 Column: 1

              # Its presence/absence is used in subclassing setup in numpy/distutils/core.py.
# However, we need to run the distutils version of sdist, so import that first
# so that it is in sys.modules
import numpy.distutils.command.sdist
import setuptools

# Initialize cmdclass from versioneer
from numpy.distutils.core import numpy_cmdclass
cmdclass = versioneer.get_cmdclass(numpy_cmdclass)

            

Reported by Pylint.

Unused import setuptools
Error

Line: 80 Column: 1

              # However, we need to run the distutils version of sdist, so import that first
# so that it is in sys.modules
import numpy.distutils.command.sdist
import setuptools

# Initialize cmdclass from versioneer
from numpy.distutils.core import numpy_cmdclass
cmdclass = versioneer.get_cmdclass(numpy_cmdclass)


            

Reported by Pylint.

Attribute 'bsd_text' defined outside __init__
Error

Line: 162 Column: 13

                  def __enter__(self):
        """Concatenate files and remove LICENSES_bundled.txt"""
        with open(self.f1, 'r') as f1:
            self.bsd_text = f1.read()

        with open(self.f1, 'a') as f1:
            with open(self.f2, 'r') as f2:
                self.bundled_text = f2.read()
                f1.write('\n\n')

            

Reported by Pylint.

Attribute 'bundled_text' defined outside __init__
Error

Line: 166 Column: 17

              
        with open(self.f1, 'a') as f1:
            with open(self.f2, 'r') as f2:
                self.bundled_text = f2.read()
                f1.write('\n\n')
                f1.write(self.bundled_text)

    def __exit__(self, exception_type, exception_value, traceback):
        """Restore content of both files"""

            

Reported by Pylint.

Using subprocess.run without explicitly set `check` is not recommended.
Error

Line: 203 Column: 15

                          return False

        # will print something like '4.2.1\n'
        out = subprocess.run([cc, '-dumpversion'], stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, universal_newlines=True)
        # -std=c99 is default from this version on
        if LooseVersion(out.stdout) >= LooseVersion('5.0'):
            return False
        return True

            

Reported by Pylint.

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

Line: 22 Column: 1

              """
DOCLINES = (__doc__ or '').split("\n")

import os
import sys
import subprocess
import textwrap
import warnings
import builtins

            

Reported by Pylint.

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

Line: 23 Column: 1

              DOCLINES = (__doc__ or '').split("\n")

import os
import sys
import subprocess
import textwrap
import warnings
import builtins
import re

            

Reported by Pylint.

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

Line: 24 Column: 1

              
import os
import sys
import subprocess
import textwrap
import warnings
import builtins
import re


            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 24
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              
import os
import sys
import subprocess
import textwrap
import warnings
import builtins
import re


            

Reported by Bandit.

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

Line: 25 Column: 1

              import os
import sys
import subprocess
import textwrap
import warnings
import builtins
import re



            

Reported by Pylint.

numpy/lib/shape_base.py
54 issues
Unused argument 'axis'
Error

Line: 52 Column: 47

                  return tuple(fancy_index)


def _take_along_axis_dispatcher(arr, indices, axis):
    return (arr, indices)


@array_function_dispatch(_take_along_axis_dispatcher)
def take_along_axis(arr, indices, axis):

            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 173 Column: 54

                  return arr[_make_along_axis_idx(arr_shape, indices, axis)]


def _put_along_axis_dispatcher(arr, indices, values, axis):
    return (arr, indices, values)


@array_function_dispatch(_put_along_axis_dispatcher)
def put_along_axis(arr, indices, values, axis):

            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 263 Column: 42

                  arr[_make_along_axis_idx(arr_shape, indices, axis)] = values


def _apply_along_axis_dispatcher(func1d, axis, arr, *args, **kwargs):
    return (arr,)


@array_function_dispatch(_apply_along_axis_dispatcher)
def apply_along_axis(func1d, axis, arr, *args, **kwargs):

            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 263 Column: 1

                  arr[_make_along_axis_idx(arr_shape, indices, axis)] = values


def _apply_along_axis_dispatcher(func1d, axis, arr, *args, **kwargs):
    return (arr,)


@array_function_dispatch(_apply_along_axis_dispatcher)
def apply_along_axis(func1d, axis, arr, *args, **kwargs):

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 263 Column: 1

                  arr[_make_along_axis_idx(arr_shape, indices, axis)] = values


def _apply_along_axis_dispatcher(func1d, axis, arr, *args, **kwargs):
    return (arr,)


@array_function_dispatch(_apply_along_axis_dispatcher)
def apply_along_axis(func1d, axis, arr, *args, **kwargs):

            

Reported by Pylint.

Unused argument 'func1d'
Error

Line: 263 Column: 34

                  arr[_make_along_axis_idx(arr_shape, indices, axis)] = values


def _apply_along_axis_dispatcher(func1d, axis, arr, *args, **kwargs):
    return (arr,)


@array_function_dispatch(_apply_along_axis_dispatcher)
def apply_along_axis(func1d, axis, arr, *args, **kwargs):

            

Reported by Pylint.

Unused variable 'e'
Error

Line: 375 Column: 5

                  # invoke the function on the first item
    try:
        ind0 = next(inds)
    except StopIteration as e:
        raise ValueError(
            'Cannot apply_along_axis when any iteration dimensions are 0'
        ) from None
    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))


            

Reported by Pylint.

Unused argument 'func'
Error

Line: 417 Column: 33

                      return res.__array_wrap__(out_arr)


def _apply_over_axes_dispatcher(func, a, axes):
    return (a,)


@array_function_dispatch(_apply_over_axes_dispatcher)
def apply_over_axes(func, a, axes):

            

Reported by Pylint.

Unused argument 'axes'
Error

Line: 417 Column: 42

                      return res.__array_wrap__(out_arr)


def _apply_over_axes_dispatcher(func, a, axes):
    return (a,)


@array_function_dispatch(_apply_over_axes_dispatcher)
def apply_over_axes(func, a, axes):

            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 508 Column: 32

                  return val


def _expand_dims_dispatcher(a, axis):
    return (a,)


@array_function_dispatch(_expand_dims_dispatcher)
def expand_dims(a, axis):

            

Reported by Pylint.

numpy/f2py/cfuncs.py
54 issues
Attempted relative import beyond top-level package
Error

Line: 20 Column: 1

              import sys
import copy

from . import __version__

f2py_version = __version__.version
errmess = sys.stderr.write

##################### Definitions ##################

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 1327 Column: 5

              

def buildcfuncs():
    from .capi_maps import c2capi_map
    for k in c2capi_map.keys():
        m = 'pyarr_from_p_%s1' % k
        cppmacros[
            m] = '#define %s(v) (PyArray_SimpleNewFromData(0,NULL,%s,(char *)v))' % (m, c2capi_map[k])
    k = 'string'

            

Reported by Pylint.

XXX: Note that CNUMFROMARROBJ is identical with NUMFROMARROBJ
Error

Line: 415 Column: 3

              #         return 1;\\
#     }
# """
# XXX: Note that CNUMFROMARROBJ is identical with NUMFROMARROBJ
# cppmacros['CNUMFROMARROBJ']="""\
# define CNUMFROMARROBJ(typenum,ctype) \\
#     if (PyArray_Check(obj)) arr = (PyArrayObject *)obj;\\
#     else arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\
#     if (arr) {\\

            

Reported by Pylint.

Too many lines in module (1440/1000)
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
"""

C declarations, CPP macros, and C functions for f2py2e.
Only required declarations/macros/functions will be used.

Copyright 1999,2000 Pearu Peterson all rights reserved,
Pearu Peterson <pearu@ioc.ee>
Permission to use, modify, and distribute this software is given under the

            

Reported by Pylint.

Line too long (118/100)
Error

Line: 314 Column: 1

                  'pyobj_from_float1'] = '#define pyobj_from_float1(v) (PyFloat_FromDouble(v))'
needs['pyobj_from_complex_long_double1'] = ['complex_long_double']
cppmacros[
    'pyobj_from_complex_long_double1'] = '#define pyobj_from_complex_long_double1(v) (PyComplex_FromDoubles(v.r,v.i))'
needs['pyobj_from_complex_double1'] = ['complex_double']
cppmacros[
    'pyobj_from_complex_double1'] = '#define pyobj_from_complex_double1(v) (PyComplex_FromDoubles(v.r,v.i))'
needs['pyobj_from_complex_float1'] = ['complex_float']
cppmacros[

            

Reported by Pylint.

Line too long (108/100)
Error

Line: 317 Column: 1

                  'pyobj_from_complex_long_double1'] = '#define pyobj_from_complex_long_double1(v) (PyComplex_FromDoubles(v.r,v.i))'
needs['pyobj_from_complex_double1'] = ['complex_double']
cppmacros[
    'pyobj_from_complex_double1'] = '#define pyobj_from_complex_double1(v) (PyComplex_FromDoubles(v.r,v.i))'
needs['pyobj_from_complex_float1'] = ['complex_float']
cppmacros[
    'pyobj_from_complex_float1'] = '#define pyobj_from_complex_float1(v) (PyComplex_FromDoubles(v.r,v.i))'
needs['pyobj_from_string1'] = ['string']
cppmacros[

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 320 Column: 1

                  'pyobj_from_complex_double1'] = '#define pyobj_from_complex_double1(v) (PyComplex_FromDoubles(v.r,v.i))'
needs['pyobj_from_complex_float1'] = ['complex_float']
cppmacros[
    'pyobj_from_complex_float1'] = '#define pyobj_from_complex_float1(v) (PyComplex_FromDoubles(v.r,v.i))'
needs['pyobj_from_string1'] = ['string']
cppmacros[
    'pyobj_from_string1'] = '#define pyobj_from_string1(v) (PyUnicode_FromString((char *)v))'
needs['pyobj_from_string1size'] = ['string']
cppmacros[

            

Reported by Pylint.

Line too long (117/100)
Error

Line: 326 Column: 1

                  'pyobj_from_string1'] = '#define pyobj_from_string1(v) (PyUnicode_FromString((char *)v))'
needs['pyobj_from_string1size'] = ['string']
cppmacros[
    'pyobj_from_string1size'] = '#define pyobj_from_string1size(v,len) (PyUnicode_FromStringAndSize((char *)v, len))'
needs['TRYPYARRAYTEMPLATE'] = ['PRINTPYOBJERR']
cppmacros['TRYPYARRAYTEMPLATE'] = """\
/* New SciPy */
#define TRYPYARRAYTEMPLATECHAR case NPY_STRING: *(char *)(PyArray_DATA(arr))=*v; break;
#define TRYPYARRAYTEMPLATELONG case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break;

            

Reported by Pylint.

Line too long (111/100)
Error

Line: 556 Column: 1

              # define CHECKDIMS(dims,rank) \\
#     for (int i=0;i<(rank);i++)\\
#         if (dims[i]<0) {\\
#             fprintf(stderr,\"Unspecified array argument requires a complete dimension specification.\\n\");\\
#             goto capi_fail;\\
#         }
# """
cppmacros[
    'ARRSIZE'] = '#define ARRSIZE(dims,rank) (_PyArray_multiply_list(dims,rank))'

            

Reported by Pylint.

Line too long (128/100)
Error

Line: 1157 Column: 1

              
needs['try_pyarr_from_char'] = ['pyobj_from_char1', 'TRYPYARRAYTEMPLATE']
cfuncs[
    'try_pyarr_from_char'] = 'static int try_pyarr_from_char(PyObject* obj,char* v) {\n    TRYPYARRAYTEMPLATE(char,\'c\');\n}\n'
needs['try_pyarr_from_signed_char'] = ['TRYPYARRAYTEMPLATE', 'unsigned_char']
cfuncs[
    'try_pyarr_from_unsigned_char'] = 'static int try_pyarr_from_unsigned_char(PyObject* obj,unsigned_char* v) {\n    TRYPYARRAYTEMPLATE(unsigned_char,\'b\');\n}\n'
needs['try_pyarr_from_signed_char'] = ['TRYPYARRAYTEMPLATE', 'signed_char']
cfuncs[

            

Reported by Pylint.

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

Line: 9 Column: 11

              
SEED_NONE = None
SEED_INT = 4579435749574957634658964293569
SEED_ARR: np.ndarray[Any, np.dtype[np.int64]] = np.array([1, 2, 3, 4], dtype=np.int64)
SEED_ARRLIKE: List[int] = [1, 2, 3, 4]
SEED_SEED_SEQ: np.random.SeedSequence = np.random.SeedSequence(0)
SEED_MT19937: np.random.MT19937 = np.random.MT19937(0)
SEED_PCG64: np.random.PCG64 = np.random.PCG64(0)
SEED_PHILOX: np.random.Philox = np.random.Philox(0)

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 73 Column: 12

              
def_gen: np.random.Generator = np.random.default_rng()

D_arr_0p1: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.1])
D_arr_0p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.5])
D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 74 Column: 12

              def_gen: np.random.Generator = np.random.default_rng()

D_arr_0p1: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.1])
D_arr_0p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.5])
D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)
D_arr_like_0p1: List[float] = [0.1]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 75 Column: 12

              
D_arr_0p1: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.1])
D_arr_0p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.5])
D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)
D_arr_like_0p1: List[float] = [0.1]
D_arr_like_0p5: List[float] = [0.5]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 76 Column: 12

              D_arr_0p1: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.1])
D_arr_0p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.5])
D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)
D_arr_like_0p1: List[float] = [0.1]
D_arr_like_0p5: List[float] = [0.5]
D_arr_like_0p9: List[float] = [0.9]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 77 Column: 11

              D_arr_0p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.5])
D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)
D_arr_like_0p1: List[float] = [0.1]
D_arr_like_0p5: List[float] = [0.5]
D_arr_like_0p9: List[float] = [0.9]
D_arr_like_1p5: List[float] = [1.5]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 78 Column: 11

              D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)
D_arr_like_0p1: List[float] = [0.1]
D_arr_like_0p5: List[float] = [0.5]
D_arr_like_0p9: List[float] = [0.9]
D_arr_like_1p5: List[float] = [1.5]
I_arr_like_10: List[int] = [10]

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 86 Column: 7

              I_arr_like_10: List[int] = [10]
I_arr_like_20: List[int] = [20]
D_2D_like: List[List[float]] = [[1, 2], [2, 3], [3, 4], [4, 5.1]]
D_2D: np.ndarray[Any, np.dtype[np.float64]] = np.array(D_2D_like)

S_out: np.ndarray[Any, np.dtype[np.float32]] = np.empty(1, dtype=np.float32)
D_out: np.ndarray[Any, np.dtype[np.float64]] = np.empty(1)

def_gen.standard_normal()

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 88 Column: 8

              D_2D_like: List[List[float]] = [[1, 2], [2, 3], [3, 4], [4, 5.1]]
D_2D: np.ndarray[Any, np.dtype[np.float64]] = np.array(D_2D_like)

S_out: np.ndarray[Any, np.dtype[np.float32]] = np.empty(1, dtype=np.float32)
D_out: np.ndarray[Any, np.dtype[np.float64]] = np.empty(1)

def_gen.standard_normal()
def_gen.standard_normal(dtype=np.float32)
def_gen.standard_normal(dtype="float32")

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 89 Column: 8

              D_2D: np.ndarray[Any, np.dtype[np.float64]] = np.array(D_2D_like)

S_out: np.ndarray[Any, np.dtype[np.float32]] = np.empty(1, dtype=np.float32)
D_out: np.ndarray[Any, np.dtype[np.float64]] = np.empty(1)

def_gen.standard_normal()
def_gen.standard_normal(dtype=np.float32)
def_gen.standard_normal(dtype="float32")
def_gen.standard_normal(dtype="double")

            

Reported by Pylint.

numpy/typing/tests/data/pass/mod.py
54 issues
Statement seems to have no effect
Error

Line: 26 Column: 1

              
# Time structures

td % td
td % AR2
AR2 % td

divmod(td, td)
divmod(td, AR2)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 27 Column: 1

              # Time structures

td % td
td % AR2
AR2 % td

divmod(td, td)
divmod(td, AR2)
divmod(AR2, td)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 28 Column: 1

              
td % td
td % AR2
AR2 % td

divmod(td, td)
divmod(td, AR2)
divmod(AR2, td)


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 36 Column: 1

              
# Bool

b_ % b
b_ % i
b_ % f
b_ % b_
b_ % i8
b_ % u8

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 37 Column: 1

              # Bool

b_ % b
b_ % i
b_ % f
b_ % b_
b_ % i8
b_ % u8
b_ % f8

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 38 Column: 1

              
b_ % b
b_ % i
b_ % f
b_ % b_
b_ % i8
b_ % u8
b_ % f8
b_ % AR

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 39 Column: 1

              b_ % b
b_ % i
b_ % f
b_ % b_
b_ % i8
b_ % u8
b_ % f8
b_ % AR


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 40 Column: 1

              b_ % i
b_ % f
b_ % b_
b_ % i8
b_ % u8
b_ % f8
b_ % AR

divmod(b_, b)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 41 Column: 1

              b_ % f
b_ % b_
b_ % i8
b_ % u8
b_ % f8
b_ % AR

divmod(b_, b)
divmod(b_, i)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 42 Column: 1

              b_ % b_
b_ % i8
b_ % u8
b_ % f8
b_ % AR

divmod(b_, b)
divmod(b_, i)
divmod(b_, f)

            

Reported by Pylint.

numpy/lib/type_check.py
53 issues
Attempted relative import beyond top-level package
Error

Line: 16 Column: 1

              from numpy.core.numeric import asarray, asanyarray, isnan, zeros
from numpy.core.overrides import set_module
from numpy.core import overrides
from .ufunclike import isneginf, isposinf


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


            

Reported by Pylint.

Unused argument 'dtype'
Error

Line: 80 Column: 29

                  return min(intersection, key=_typecodes_by_elsize.index)


def _asfarray_dispatcher(a, dtype=None):
    return (a,)


@array_function_dispatch(_asfarray_dispatcher)
def asfarray(a, dtype=_nx.float_):

            

Reported by Pylint.

Unused argument 'posinf'
Error

Line: 400 Column: 52

                  return f.max, f.min


def _nan_to_num_dispatcher(x, copy=None, nan=None, posinf=None, neginf=None):
    return (x,)


@array_function_dispatch(_nan_to_num_dispatcher)
def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):

            

Reported by Pylint.

Unused argument 'copy'
Error

Line: 400 Column: 31

                  return f.max, f.min


def _nan_to_num_dispatcher(x, copy=None, nan=None, posinf=None, neginf=None):
    return (x,)


@array_function_dispatch(_nan_to_num_dispatcher)
def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):

            

Reported by Pylint.

Unused argument 'nan'
Error

Line: 400 Column: 42

                  return f.max, f.min


def _nan_to_num_dispatcher(x, copy=None, nan=None, posinf=None, neginf=None):
    return (x,)


@array_function_dispatch(_nan_to_num_dispatcher)
def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):

            

Reported by Pylint.

Unused argument 'neginf'
Error

Line: 400 Column: 65

                  return f.max, f.min


def _nan_to_num_dispatcher(x, copy=None, nan=None, posinf=None, neginf=None):
    return (x,)


@array_function_dispatch(_nan_to_num_dispatcher)
def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):

            

Reported by Pylint.

Redefining name 'iscomplex' from outer scope (line 211)
Error

Line: 506 Column: 5

                  if not issubclass(xtype, _nx.inexact):
        return x[()] if isscalar else x

    iscomplex = issubclass(xtype, _nx.complexfloating)

    dest = (x.real, x.imag) if iscomplex else (x,)
    maxf, minf = _getmaxmin(x.real.dtype)
    if posinf is not None:
        maxf = posinf

            

Reported by Pylint.

Unused argument 'tol'
Error

Line: 525 Column: 34

              
#-----------------------------------------------------------------------------

def _real_if_close_dispatcher(a, tol=None):
    return (a,)


@array_function_dispatch(_real_if_close_dispatcher)
def real_if_close(a, tol=100):

            

Reported by Pylint.

Constant name "_typecodes_by_elsize" doesn't conform to UPPER_CASE naming style
Error

Line: 23 Column: 1

                  overrides.array_function_dispatch, module='numpy')


_typecodes_by_elsize = 'GDFgdfQqLlIiHhBb?'


@set_module('numpy')
def mintypecode(typechars, typeset='GDFgdf', default='d'):
    """

            

Reported by Pylint.

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

Line: 80 Column: 1

                  return min(intersection, key=_typecodes_by_elsize.index)


def _asfarray_dispatcher(a, dtype=None):
    return (a,)


@array_function_dispatch(_asfarray_dispatcher)
def asfarray(a, dtype=_nx.float_):

            

Reported by Pylint.

numpy/f2py/tests/test_crackfortran.py
53 issues
Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              import numpy as np
from numpy.testing import assert_array_equal, assert_equal
from numpy.f2py.crackfortran import markinnerspaces
from . import util
from numpy.f2py import crackfortran
import textwrap


class TestNoSpace(util.F2PyTest):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
from numpy.testing import assert_array_equal, assert_equal
from numpy.f2py.crackfortran import markinnerspaces
from . import util
from numpy.f2py import crackfortran
import textwrap


class TestNoSpace(util.F2PyTest):

            

Reported by Pylint.

third party import "from numpy.f2py import crackfortran" should be placed before "from . import util"
Error

Line: 5 Column: 1

              from numpy.testing import assert_array_equal, assert_equal
from numpy.f2py.crackfortran import markinnerspaces
from . import util
from numpy.f2py import crackfortran
import textwrap


class TestNoSpace(util.F2PyTest):
    # issue gh-15035: add handling for endsubroutine, endfunction with no space

            

Reported by Pylint.

standard import "import textwrap" should be placed before "import numpy as np"
Error

Line: 6 Column: 1

              from numpy.f2py.crackfortran import markinnerspaces
from . import util
from numpy.f2py import crackfortran
import textwrap


class TestNoSpace(util.F2PyTest):
    # issue gh-15035: add handling for endsubroutine, endfunction with no space
    # between "end" and the block name

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 9 Column: 1

              import textwrap


class TestNoSpace(util.F2PyTest):
    # issue gh-15035: add handling for endsubroutine, endfunction with no space
    # between "end" and the block name
    code = """
        subroutine subb(k)
          real(8), intent(inout) :: k(:)

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              import textwrap


class TestNoSpace(util.F2PyTest):
    # issue gh-15035: add handling for endsubroutine, endfunction with no space
    # between "end" and the block name
    code = """
        subroutine subb(k)
          real(8), intent(inout) :: k(:)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 5

                      endfunction
    """

    def test_module(self):
        k = np.array([1, 2, 3], dtype=np.float64)
        w = np.array([1, 2, 3], dtype=np.float64)
        self.module.subb(k)
        assert_array_equal(k, w + 1)
        self.module.subc([w, k])

            

Reported by Pylint.

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

Line: 33 Column: 9

              
    def test_module(self):
        k = np.array([1, 2, 3], dtype=np.float64)
        w = np.array([1, 2, 3], dtype=np.float64)
        self.module.subb(k)
        assert_array_equal(k, w + 1)
        self.module.subc([w, k])
        assert_array_equal(k, w + 1)
        assert self.module.t0(23) == b'2'

            

Reported by Pylint.

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

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

                      assert_array_equal(k, w + 1)
        self.module.subc([w, k])
        assert_array_equal(k, w + 1)
        assert self.module.t0(23) == b'2'


class TestPublicPrivate():
    def test_defaultPrivate(self, tmp_path):
        f_path = tmp_path / "mod.f90"

            

Reported by Bandit.

Missing class docstring
Error

Line: 41 Column: 1

                      assert self.module.t0(23) == b'2'


class TestPublicPrivate():
    def test_defaultPrivate(self, tmp_path):
        f_path = tmp_path / "mod.f90"
        with f_path.open('w') as ff:
            ff.write(textwrap.dedent("""\
            module foo

            

Reported by Pylint.

numpy/core/tests/test__exceptions.py
53 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              
import pickle

import pytest
import numpy as np

_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError


            

Reported by Pylint.

Access to a protected member _ArrayMemoryError of a client class
Error

Line: 10 Column: 21

              import pytest
import numpy as np

_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError

class TestArrayMemoryError:
    def test_pickling(self):
        """ Test that _ArrayMemoryError can be pickled """

            

Reported by Pylint.

Access to a protected member _exceptions of a client class
Error

Line: 10 Column: 21

              import pytest
import numpy as np

_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError

class TestArrayMemoryError:
    def test_pickling(self):
        """ Test that _ArrayMemoryError can be pickled """

            

Reported by Pylint.

Access to a protected member _exceptions of a client class
Error

Line: 11 Column: 21

              import numpy as np

_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError

class TestArrayMemoryError:
    def test_pickling(self):
        """ Test that _ArrayMemoryError can be pickled """
        error = _ArrayMemoryError((1023,), np.dtype(np.uint8))

            

Reported by Pylint.

Access to a protected member _UFuncNoLoopError of a client class
Error

Line: 11 Column: 21

              import numpy as np

_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError

class TestArrayMemoryError:
    def test_pickling(self):
        """ Test that _ArrayMemoryError can be pickled """
        error = _ArrayMemoryError((1023,), np.dtype(np.uint8))

            

Reported by Pylint.

Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
Security blacklist

Line: 17
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b301-pickle

                  def test_pickling(self):
        """ Test that _ArrayMemoryError can be pickled """
        error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
        res = pickle.loads(pickle.dumps(error))
        assert res._total_size == error._total_size

    def test_str(self):
        e = _ArrayMemoryError((1023,), np.dtype(np.uint8))
        str(e)  # not crashing is enough

            

Reported by Bandit.

Access to a protected member _total_size of a client class
Error

Line: 18 Column: 16

                      """ Test that _ArrayMemoryError can be pickled """
        error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
        res = pickle.loads(pickle.dumps(error))
        assert res._total_size == error._total_size

    def test_str(self):
        e = _ArrayMemoryError((1023,), np.dtype(np.uint8))
        str(e)  # not crashing is enough


            

Reported by Pylint.

Access to a protected member _total_size of a client class
Error

Line: 18 Column: 35

                      """ Test that _ArrayMemoryError can be pickled """
        error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
        res = pickle.loads(pickle.dumps(error))
        assert res._total_size == error._total_size

    def test_str(self):
        e = _ArrayMemoryError((1023,), np.dtype(np.uint8))
        str(e)  # not crashing is enough


            

Reported by Pylint.

Access to a protected member _size_to_string of a client class
Error

Line: 27 Column: 13

                  # testing these properties is easier than testing the full string repr
    def test__size_to_string(self):
        """ Test e._size_to_string """
        f = _ArrayMemoryError._size_to_string
        Ki = 1024
        assert f(0) == '0 bytes'
        assert f(1) == '1 bytes'
        assert f(1023) == '1023 bytes'
        assert f(Ki) == '1.00 KiB'

            

Reported by Pylint.

Access to a protected member _total_size of a client class
Error

Line: 50 Column: 16

                  def test__total_size(self):
        """ Test e._total_size """
        e = _ArrayMemoryError((1,), np.dtype(np.uint8))
        assert e._total_size == 1

        e = _ArrayMemoryError((2, 4), np.dtype((np.uint64, 16)))
        assert e._total_size == 1024



            

Reported by Pylint.

numpy/lib/tests/test__iotools.py
53 issues
Using deprecated method assert_()
Error

Line: 131 Column: 9

                      "Test validate no names"
        namelist = None
        validator = NameValidator()
        assert_(validator(namelist) is None)
        assert_equal(validator(namelist, nbfields=3), ['f0', 'f1', 'f2'])

# -----------------------------------------------------------------------------



            

Reported by Pylint.

Access to a protected member _status of a client class
Error

Line: 147 Column: 22

                  def test_creation(self):
        "Test creation of a StringConverter"
        converter = StringConverter(int, -99999)
        assert_equal(converter._status, 1)
        assert_equal(converter.default, -99999)

    def test_upgrade(self):
        "Tests the upgrade method."


            

Reported by Pylint.

Access to a protected member _status of a client class
Error

Line: 154 Column: 22

                      "Tests the upgrade method."

        converter = StringConverter()
        assert_equal(converter._status, 0)

        # test int
        assert_equal(converter.upgrade('0'), 0)
        assert_equal(converter._status, 1)


            

Reported by Pylint.

Access to a protected member _status of a client class
Error

Line: 158 Column: 22

              
        # test int
        assert_equal(converter.upgrade('0'), 0)
        assert_equal(converter._status, 1)

        # On systems where long defaults to 32-bit, the statuses will be
        # offset by one, so we check for this here.
        import numpy.core.numeric as nx
        status_offset = int(nx.dtype(nx.int_).itemsize < nx.dtype(nx.int64).itemsize)

            

Reported by Pylint.

Access to a protected member _status of a client class
Error

Line: 167 Column: 22

              
        # test int > 2**32
        assert_equal(converter.upgrade('17179869184'), 17179869184)
        assert_equal(converter._status, 1 + status_offset)

        # test float
        assert_allclose(converter.upgrade('0.'), 0.0)
        assert_equal(converter._status, 2 + status_offset)


            

Reported by Pylint.

Access to a protected member _status of a client class
Error

Line: 171 Column: 22

              
        # test float
        assert_allclose(converter.upgrade('0.'), 0.0)
        assert_equal(converter._status, 2 + status_offset)

        # test complex
        assert_equal(converter.upgrade('0j'), complex('0j'))
        assert_equal(converter._status, 3 + status_offset)


            

Reported by Pylint.

Access to a protected member _status of a client class
Error

Line: 175 Column: 22

              
        # test complex
        assert_equal(converter.upgrade('0j'), complex('0j'))
        assert_equal(converter._status, 3 + status_offset)

        # test str
        # note that the longdouble type has been skipped, so the
        # _status increases by 2. Everything should succeed with
        # unicode conversion (8).

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 183 Column: 13

                      # unicode conversion (8).
        for s in ['a', b'a']:
            res = converter.upgrade(s)
            assert_(type(res) is str)
            assert_equal(res, 'a')
            assert_equal(converter._status, 8 + status_offset)

    def test_missing(self):
        "Tests the use of missing values."

            

Reported by Pylint.

Access to a protected member _status of a client class
Error

Line: 185 Column: 26

                          res = converter.upgrade(s)
            assert_(type(res) is str)
            assert_equal(res, 'a')
            assert_equal(converter._status, 8 + status_offset)

    def test_missing(self):
        "Tests the use of missing values."
        converter = StringConverter(missing_values=('missing',
                                                    'missed'))

            

Reported by Pylint.

Access to a protected member _mapper of a client class
Error

Line: 204 Column: 28

                  def test_upgrademapper(self):
        "Tests updatemapper"
        dateparser = _bytes_to_date
        _original_mapper = StringConverter._mapper[:]
        try:
            StringConverter.upgrade_mapper(dateparser, date(2000, 1, 1))
            convert = StringConverter(dateparser, date(2000, 1, 1))
            test = convert('2001-01-01')
            assert_equal(test, date(2001, 1, 1))

            

Reported by Pylint.