The following issues were found

numpy/polynomial/hermite_e.py
129 issues
Attempted relative import beyond top-level package
Error

Line: 82 Column: 1

              import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index

from . import polyutils as pu
from ._polybase import ABCPolyBase

__all__ = [
    'hermezero', 'hermeone', 'hermex', 'hermedomain', 'hermeline',
    'hermeadd', 'hermesub', 'hermemulx', 'hermemul', 'hermediv',

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 83 Column: 1

              from numpy.core.multiarray import normalize_axis_index

from . import polyutils as pu
from ._polybase import ABCPolyBase

__all__ = [
    'hermezero', 'hermeone', 'hermex', 'hermedomain', 'hermeline',
    'hermeadd', 'hermesub', 'hermemulx', 'hermemul', 'hermediv',
    'hermepow', 'hermeval', 'hermeder', 'hermeint', 'herme2poly',

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 181 Column: 5

                  array([0.,  1.,  2.,  3.])

    """
    from .polynomial import polyadd, polysub, polymulx

    [c] = pu.as_series([c])
    n = len(c)
    if n == 1:
        return c

            

Reported by Pylint.

Access to a protected member _fromroots of a client class
Error

Line: 309 Column: 12

                  array([0.+0.j, 0.+0.j])

    """
    return pu._fromroots(hermeline, hermemul, roots)


def hermeadd(c1, c2):
    """
    Add one Hermite series to another.

            

Reported by Pylint.

Access to a protected member _add of a client class
Error

Line: 349 Column: 12

                  array([2.,  4.,  6.,  4.])

    """
    return pu._add(c1, c2)


def hermesub(c1, c2):
    """
    Subtract one Hermite series from another.

            

Reported by Pylint.

Access to a protected member _sub of a client class
Error

Line: 389 Column: 12

                  array([0., 0., 0., 4.])

    """
    return pu._sub(c1, c2)


def hermemulx(c):
    """Multiply a Hermite series by x.


            

Reported by Pylint.

Access to a protected member _div of a client class
Error

Line: 550 Column: 12

                  (array([1., 2., 3.]), array([1., 2.]))

    """
    return pu._div(hermemul, c1, c2)


def hermepow(c, pow, maxpower=16):
    """Raise a Hermite series to a power.


            

Reported by Pylint.

Redefining built-in 'pow'
Error

Line: 553 Column: 17

                  return pu._div(hermemul, c1, c2)


def hermepow(c, pow, maxpower=16):
    """Raise a Hermite series to a power.

    Returns the Hermite series `c` raised to the power `pow`. The
    argument `c` is a sequence of coefficients ordered from low to high.
    i.e., [1,2,3] is the series  ``P_0 + 2*P_1 + 3*P_2.``

            

Reported by Pylint.

Access to a protected member _pow of a client class
Error

Line: 587 Column: 12

                  array([23.,  28.,  46.,  12.,   9.])

    """
    return pu._pow(hermemul, c, pow, maxpower)


def hermeder(c, m=1, scl=1, axis=0):
    """
    Differentiate a Hermite_e series.

            

Reported by Pylint.

Access to a protected member _deprecate_as_int of a client class
Error

Line: 648 Column: 11

                  c = np.array(c, ndmin=1, copy=True)
    if c.dtype.char in '?bBhHiIlLqQpP':
        c = c.astype(np.double)
    cnt = pu._deprecate_as_int(m, "the order of derivation")
    iaxis = pu._deprecate_as_int(axis, "the axis")
    if cnt < 0:
        raise ValueError("The order of derivation must be non-negative")
    iaxis = normalize_axis_index(iaxis, c.ndim)


            

Reported by Pylint.

numpy/lib/tests/test_polynomial.py
126 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

                  assert_array_almost_equal, assert_raises, assert_allclose
    )

import pytest

# `poly1d` has some support for `bool_` and `timedelta64`,
# but it is limited and they are therefore excluded here
TYPE_CODES = np.typecodes["AllInteger"] + np.typecodes["AllFloat"] + "O"


            

Reported by Pylint.

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

Line: 117 Column: 9

              
        assert_(np.iscomplexobj(np.poly([1j, -1.0000001j])))

        np.random.seed(42)
        a = np.random.randn(100) + 1j*np.random.randn(100)
        assert_(np.isrealobj(np.poly(np.concatenate((a, np.conjugate(a))))))

    def test_roots(self):
        assert_array_equal(np.roots([1, 0, 0]), [0, 0])

            

Reported by Pylint.

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

Line: 118 Column: 39

                      assert_(np.iscomplexobj(np.poly([1j, -1.0000001j])))

        np.random.seed(42)
        a = np.random.randn(100) + 1j*np.random.randn(100)
        assert_(np.isrealobj(np.poly(np.concatenate((a, np.conjugate(a))))))

    def test_roots(self):
        assert_array_equal(np.roots([1, 0, 0]), [0, 0])


            

Reported by Pylint.

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

Line: 118 Column: 13

                      assert_(np.iscomplexobj(np.poly([1j, -1.0000001j])))

        np.random.seed(42)
        a = np.random.randn(100) + 1j*np.random.randn(100)
        assert_(np.isrealobj(np.poly(np.concatenate((a, np.conjugate(a))))))

    def test_roots(self):
        assert_array_equal(np.roots([1, 0, 0]), [0, 0])


            

Reported by Pylint.

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

Line: 188 Column: 9

                      assert_almost_equal(val0, cov[:, :, 1], decimal=4)

        # check order 1 (deg=0) case, were the analytic results are simple
        np.random.seed(123)
        y = np.random.normal(size=(4, 10000))
        mean, cov = np.polyfit(np.zeros(y.shape[0]), y, deg=0, cov=True)
        # Should get sigma_mean = sigma/sqrt(N) = 1./sqrt(4) = 0.5.
        assert_allclose(mean.std(), 0.5, atol=0.01)
        assert_allclose(np.sqrt(cov.mean()), 0.5, atol=0.01)

            

Reported by Pylint.

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

Line: 189 Column: 13

              
        # check order 1 (deg=0) case, were the analytic results are simple
        np.random.seed(123)
        y = np.random.normal(size=(4, 10000))
        mean, cov = np.polyfit(np.zeros(y.shape[0]), y, deg=0, cov=True)
        # Should get sigma_mean = sigma/sqrt(N) = 1./sqrt(4) = 0.5.
        assert_allclose(mean.std(), 0.5, atol=0.01)
        assert_allclose(np.sqrt(cov.mean()), 0.5, atol=0.01)
        # Without scaling, since reduced chi2 is 1, the result should be the same.

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 106 Column: 9

                      assert_array_almost_equal(np.poly(A), [1, -6, -72, -27])

        # Should produce real output for perfect conjugates
        assert_(np.isrealobj(np.poly([+1.082j, +2.613j, -2.613j, -1.082j])))
        assert_(np.isrealobj(np.poly([0+1j, -0+-1j, 1+2j,
                                      1-2j, 1.+3.5j, 1-3.5j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j, 1+3j, 1-3.j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 2j, -2j])))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 107 Column: 9

              
        # Should produce real output for perfect conjugates
        assert_(np.isrealobj(np.poly([+1.082j, +2.613j, -2.613j, -1.082j])))
        assert_(np.isrealobj(np.poly([0+1j, -0+-1j, 1+2j,
                                      1-2j, 1.+3.5j, 1-3.5j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j, 1+3j, 1-3.j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 2j, -2j])))
        assert_(np.isrealobj(np.poly([1j, -1j])))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 109 Column: 9

                      assert_(np.isrealobj(np.poly([+1.082j, +2.613j, -2.613j, -1.082j])))
        assert_(np.isrealobj(np.poly([0+1j, -0+-1j, 1+2j,
                                      1-2j, 1.+3.5j, 1-3.5j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j, 1+3j, 1-3.j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 2j, -2j])))
        assert_(np.isrealobj(np.poly([1j, -1j])))
        assert_(np.isrealobj(np.poly([1, -1])))


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 110 Column: 9

                      assert_(np.isrealobj(np.poly([0+1j, -0+-1j, 1+2j,
                                      1-2j, 1.+3.5j, 1-3.5j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j, 1+3j, 1-3.j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 2j, -2j])))
        assert_(np.isrealobj(np.poly([1j, -1j])))
        assert_(np.isrealobj(np.poly([1, -1])))

        assert_(np.iscomplexobj(np.poly([1j, -1.0000001j])))

            

Reported by Pylint.

numpy/random/tests/test_direct.py
124 issues
Unable to import 'pytest'
Error

Line: 8 Column: 1

              import numpy as np
from numpy.testing import (assert_equal, assert_allclose, assert_array_equal,
                           assert_raises)
import pytest

from numpy.random import (
    Generator, MT19937, PCG64, PCG64DXSM, Philox, RandomState, SeedSequence,
    SFC64, default_rng
)

            

Reported by Pylint.

Unable to import 'numpy.random._common'
Error

Line: 14 Column: 1

                  Generator, MT19937, PCG64, PCG64DXSM, Philox, RandomState, SeedSequence,
    SFC64, default_rng
)
from numpy.random._common import interface

try:
    import cffi  # noqa: F401

    MISSING_CFFI = False

            

Reported by Pylint.

Unable to import 'numpy.random.bit_generator'
Error

Line: 130 Column: 5

                  return gauss[:n]

def test_seedsequence():
    from numpy.random.bit_generator import (ISeedSequence,
                                            ISpawnableSeedSequence,
                                            SeedlessSeedSequence)

    s1 = SeedSequence(range(10), spawn_key=(1, 2), pool_size=6)
    s1.spawn(10)

            

Reported by Pylint.

Unused import cffi
Error

Line: 17 Column: 5

              from numpy.random._common import interface

try:
    import cffi  # noqa: F401

    MISSING_CFFI = False
except ImportError:
    MISSING_CFFI = True


            

Reported by Pylint.

Unused import ctypes
Error

Line: 24 Column: 5

                  MISSING_CFFI = True

try:
    import ctypes  # noqa: F401

    MISSING_CTYPES = False
except ImportError:
    MISSING_CTYPES = False


            

Reported by Pylint.

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

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

                      bit_generator = self.bit_generator(*self.data1['seed'])
        state = bit_generator.state
        bitgen_pkl = pickle.dumps(bit_generator)
        reloaded = pickle.loads(bitgen_pkl)
        reloaded_state = reloaded.state
        assert_array_equal(Generator(bit_generator).standard_normal(1000),
                           Generator(reloaded).standard_normal(1000))
        assert bit_generator is not reloaded
        assert_state_equal(reloaded_state, state)

            

Reported by Bandit.

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

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

                      assert_state_equal(reloaded_state, state)

        ss = SeedSequence(100)
        aa = pickle.loads(pickle.dumps(ss))
        assert_equal(ss.state, aa.state)

    def test_invalid_state_type(self):
        bit_generator = self.bit_generator(*self.data1['seed'])
        with pytest.raises(TypeError):

            

Reported by Bandit.

Access to a protected member _benchmark of a client class
Error

Line: 284 Column: 9

              
    def test_benchmark(self):
        bit_generator = self.bit_generator(*self.data1['seed'])
        bit_generator._benchmark(1)
        bit_generator._benchmark(1, 'double')
        with pytest.raises(ValueError):
            bit_generator._benchmark(1, 'int32')

    @pytest.mark.skipif(MISSING_CFFI, reason='cffi not available')

            

Reported by Pylint.

Access to a protected member _benchmark of a client class
Error

Line: 285 Column: 9

                  def test_benchmark(self):
        bit_generator = self.bit_generator(*self.data1['seed'])
        bit_generator._benchmark(1)
        bit_generator._benchmark(1, 'double')
        with pytest.raises(ValueError):
            bit_generator._benchmark(1, 'int32')

    @pytest.mark.skipif(MISSING_CFFI, reason='cffi not available')
    def test_cffi(self):

            

Reported by Pylint.

Access to a protected member _benchmark of a client class
Error

Line: 287 Column: 13

                      bit_generator._benchmark(1)
        bit_generator._benchmark(1, 'double')
        with pytest.raises(ValueError):
            bit_generator._benchmark(1, 'int32')

    @pytest.mark.skipif(MISSING_CFFI, reason='cffi not available')
    def test_cffi(self):
        bit_generator = self.bit_generator(*self.data1['seed'])
        cffi_interface = bit_generator.cffi

            

Reported by Pylint.

numpy/core/umath.py
123 issues
Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              
"""

from . import _multiarray_umath
from ._multiarray_umath import *  # noqa: F403
# These imports are needed for backward compatibility,
# do not change them. issue gh-11862
# _ones_like is semi-public, on purpose not added to __all__
from ._multiarray_umath import _UFUNC_API, _add_newdoc_ufunc, _ones_like

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              """

from . import _multiarray_umath
from ._multiarray_umath import *  # noqa: F403
# These imports are needed for backward compatibility,
# do not change them. issue gh-11862
# _ones_like is semi-public, on purpose not added to __all__
from ._multiarray_umath import _UFUNC_API, _add_newdoc_ufunc, _ones_like


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 14 Column: 1

              # These imports are needed for backward compatibility,
# do not change them. issue gh-11862
# _ones_like is semi-public, on purpose not added to __all__
from ._multiarray_umath import _UFUNC_API, _add_newdoc_ufunc, _ones_like

__all__ = [
    '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG',
    'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT',
    'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'NAN',

            

Reported by Pylint.

Undefined variable name 'ERR_IGNORE' in __all__
Error

Line: 17 Column: 46

              from ._multiarray_umath import _UFUNC_API, _add_newdoc_ufunc, _ones_like

__all__ = [
    '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG',
    'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT',
    'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'NAN',
    'NINF', 'NZERO', 'PINF', 'PZERO', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID',
    'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'UFUNC_BUFSIZE_DEFAULT',
    'UFUNC_PYVALS_NAME', '_add_newdoc_ufunc', 'absolute', 'add',

            

Reported by Pylint.

Undefined variable name 'ERR_CALL' in __all__
Error

Line: 17 Column: 19

              from ._multiarray_umath import _UFUNC_API, _add_newdoc_ufunc, _ones_like

__all__ = [
    '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG',
    'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT',
    'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'NAN',
    'NINF', 'NZERO', 'PINF', 'PZERO', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID',
    'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'UFUNC_BUFSIZE_DEFAULT',
    'UFUNC_PYVALS_NAME', '_add_newdoc_ufunc', 'absolute', 'add',

            

Reported by Pylint.

Undefined variable name 'ERR_LOG' in __all__
Error

Line: 17 Column: 60

              from ._multiarray_umath import _UFUNC_API, _add_newdoc_ufunc, _ones_like

__all__ = [
    '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG',
    'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT',
    'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'NAN',
    'NINF', 'NZERO', 'PINF', 'PZERO', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID',
    'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'UFUNC_BUFSIZE_DEFAULT',
    'UFUNC_PYVALS_NAME', '_add_newdoc_ufunc', 'absolute', 'add',

            

Reported by Pylint.

Undefined variable name 'ERR_DEFAULT' in __all__
Error

Line: 17 Column: 31

              from ._multiarray_umath import _UFUNC_API, _add_newdoc_ufunc, _ones_like

__all__ = [
    '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG',
    'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT',
    'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'NAN',
    'NINF', 'NZERO', 'PINF', 'PZERO', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID',
    'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'UFUNC_BUFSIZE_DEFAULT',
    'UFUNC_PYVALS_NAME', '_add_newdoc_ufunc', 'absolute', 'add',

            

Reported by Pylint.

Undefined variable name 'ERR_WARN' in __all__
Error

Line: 18 Column: 31

              
__all__ = [
    '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG',
    'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT',
    'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'NAN',
    'NINF', 'NZERO', 'PINF', 'PZERO', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID',
    'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'UFUNC_BUFSIZE_DEFAULT',
    'UFUNC_PYVALS_NAME', '_add_newdoc_ufunc', 'absolute', 'add',
    'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh',

            

Reported by Pylint.

Undefined variable name 'ERR_PRINT' in __all__
Error

Line: 18 Column: 5

              
__all__ = [
    '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG',
    'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT',
    'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'NAN',
    'NINF', 'NZERO', 'PINF', 'PZERO', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID',
    'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'UFUNC_BUFSIZE_DEFAULT',
    'UFUNC_PYVALS_NAME', '_add_newdoc_ufunc', 'absolute', 'add',
    'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh',

            

Reported by Pylint.

Undefined variable name 'ERR_RAISE' in __all__
Error

Line: 18 Column: 18

              
__all__ = [
    '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG',
    'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT',
    'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'NAN',
    'NINF', 'NZERO', 'PINF', 'PZERO', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID',
    'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'UFUNC_BUFSIZE_DEFAULT',
    'UFUNC_PYVALS_NAME', '_add_newdoc_ufunc', 'absolute', 'add',
    'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh',

            

Reported by Pylint.

numpy/lib/tests/test_stride_tricks.py
123 issues
Unable to import 'numpy.core._rational_tests'
Error

Line: 2 Column: 1

              import numpy as np
from numpy.core._rational_tests import rational
from numpy.testing import (
    assert_equal, assert_array_equal, assert_raises, assert_,
    assert_raises_regex, assert_warns,
    )
from numpy.lib.stride_tricks import (
    as_strided, broadcast_arrays, _broadcast_shape, broadcast_to,
    broadcast_shapes, sliding_window_view,

            

Reported by Pylint.

Unable to import 'pytest'
Error

Line: 11 Column: 1

                  as_strided, broadcast_arrays, _broadcast_shape, broadcast_to,
    broadcast_shapes, sliding_window_view,
    )
import pytest


def assert_shapes_correct(input_shapes, expected_shape):
    # Broadcast a list of arrays with the given input shapes and check the
    # common output shape.

            

Reported by Pylint.

Unexpected keyword argument 'dtype' in function call
Error

Line: 70 Column: 9

                  y = np.arange(10)

    with assert_raises_regex(TypeError, 'got an unexpected keyword'):
        broadcast_arrays(x, y, dtype='float64')


def test_one_off():
    x = np.array([[1, 2, 3]])
    y = np.array([[1], [2], [3]])

            

Reported by Pylint.

Unused variable 'b0'
Error

Line: 51 Column: 5

                  # Use the add ufunc to do the broadcasting. Since we're adding 0s to x1, the
    # result should be exactly the same as the broadcasted view of x1.
    y = x0 + x1
    b0, b1 = broadcast_arrays(x0, x1)
    assert_array_equal(y, b1)


def test_same():
    x = np.arange(10)

            

Reported by Pylint.

Unused variable 'expected_shape'
Error

Line: 220 Column: 23

                      [[(), (1, 0)], (1, 0)],
        [[(), (0, 1)], (0, 1)],
    ]
    for input_shapes, expected_shape in data:
        assert_same_as_ufunc(input_shapes[0], input_shapes[1],
                             "Shapes: %s %s" % (input_shapes[0], input_shapes[1]))
        # Reverse the input shapes since broadcasting should be symmetric.
        assert_same_as_ufunc(input_shapes[1], input_shapes[0])
        # Try them transposed, too.

            

Reported by Pylint.

Cell variable target_shape defined in loop
Error

Line: 276 Column: 61

                  ]
    for orig_shape, target_shape in data:
        arr = np.zeros(orig_shape)
        assert_raises(ValueError, lambda: broadcast_to(arr, target_shape))


def test_broadcast_shape():
    # tests internal _broadcast_shape
    # _broadcast_shape is already exercised indirectly by broadcast_arrays

            

Reported by Pylint.

Cell variable arr defined in loop
Error

Line: 276 Column: 56

                  ]
    for orig_shape, target_shape in data:
        arr = np.zeros(orig_shape)
        assert_raises(ValueError, lambda: broadcast_to(arr, target_shape))


def test_broadcast_shape():
    # tests internal _broadcast_shape
    # _broadcast_shape is already exercised indirectly by broadcast_arrays

            

Reported by Pylint.

Cell variable input_shapes defined in loop
Error

Line: 348 Column: 61

                      [2, (2, 3)],
    ]
    for input_shapes in data:
        assert_raises(ValueError, lambda: broadcast_shapes(*input_shapes))

    bad_args = [(2,)] * 32 + [(3,)] * 32
    assert_raises(ValueError, lambda: broadcast_shapes(*bad_args))



            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 479 Column: 9

                  def test_writeable(self):
        arr = np.arange(5)
        view = sliding_window_view(arr, 2, writeable=False)
        assert_(not view.flags.writeable)
        with pytest.raises(
                ValueError,
                match='assignment destination is read-only'):
            view[0, 0] = 3
        view = sliding_window_view(arr, 2, writeable=True)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 485 Column: 9

                              match='assignment destination is read-only'):
            view[0, 0] = 3
        view = sliding_window_view(arr, 2, writeable=True)
        assert_(view.flags.writeable)
        view[0, 1] = 3
        assert_array_equal(arr, np.array([0, 3, 2, 3, 4]))

    def test_subok(self):
        class MyArray(np.ndarray):

            

Reported by Pylint.

numpy/polynomial/legendre.py
122 issues
Attempted relative import beyond top-level package
Error

Line: 86 Column: 1

              import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index

from . import polyutils as pu
from ._polybase import ABCPolyBase

__all__ = [
    'legzero', 'legone', 'legx', 'legdomain', 'legline', 'legadd',
    'legsub', 'legmulx', 'legmul', 'legdiv', 'legpow', 'legval', 'legder',

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 87 Column: 1

              from numpy.core.multiarray import normalize_axis_index

from . import polyutils as pu
from ._polybase import ABCPolyBase

__all__ = [
    'legzero', 'legone', 'legx', 'legdomain', 'legline', 'legadd',
    'legsub', 'legmulx', 'legmul', 'legdiv', 'legpow', 'legval', 'legder',
    'legint', 'leg2poly', 'poly2leg', 'legfromroots', 'legvander',

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 193 Column: 5

              

    """
    from .polynomial import polyadd, polysub, polymulx

    [c] = pu.as_series([c])
    n = len(c)
    if n < 3:
        return c

            

Reported by Pylint.

Access to a protected member _fromroots of a client class
Error

Line: 319 Column: 12

                  array([ 1.33333333+0.j,  0.00000000+0.j,  0.66666667+0.j]) # may vary

    """
    return pu._fromroots(legline, legmul, roots)


def legadd(c1, c2):
    """
    Add one Legendre series to another.

            

Reported by Pylint.

Access to a protected member _add of a client class
Error

Line: 361 Column: 12

                  array([4.,  4.,  4.])

    """
    return pu._add(c1, c2)


def legsub(c1, c2):
    """
    Subtract one Legendre series from another.

            

Reported by Pylint.

Access to a protected member _sub of a client class
Error

Line: 405 Column: 12

                  array([ 2.,  0., -2.])

    """
    return pu._sub(c1, c2)


def legmulx(c):
    """Multiply a Legendre series by x.


            

Reported by Pylint.

Access to a protected member _div of a client class
Error

Line: 578 Column: 12

                  (array([-0.07407407,  1.66666667]), array([-1.03703704, -2.51851852])) # may vary

    """
    return pu._div(legmul, c1, c2)


def legpow(c, pow, maxpower=16):
    """Raise a Legendre series to a power.


            

Reported by Pylint.

Redefining built-in 'pow'
Error

Line: 581 Column: 15

                  return pu._div(legmul, c1, c2)


def legpow(c, pow, maxpower=16):
    """Raise a Legendre series to a power.

    Returns the Legendre series `c` raised to the power `pow`. The
    argument `c` is a sequence of coefficients ordered from low to high.
    i.e., [1,2,3] is the series  ``P_0 + 2*P_1 + 3*P_2.``

            

Reported by Pylint.

Access to a protected member _pow of a client class
Error

Line: 609 Column: 12

                  legadd, legsub, legmulx, legmul, legdiv

    """
    return pu._pow(legmul, c, pow, maxpower)


def legder(c, m=1, scl=1, axis=0):
    """
    Differentiate a Legendre series.

            

Reported by Pylint.

Access to a protected member _deprecate_as_int of a client class
Error

Line: 675 Column: 11

                  c = np.array(c, ndmin=1, copy=True)
    if c.dtype.char in '?bBhHiIlLqQpP':
        c = c.astype(np.double)
    cnt = pu._deprecate_as_int(m, "the order of derivation")
    iaxis = pu._deprecate_as_int(axis, "the axis")
    if cnt < 0:
        raise ValueError("The order of derivation must be non-negative")
    iaxis = normalize_axis_index(iaxis, c.ndim)


            

Reported by Pylint.

numpy/typing/tests/data/reveal/mod.py
122 issues
No value for argument 'value' in constructor call
Error

Line: 4 Column: 6

              from typing import Any
import numpy as np

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

f4 = np.float32()
i4 = np.int32()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 6 Column: 6

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

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


            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 8 Column: 6

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

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

td = np.timedelta64(0, "D")
b_ = np.bool_()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 10 Column: 6

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

td = np.timedelta64(0, "D")
b_ = np.bool_()

b = bool()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 13 Column: 6

              u4 = np.uint32()

td = np.timedelta64(0, "D")
b_ = np.bool_()

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


            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 19 Column: 7

              f = float()
i = int()

AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]

# Time structures

reveal_type(td % td)  # E: numpy.timedelta64

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 20 Column: 7

              i = int()

AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]

# Time structures

reveal_type(td % td)  # E: numpy.timedelta64
reveal_type(AR_m % td)  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 24 Column: 1

              
# Time structures

reveal_type(td % td)  # E: numpy.timedelta64
reveal_type(AR_m % td)  # E: Any
reveal_type(td % AR_m)  # E: Any

reveal_type(divmod(td, td))  # E: Tuple[{int64}, numpy.timedelta64]
reveal_type(divmod(AR_m, td))  # E: Tuple[numpy.ndarray[Any, numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]], numpy.ndarray[Any, numpy.dtype[numpy.timedelta64]]]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 25 Column: 1

              # Time structures

reveal_type(td % td)  # E: numpy.timedelta64
reveal_type(AR_m % td)  # E: Any
reveal_type(td % AR_m)  # E: Any

reveal_type(divmod(td, td))  # E: Tuple[{int64}, numpy.timedelta64]
reveal_type(divmod(AR_m, td))  # E: Tuple[numpy.ndarray[Any, numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]], numpy.ndarray[Any, numpy.dtype[numpy.timedelta64]]]
reveal_type(divmod(td, AR_m))  # E: Tuple[numpy.ndarray[Any, numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]], numpy.ndarray[Any, numpy.dtype[numpy.timedelta64]]]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 26 Column: 1

              
reveal_type(td % td)  # E: numpy.timedelta64
reveal_type(AR_m % td)  # E: Any
reveal_type(td % AR_m)  # E: Any

reveal_type(divmod(td, td))  # E: Tuple[{int64}, numpy.timedelta64]
reveal_type(divmod(AR_m, td))  # E: Tuple[numpy.ndarray[Any, numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]], numpy.ndarray[Any, numpy.dtype[numpy.timedelta64]]]
reveal_type(divmod(td, AR_m))  # E: Tuple[numpy.ndarray[Any, numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]], numpy.ndarray[Any, numpy.dtype[numpy.timedelta64]]]


            

Reported by Pylint.

numpy/polynomial/laguerre.py
119 issues
Attempted relative import beyond top-level package
Error

Line: 82 Column: 1

              import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index

from . import polyutils as pu
from ._polybase import ABCPolyBase

__all__ = [
    'lagzero', 'lagone', 'lagx', 'lagdomain', 'lagline', 'lagadd',
    'lagsub', 'lagmulx', 'lagmul', 'lagdiv', 'lagpow', 'lagval', 'lagder',

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 83 Column: 1

              from numpy.core.multiarray import normalize_axis_index

from . import polyutils as pu
from ._polybase import ABCPolyBase

__all__ = [
    'lagzero', 'lagone', 'lagx', 'lagdomain', 'lagline', 'lagadd',
    'lagsub', 'lagmulx', 'lagmul', 'lagdiv', 'lagpow', 'lagval', 'lagder',
    'lagint', 'lag2poly', 'poly2lag', 'lagfromroots', 'lagvander',

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 179 Column: 5

                  array([0., 1., 2., 3.])

    """
    from .polynomial import polyadd, polysub, polymulx

    [c] = pu.as_series([c])
    n = len(c)
    if n == 1:
        return c

            

Reported by Pylint.

Access to a protected member _fromroots of a client class
Error

Line: 304 Column: 12

                  array([0.+0.j, 0.+0.j])

    """
    return pu._fromroots(lagline, lagmul, roots)


def lagadd(c1, c2):
    """
    Add one Laguerre series to another.

            

Reported by Pylint.

Access to a protected member _add of a client class
Error

Line: 345 Column: 12

              

    """
    return pu._add(c1, c2)


def lagsub(c1, c2):
    """
    Subtract one Laguerre series from another.

            

Reported by Pylint.

Access to a protected member _sub of a client class
Error

Line: 385 Column: 12

                  array([0.,  0.,  0.,  4.])

    """
    return pu._sub(c1, c2)


def lagmulx(c):
    """Multiply a Laguerre series by x.


            

Reported by Pylint.

Access to a protected member _div of a client class
Error

Line: 551 Column: 12

                  (array([1., 2., 3.]), array([1., 1.]))

    """
    return pu._div(lagmul, c1, c2)


def lagpow(c, pow, maxpower=16):
    """Raise a Laguerre series to a power.


            

Reported by Pylint.

Redefining built-in 'pow'
Error

Line: 554 Column: 15

                  return pu._div(lagmul, c1, c2)


def lagpow(c, pow, maxpower=16):
    """Raise a Laguerre series to a power.

    Returns the Laguerre series `c` raised to the power `pow`. The
    argument `c` is a sequence of coefficients ordered from low to high.
    i.e., [1,2,3] is the series  ``P_0 + 2*P_1 + 3*P_2.``

            

Reported by Pylint.

Access to a protected member _pow of a client class
Error

Line: 588 Column: 12

                  array([ 14., -16.,  56., -72.,  54.])

    """
    return pu._pow(lagmul, c, pow, maxpower)


def lagder(c, m=1, scl=1, axis=0):
    """
    Differentiate a Laguerre series.

            

Reported by Pylint.

Access to a protected member _deprecate_as_int of a client class
Error

Line: 650 Column: 11

                  if c.dtype.char in '?bBhHiIlLqQpP':
        c = c.astype(np.double)

    cnt = pu._deprecate_as_int(m, "the order of derivation")
    iaxis = pu._deprecate_as_int(axis, "the axis")
    if cnt < 0:
        raise ValueError("The order of derivation must be non-negative")
    iaxis = normalize_axis_index(iaxis, c.ndim)


            

Reported by Pylint.

numpy/lib/recfunctions.py
111 issues
Access to a protected member _check_fill_value of a client class
Error

Line: 18 Column: 21

              from numpy.lib._iotools import _is_string_like
from numpy.testing import suppress_warnings

_check_fill_value = np.ma.core._check_fill_value


__all__ = [
    'append_fields', 'apply_along_fields', 'assign_fields_by_name',
    'drop_fields', 'find_duplicates', 'flatten_descr',

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 32 Column: 39

                  ]


def _recursive_fill_fields_dispatcher(input, output):
    return (input, output)


@array_function_dispatch(_recursive_fill_fields_dispatcher)
def recursive_fill_fields(input, output):

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 37 Column: 27

              

@array_function_dispatch(_recursive_fill_fields_dispatcher)
def recursive_fill_fields(input, output):
    """
    Fills fields from output with fields from input,
    with support for nested structures.

    Parameters

            

Reported by Pylint.

Unused argument 'fill_value'
Error

Line: 364 Column: 41

                  return output


def _merge_arrays_dispatcher(seqarrays, fill_value=None, flatten=None,
                             usemask=None, asrecarray=None):
    return seqarrays


@array_function_dispatch(_merge_arrays_dispatcher)

            

Reported by Pylint.

Unused argument 'flatten'
Error

Line: 364 Column: 58

                  return output


def _merge_arrays_dispatcher(seqarrays, fill_value=None, flatten=None,
                             usemask=None, asrecarray=None):
    return seqarrays


@array_function_dispatch(_merge_arrays_dispatcher)

            

Reported by Pylint.

Unused argument 'usemask'
Error

Line: 365 Column: 30

              

def _merge_arrays_dispatcher(seqarrays, fill_value=None, flatten=None,
                             usemask=None, asrecarray=None):
    return seqarrays


@array_function_dispatch(_merge_arrays_dispatcher)
def merge_arrays(seqarrays, fill_value=-1, flatten=False,

            

Reported by Pylint.

Unused argument 'asrecarray'
Error

Line: 365 Column: 44

              

def _merge_arrays_dispatcher(seqarrays, fill_value=None, flatten=None,
                             usemask=None, asrecarray=None):
    return seqarrays


@array_function_dispatch(_merge_arrays_dispatcher)
def merge_arrays(seqarrays, fill_value=-1, flatten=False,

            

Reported by Pylint.

Unused argument 'drop_names'
Error

Line: 505 Column: 35

                  return output


def _drop_fields_dispatcher(base, drop_names, usemask=None, asrecarray=None):
    return (base,)


@array_function_dispatch(_drop_fields_dispatcher)
def drop_fields(base, drop_names, usemask=True, asrecarray=False):

            

Reported by Pylint.

Unused argument 'usemask'
Error

Line: 505 Column: 47

                  return output


def _drop_fields_dispatcher(base, drop_names, usemask=None, asrecarray=None):
    return (base,)


@array_function_dispatch(_drop_fields_dispatcher)
def drop_fields(base, drop_names, usemask=True, asrecarray=False):

            

Reported by Pylint.

Unused argument 'asrecarray'
Error

Line: 505 Column: 61

                  return output


def _drop_fields_dispatcher(base, drop_names, usemask=None, asrecarray=None):
    return (base,)


@array_function_dispatch(_drop_fields_dispatcher)
def drop_fields(base, drop_names, usemask=True, asrecarray=False):

            

Reported by Pylint.

numpy/random/tests/test_randomstate_regression.py
111 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import sys

import pytest

from numpy.testing import (
    assert_, assert_array_equal, assert_raises,
    )
import numpy as np


            

Reported by Pylint.

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

Line: 19 Column: 17

                      # Make sure generated random variables are in [-pi, pi].
        # Regression test for ticket #986.
        for mu in np.linspace(-7., 7., 5):
            r = random.vonmises(mu, 1, 50)
            assert_(np.all(r > -np.pi) and np.all(r <= np.pi))

    def test_hypergeometric_range(self):
        # Test for ticket #921
        assert_(np.all(random.hypergeometric(3, 18, 11, size=10) < 4))

            

Reported by Pylint.

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

Line: 24 Column: 24

              
    def test_hypergeometric_range(self):
        # Test for ticket #921
        assert_(np.all(random.hypergeometric(3, 18, 11, size=10) < 4))
        assert_(np.all(random.hypergeometric(18, 3, 11, size=10) > 0))

        # Test for ticket #5623
        args = [
            (2**20 - 2, 2**20 - 2, 2**20 - 2),  # Check for 32-bit systems

            

Reported by Pylint.

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

Line: 25 Column: 24

                  def test_hypergeometric_range(self):
        # Test for ticket #921
        assert_(np.all(random.hypergeometric(3, 18, 11, size=10) < 4))
        assert_(np.all(random.hypergeometric(18, 3, 11, size=10) > 0))

        # Test for ticket #5623
        args = [
            (2**20 - 2, 2**20 - 2, 2**20 - 2),  # Check for 32-bit systems
        ]

            

Reported by Pylint.

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

Line: 36 Column: 21

                          # Check for 64-bit systems
            args.append((2**40 - 2, 2**40 - 2, 2**40 - 2))
        for arg in args:
            assert_(random.hypergeometric(*arg) > 0)

    def test_logseries_convergence(self):
        # Test for ticket #923
        N = 1000
        random.seed(0)

            

Reported by Pylint.

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

Line: 41 Column: 9

                  def test_logseries_convergence(self):
        # Test for ticket #923
        N = 1000
        random.seed(0)
        rvsn = random.logseries(0.8, size=N)
        # these two frequency counts should be close to theoretical
        # numbers with this large sample
        # theoretical large N result is 0.49706795
        freq = np.sum(rvsn == 1) / N

            

Reported by Pylint.

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

Line: 42 Column: 16

                      # Test for ticket #923
        N = 1000
        random.seed(0)
        rvsn = random.logseries(0.8, size=N)
        # these two frequency counts should be close to theoretical
        # numbers with this large sample
        # theoretical large N result is 0.49706795
        freq = np.sum(rvsn == 1) / N
        msg = f'Frequency was {freq:f}, should be > 0.45'

            

Reported by Pylint.

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

Line: 60 Column: 13

                                [(1, 1), (2, 2), (3, 3), None],
                  [1, (2, 2), (3, 3), None],
                  [(1, 1), 2, 3, None]]:
            random.seed(12345)
            shuffled = list(t)
            random.shuffle(shuffled)
            expected = np.array([t[0], t[3], t[1], t[2]], dtype=object)
            assert_array_equal(np.array(shuffled, dtype=object), expected)


            

Reported by Pylint.

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

Line: 62 Column: 13

                                [(1, 1), 2, 3, None]]:
            random.seed(12345)
            shuffled = list(t)
            random.shuffle(shuffled)
            expected = np.array([t[0], t[3], t[1], t[2]], dtype=object)
            assert_array_equal(np.array(shuffled, dtype=object), expected)

    def test_call_within_randomstate(self):
        # Check that custom RandomState does not call into global state

            

Reported by Pylint.

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

Line: 68 Column: 13

              
    def test_call_within_randomstate(self):
        # Check that custom RandomState does not call into global state
        m = random.RandomState()
        res = np.array([0, 8, 7, 2, 1, 9, 4, 7, 0, 3])
        for i in range(3):
            random.seed(i)
            m.seed(4321)
            # If m.state is not honored, the result will change

            

Reported by Pylint.