The following issues were found

numpy/lib/tests/test_type_check.py
237 issues
Module 'numpy.random' has no 'rand' member
Error

Line: 94 Column: 13

              class TestReal:

    def test_real(self):
        y = np.random.rand(10,)
        assert_array_equal(y, np.real(y))

        y = np.array(1)
        out = np.real(y)
        assert_array_equal(y, out)

            

Reported by Pylint.

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

Line: 108 Column: 13

                      assert_(not isinstance(out, np.ndarray))

    def test_cmplx(self):
        y = np.random.rand(10,)+1j*np.random.rand(10,)
        assert_array_equal(y.real, np.real(y))

        y = np.array(1 + 1j)
        out = np.real(y)
        assert_array_equal(y.real, out)

            

Reported by Pylint.

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

Line: 108 Column: 36

                      assert_(not isinstance(out, np.ndarray))

    def test_cmplx(self):
        y = np.random.rand(10,)+1j*np.random.rand(10,)
        assert_array_equal(y.real, np.real(y))

        y = np.array(1 + 1j)
        out = np.real(y)
        assert_array_equal(y.real, out)

            

Reported by Pylint.

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

Line: 125 Column: 13

              class TestImag:

    def test_real(self):
        y = np.random.rand(10,)
        assert_array_equal(0, np.imag(y))

        y = np.array(1)
        out = np.imag(y)
        assert_array_equal(0, out)

            

Reported by Pylint.

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

Line: 139 Column: 13

                      assert_(not isinstance(out, np.ndarray))

    def test_cmplx(self):
        y = np.random.rand(10,)+1j*np.random.rand(10,)
        assert_array_equal(y.imag, np.imag(y))

        y = np.array(1 + 1j)
        out = np.imag(y)
        assert_array_equal(y.imag, out)

            

Reported by Pylint.

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

Line: 139 Column: 36

                      assert_(not isinstance(out, np.ndarray))

    def test_cmplx(self):
        y = np.random.rand(10,)+1j*np.random.rand(10,)
        assert_array_equal(y.imag, np.imag(y))

        y = np.array(1 + 1j)
        out = np.imag(y)
        assert_array_equal(y.imag, out)

            

Reported by Pylint.

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

Line: 458 Column: 13

              class TestRealIfClose:

    def test_basic(self):
        a = np.random.rand(10)
        b = real_if_close(a+1e-15j)
        assert_all(isrealobj(b))
        assert_array_equal(a, b)
        b = real_if_close(a+1e-7j)
        assert_all(iscomplexobj(b))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 12 Column: 5

              

def assert_all(x):
    assert_(np.all(x), x)


class TestCommonType:
    def test_basic(self):
        ai32 = np.array([[1, 2], [3, 4]], dtype=np.int32)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 23 Column: 9

                      af64 = np.array([[1, 2], [3, 4]], dtype=np.float64)
        acs = np.array([[1+5j, 2+6j], [3+7j, 4+8j]], dtype=np.csingle)
        acd = np.array([[1+5j, 2+6j], [3+7j, 4+8j]], dtype=np.cdouble)
        assert_(common_type(ai32) == np.float64)
        assert_(common_type(af16) == np.float16)
        assert_(common_type(af32) == np.float32)
        assert_(common_type(af64) == np.float64)
        assert_(common_type(acs) == np.csingle)
        assert_(common_type(acd) == np.cdouble)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 24 Column: 9

                      acs = np.array([[1+5j, 2+6j], [3+7j, 4+8j]], dtype=np.csingle)
        acd = np.array([[1+5j, 2+6j], [3+7j, 4+8j]], dtype=np.cdouble)
        assert_(common_type(ai32) == np.float64)
        assert_(common_type(af16) == np.float16)
        assert_(common_type(af32) == np.float32)
        assert_(common_type(af64) == np.float64)
        assert_(common_type(acs) == np.csingle)
        assert_(common_type(acd) == np.cdouble)


            

Reported by Pylint.

numpy/lib/tests/test_recfunctions.py
233 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

import numpy as np
import numpy.ma as ma
from numpy.ma.mrecords import MaskedRecords
from numpy.ma.testutils import assert_equal
from numpy.testing import assert_, assert_raises
from numpy.lib.recfunctions import (
    drop_fields, rename_fields, get_fieldstructure, recursive_fill_fields,

            

Reported by Pylint.

Access to a protected member _get_fieldspec of a client class
Error

Line: 13 Column: 17

                  find_duplicates, merge_arrays, append_fields, stack_arrays, join_by,
    repack_fields, unstructured_to_structured, structured_to_unstructured,
    apply_along_fields, require_fields, assign_fields_by_name)
get_fieldspec = np.lib.recfunctions._get_fieldspec
get_names = np.lib.recfunctions.get_names
get_names_flat = np.lib.recfunctions.get_names_flat
zip_descr = np.lib.recfunctions._zip_descr
zip_dtype = np.lib.recfunctions._zip_dtype


            

Reported by Pylint.

Access to a protected member _zip_descr of a client class
Error

Line: 16 Column: 13

              get_fieldspec = np.lib.recfunctions._get_fieldspec
get_names = np.lib.recfunctions.get_names
get_names_flat = np.lib.recfunctions.get_names_flat
zip_descr = np.lib.recfunctions._zip_descr
zip_dtype = np.lib.recfunctions._zip_dtype


class TestRecFunctions:
    # Misc tests

            

Reported by Pylint.

Access to a protected member _zip_dtype of a client class
Error

Line: 17 Column: 13

              get_names = np.lib.recfunctions.get_names
get_names_flat = np.lib.recfunctions.get_names_flat
zip_descr = np.lib.recfunctions._zip_descr
zip_dtype = np.lib.recfunctions._zip_dtype


class TestRecFunctions:
    # Misc tests


            

Reported by Pylint.

Attribute 'data' defined outside __init__
Error

Line: 30 Column: 9

                                   dtype=[('A', '|S3'), ('B', float)])
        w = np.array([(1, (2, 3.0)), (4, (5, 6.0))],
                     dtype=[('a', int), ('b', [('ba', float), ('bb', int)])])
        self.data = (w, x, y, z)

    def test_zip_descr(self):
        # Test zip_descr
        (w, x, y, z) = self.data


            

Reported by Pylint.

Unused variable 'y'
Error

Line: 34 Column: 16

              
    def test_zip_descr(self):
        # Test zip_descr
        (w, x, y, z) = self.data

        # Std array
        test = zip_descr((x, x), flatten=True)
        assert_equal(test,
                     np.dtype([('', int), ('', int)]))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 229 Column: 9

              
        # make sure type is preserved
        dt = np.dtype((np.record, dt))
        assert_(repack_fields(dt).type is np.record)

    def test_structured_to_unstructured(self):
        a = np.zeros(4, dtype=[('a', 'i4'), ('b', 'f4,u2'), ('c', 'f4', 2)])
        out = structured_to_unstructured(a)
        assert_equal(out, np.zeros((4,5), dtype='f8'))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 266 Column: 9

                                   dtype=[('x', 'i4'), ('y', 'i4'), ('z', 'i4')])
        dd = structured_to_unstructured(d)
        ddd = unstructured_to_structured(dd, d.dtype)
        assert_(dd.base is d)
        assert_(ddd.base is d)

        # including uniform fields with subarrays unpacked
        d = np.array([(1, [2,  3], [[ 4,  5], [ 6,  7]]),
                      (8, [9, 10], [[11, 12], [13, 14]])],

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 267 Column: 9

                      dd = structured_to_unstructured(d)
        ddd = unstructured_to_structured(dd, d.dtype)
        assert_(dd.base is d)
        assert_(ddd.base is d)

        # including uniform fields with subarrays unpacked
        d = np.array([(1, [2,  3], [[ 4,  5], [ 6,  7]]),
                      (8, [9, 10], [[11, 12], [13, 14]])],
                     dtype=[('x0', 'i4'), ('x1', ('i4', 2)),

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 276 Column: 9

                                          ('x2', ('i4', (2, 2)))])
        dd = structured_to_unstructured(d)
        ddd = unstructured_to_structured(dd, d.dtype)
        assert_(dd.base is d)
        assert_(ddd.base is d)

        # test that nested fields with identical names don't break anything
        point = np.dtype([('x', int), ('y', int)])
        triangle = np.dtype([('a', point), ('b', point), ('c', point)])

            

Reported by Pylint.

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

Line: 3 Column: 7

              import numpy as np

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

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

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 4 Column: 6

              import numpy as np

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

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

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 6 Column: 6

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

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

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 8 Column: 6

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

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

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

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 9 Column: 6

              u8 = np.uint64()

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

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

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 11 Column: 6

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

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

b_ = np.bool_()

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 16 Column: 6

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

b_ = np.bool_()

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

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 30 Column: 1

              
# Time structures

reveal_type(dt > dt)  # E: numpy.bool_

reveal_type(td > td)  # E: numpy.bool_
reveal_type(td > i)  # E: numpy.bool_
reveal_type(td > i4)  # E: numpy.bool_
reveal_type(td > i8)  # E: numpy.bool_

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 32 Column: 1

              
reveal_type(dt > dt)  # E: numpy.bool_

reveal_type(td > td)  # E: numpy.bool_
reveal_type(td > i)  # E: numpy.bool_
reveal_type(td > i4)  # E: numpy.bool_
reveal_type(td > i8)  # E: numpy.bool_

reveal_type(td > AR)  # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 33 Column: 1

              reveal_type(dt > dt)  # E: numpy.bool_

reveal_type(td > td)  # E: numpy.bool_
reveal_type(td > i)  # E: numpy.bool_
reveal_type(td > i4)  # E: numpy.bool_
reveal_type(td > i8)  # E: numpy.bool_

reveal_type(td > AR)  # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]
reveal_type(td > SEQ)  # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]

            

Reported by Pylint.

numpy/ma/timer_comparison.py
217 issues
Instance of 'ModuleTester' has no 'average' member
Error

Line: 381 Column: 38

                  def test_99(self):
        # test average
        ott = self.array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
        self.assert_array_equal(2.0, self.average(ott, axis=0))
        self.assert_array_equal(2.0, self.average(ott, weights=[1., 1., 2., 1.]))
        result, wts = self.average(ott, weights=[1., 1., 2., 1.], returned=1)
        self.assert_array_equal(2.0, result)
        assert(wts == 4.0)
        ott[:] = self.masked

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 382 Column: 38

                      # test average
        ott = self.array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
        self.assert_array_equal(2.0, self.average(ott, axis=0))
        self.assert_array_equal(2.0, self.average(ott, weights=[1., 1., 2., 1.]))
        result, wts = self.average(ott, weights=[1., 1., 2., 1.], returned=1)
        self.assert_array_equal(2.0, result)
        assert(wts == 4.0)
        ott[:] = self.masked
        assert(self.average(ott, axis=0) is self.masked)

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 383 Column: 23

                      ott = self.array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
        self.assert_array_equal(2.0, self.average(ott, axis=0))
        self.assert_array_equal(2.0, self.average(ott, weights=[1., 1., 2., 1.]))
        result, wts = self.average(ott, weights=[1., 1., 2., 1.], returned=1)
        self.assert_array_equal(2.0, result)
        assert(wts == 4.0)
        ott[:] = self.masked
        assert(self.average(ott, axis=0) is self.masked)
        ott = self.array([0., 1., 2., 3.], mask=[1, 0, 0, 0])

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 387 Column: 16

                      self.assert_array_equal(2.0, result)
        assert(wts == 4.0)
        ott[:] = self.masked
        assert(self.average(ott, axis=0) is self.masked)
        ott = self.array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
        ott = ott.reshape(2, 2)
        ott[:, 1] = self.masked
        self.assert_array_equal(self.average(ott, axis=0), [2.0, 0.0])
        assert(self.average(ott, axis=1)[0] is self.masked)

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 391 Column: 33

                      ott = self.array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
        ott = ott.reshape(2, 2)
        ott[:, 1] = self.masked
        self.assert_array_equal(self.average(ott, axis=0), [2.0, 0.0])
        assert(self.average(ott, axis=1)[0] is self.masked)
        self.assert_array_equal([2., 0.], self.average(ott, axis=0))
        result, wts = self.average(ott, axis=0, returned=1)
        self.assert_array_equal(wts, [1., 0.])
        w1 = [0, 1, 1, 1, 1, 0]

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 392 Column: 16

                      ott = ott.reshape(2, 2)
        ott[:, 1] = self.masked
        self.assert_array_equal(self.average(ott, axis=0), [2.0, 0.0])
        assert(self.average(ott, axis=1)[0] is self.masked)
        self.assert_array_equal([2., 0.], self.average(ott, axis=0))
        result, wts = self.average(ott, axis=0, returned=1)
        self.assert_array_equal(wts, [1., 0.])
        w1 = [0, 1, 1, 1, 1, 0]
        w2 = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1]]

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 393 Column: 43

                      ott[:, 1] = self.masked
        self.assert_array_equal(self.average(ott, axis=0), [2.0, 0.0])
        assert(self.average(ott, axis=1)[0] is self.masked)
        self.assert_array_equal([2., 0.], self.average(ott, axis=0))
        result, wts = self.average(ott, axis=0, returned=1)
        self.assert_array_equal(wts, [1., 0.])
        w1 = [0, 1, 1, 1, 1, 0]
        w2 = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1]]
        x = self.arange(6)

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 394 Column: 23

                      self.assert_array_equal(self.average(ott, axis=0), [2.0, 0.0])
        assert(self.average(ott, axis=1)[0] is self.masked)
        self.assert_array_equal([2., 0.], self.average(ott, axis=0))
        result, wts = self.average(ott, axis=0, returned=1)
        self.assert_array_equal(wts, [1., 0.])
        w1 = [0, 1, 1, 1, 1, 0]
        w2 = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1]]
        x = self.arange(6)
        self.assert_array_equal(self.average(x, axis=0), 2.5)

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 399 Column: 33

                      w1 = [0, 1, 1, 1, 1, 0]
        w2 = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1]]
        x = self.arange(6)
        self.assert_array_equal(self.average(x, axis=0), 2.5)
        self.assert_array_equal(self.average(x, axis=0, weights=w1), 2.5)
        y = self.array([self.arange(6), 2.0*self.arange(6)])
        self.assert_array_equal(self.average(y, None), np.add.reduce(np.arange(6))*3./12.)
        self.assert_array_equal(self.average(y, axis=0), np.arange(6) * 3./2.)
        self.assert_array_equal(self.average(y, axis=1), [self.average(x, axis=0), self.average(x, axis=0) * 2.0])

            

Reported by Pylint.

Instance of 'ModuleTester' has no 'average' member
Error

Line: 400 Column: 33

                      w2 = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1]]
        x = self.arange(6)
        self.assert_array_equal(self.average(x, axis=0), 2.5)
        self.assert_array_equal(self.average(x, axis=0, weights=w1), 2.5)
        y = self.array([self.arange(6), 2.0*self.arange(6)])
        self.assert_array_equal(self.average(y, None), np.add.reduce(np.arange(6))*3./12.)
        self.assert_array_equal(self.average(y, axis=0), np.arange(6) * 3./2.)
        self.assert_array_equal(self.average(y, axis=1), [self.average(x, axis=0), self.average(x, axis=0) * 2.0])
        self.assert_array_equal(self.average(y, None, weights=w2), 20./6.)

            

Reported by Pylint.

numpy/linalg/linalg.py
217 issues
'a' does not support item assignment
Error

Line: 639 Column: 9

              
    if n == 0:
        a = empty_like(a)
        a[...] = eye(a.shape[-2], dtype=a.dtype)
        return a

    elif n < 0:
        a = inv(a)
        n = abs(n)

            

Reported by Pylint.

Instance of 'tuple' has no 'shape' member
Error

Line: 639 Column: 22

              
    if n == 0:
        a = empty_like(a)
        a[...] = eye(a.shape[-2], dtype=a.dtype)
        return a

    elif n < 0:
        a = inv(a)
        n = abs(n)

            

Reported by Pylint.

Instance of 'tuple' has no 'dtype' member
Error

Line: 639 Column: 41

              
    if n == 0:
        a = empty_like(a)
        a[...] = eye(a.shape[-2], dtype=a.dtype)
        return a

    elif n < 0:
        a = inv(a)
        n = abs(n)

            

Reported by Pylint.

Unexpected keyword argument 'keepdims' in classmethod call
Error

Line: 2543 Column: 20

                          return (x != 0).astype(x.real.dtype).sum(axis=axis, keepdims=keepdims)
        elif ord == 1:
            # special case for speedup
            return add.reduce(abs(x), axis=axis, keepdims=keepdims)
        elif ord is None or ord == 2:
            # special case for speedup
            s = (x.conj() * x).real
            return sqrt(add.reduce(s, axis=axis, keepdims=keepdims))
        # None of the str-type keywords for ord ('fro', 'nuc')

            

Reported by Pylint.

Unexpected keyword argument 'keepdims' in classmethod call
Error

Line: 2547 Column: 25

                      elif ord is None or ord == 2:
            # special case for speedup
            s = (x.conj() * x).real
            return sqrt(add.reduce(s, axis=axis, keepdims=keepdims))
        # None of the str-type keywords for ord ('fro', 'nuc')
        # are valid for vectors
        elif isinstance(ord, str):
            raise ValueError(f"Invalid norm order '{ord}' for vectors")
        else:

            

Reported by Pylint.

Unexpected keyword argument 'keepdims' in classmethod call
Error

Line: 2555 Column: 19

                      else:
            absx = abs(x)
            absx **= ord
            ret = add.reduce(absx, axis=axis, keepdims=keepdims)
            ret **= (1 / ord)
            return ret
    elif len(axis) == 2:
        row_axis, col_axis = axis
        row_axis = normalize_axis_index(row_axis, nd)

            

Reported by Pylint.

Redefining built-in 'all'
Error

Line: 21 Column: 1

              import operator
import warnings

from numpy.core import (
    array, asarray, zeros, empty, empty_like, intc, single, double,
    csingle, cdouble, inexact, complexfloating, newaxis, all, Inf, dot,
    add, multiply, sqrt, fastCopyAndTranspose, sum, isfinite,
    finfo, errstate, geterrobj, moveaxis, amin, amax, product, abs,
    atleast_2d, intp, asanyarray, object_, matmul,

            

Reported by Pylint.

Redefining built-in 'abs'
Error

Line: 21 Column: 1

              import operator
import warnings

from numpy.core import (
    array, asarray, zeros, empty, empty_like, intc, single, double,
    csingle, cdouble, inexact, complexfloating, newaxis, all, Inf, dot,
    add, multiply, sqrt, fastCopyAndTranspose, sum, isfinite,
    finfo, errstate, geterrobj, moveaxis, amin, amax, product, abs,
    atleast_2d, intp, asanyarray, object_, matmul,

            

Reported by Pylint.

Redefining built-in 'sum'
Error

Line: 21 Column: 1

              import operator
import warnings

from numpy.core import (
    array, asarray, zeros, empty, empty_like, intc, single, double,
    csingle, cdouble, inexact, complexfloating, newaxis, all, Inf, dot,
    add, multiply, sqrt, fastCopyAndTranspose, sum, isfinite,
    finfo, errstate, geterrobj, moveaxis, amin, amax, product, abs,
    atleast_2d, intp, asanyarray, object_, matmul,

            

Reported by Pylint.

Unused lapack_lite imported from numpy.linalg
Error

Line: 33 Column: 1

              from numpy.core.overrides import set_module
from numpy.core import overrides
from numpy.lib.twodim_base import triu, eye
from numpy.linalg import lapack_lite, _umath_linalg


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


            

Reported by Pylint.

numpy/typing/tests/data/reveal/fromnumeric.py
214 issues
Undefined variable 'reveal_type'
Error

Line: 15 Column: 1

              c = 1.0
d = np.array(1.0, dtype=np.float32)  # writeable

reveal_type(np.take(a, 0))  # E: Any
reveal_type(np.take(b, 0))  # E: Any
reveal_type(np.take(c, 0))  # E: Any
reveal_type(np.take(A, 0))  # E: Any
reveal_type(np.take(B, 0))  # E: Any
reveal_type(np.take(A, [0]))  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 16 Column: 1

              d = np.array(1.0, dtype=np.float32)  # writeable

reveal_type(np.take(a, 0))  # E: Any
reveal_type(np.take(b, 0))  # E: Any
reveal_type(np.take(c, 0))  # E: Any
reveal_type(np.take(A, 0))  # E: Any
reveal_type(np.take(B, 0))  # E: Any
reveal_type(np.take(A, [0]))  # E: Any
reveal_type(np.take(B, [0]))  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 17 Column: 1

              
reveal_type(np.take(a, 0))  # E: Any
reveal_type(np.take(b, 0))  # E: Any
reveal_type(np.take(c, 0))  # E: Any
reveal_type(np.take(A, 0))  # E: Any
reveal_type(np.take(B, 0))  # E: Any
reveal_type(np.take(A, [0]))  # E: Any
reveal_type(np.take(B, [0]))  # E: Any


            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 18 Column: 1

              reveal_type(np.take(a, 0))  # E: Any
reveal_type(np.take(b, 0))  # E: Any
reveal_type(np.take(c, 0))  # E: Any
reveal_type(np.take(A, 0))  # E: Any
reveal_type(np.take(B, 0))  # E: Any
reveal_type(np.take(A, [0]))  # E: Any
reveal_type(np.take(B, [0]))  # E: Any

reveal_type(np.reshape(a, 1))  # E: numpy.ndarray[Any, Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 19 Column: 1

              reveal_type(np.take(b, 0))  # E: Any
reveal_type(np.take(c, 0))  # E: Any
reveal_type(np.take(A, 0))  # E: Any
reveal_type(np.take(B, 0))  # E: Any
reveal_type(np.take(A, [0]))  # E: Any
reveal_type(np.take(B, [0]))  # E: Any

reveal_type(np.reshape(a, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(b, 1))  # E: numpy.ndarray[Any, Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 20 Column: 1

              reveal_type(np.take(c, 0))  # E: Any
reveal_type(np.take(A, 0))  # E: Any
reveal_type(np.take(B, 0))  # E: Any
reveal_type(np.take(A, [0]))  # E: Any
reveal_type(np.take(B, [0]))  # E: Any

reveal_type(np.reshape(a, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(b, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(c, 1))  # E: numpy.ndarray[Any, Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 21 Column: 1

              reveal_type(np.take(A, 0))  # E: Any
reveal_type(np.take(B, 0))  # E: Any
reveal_type(np.take(A, [0]))  # E: Any
reveal_type(np.take(B, [0]))  # E: Any

reveal_type(np.reshape(a, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(b, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(c, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(A, 1))  # E: numpy.ndarray[Any, Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 23 Column: 1

              reveal_type(np.take(A, [0]))  # E: Any
reveal_type(np.take(B, [0]))  # E: Any

reveal_type(np.reshape(a, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(b, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(c, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(A, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(B, 1))  # E: numpy.ndarray[Any, Any]


            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 24 Column: 1

              reveal_type(np.take(B, [0]))  # E: Any

reveal_type(np.reshape(a, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(b, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(c, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(A, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(B, 1))  # E: numpy.ndarray[Any, Any]

reveal_type(np.choose(a, [True, True]))  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 25 Column: 1

              
reveal_type(np.reshape(a, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(b, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(c, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(A, 1))  # E: numpy.ndarray[Any, Any]
reveal_type(np.reshape(B, 1))  # E: numpy.ndarray[Any, Any]

reveal_type(np.choose(a, [True, True]))  # E: Any
reveal_type(np.choose(A, [True, True]))  # E: Any

            

Reported by Pylint.

numpy/core/tests/test_arrayprint.py
203 issues
Unable to import 'hypothesis'
Error

Line: 4 Column: 1

              # -*- coding: utf-8 -*-
import sys
import gc
from hypothesis import given
from hypothesis.extra import numpy as hynp
import pytest

import numpy as np
from numpy.testing import (

            

Reported by Pylint.

Unable to import 'hypothesis.extra'
Error

Line: 5 Column: 1

              import sys
import gc
from hypothesis import given
from hypothesis.extra import numpy as hynp
import pytest

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

            

Reported by Pylint.

Unable to import 'pytest'
Error

Line: 6 Column: 1

              import gc
from hypothesis import given
from hypothesis.extra import numpy as hynp
import pytest

import numpy as np
from numpy.testing import (
    assert_, assert_equal, assert_raises, assert_warns, HAS_REFCOUNT,
    assert_raises_regex,

            

Reported by Pylint.

Unexpected keyword argument 'nonsense' in function call
Error

Line: 224 Column: 13

                      # an unexpected kwarg

        with assert_raises_regex(TypeError, 'nonsense'):
            np.array2string(np.array([1, 2, 3]),
                            nonsense=None)

    def test_format_function(self):
        """Test custom format function for each element in array."""
        def _format_function(x):

            

Reported by Pylint.

Value 'np.datetime64('2005-02-25')' is unsubscriptable
Error

Line: 562 Column: 27

                      a = np.zeros(1, dtype=[('a', '<i4', (3,))])
        assert_equal(str(a[0]), '([0, 0, 0],)')

        assert_equal(repr(np.datetime64('2005-02-25')[...]),
                     "array('2005-02-25', dtype='datetime64[D]')")

        assert_equal(repr(np.timedelta64('10', 'Y')[...]),
                     "array(10, dtype='timedelta64[Y]')")


            

Reported by Pylint.

Value 'np.timedelta64('10', 'Y')' is unsubscriptable
Error

Line: 565 Column: 27

                      assert_equal(repr(np.datetime64('2005-02-25')[...]),
                     "array('2005-02-25', dtype='datetime64[D]')")

        assert_equal(repr(np.timedelta64('10', 'Y')[...]),
                     "array(10, dtype='timedelta64[Y]')")

        # repr of 0d arrays is affected by printoptions
        x = np.array(1)
        np.set_printoptions(formatter={'all':lambda x: "test"})

            

Reported by Pylint.

No value for argument 'string' in unbound method call
Error

Line: 763 Column: 13

                          "array([1.00000000+1.00000000j, 1.12345679+1.12345679j])")

        # test unique special case (gh-18609)
        a = np.float64.fromhex('-1p-97')
        assert_equal(np.float64(np.array2string(a, floatmode='unique')), a)

    def test_legacy_mode_scalars(self):
        # in legacy mode, str of floats get truncated, and complex scalars
        # use * for non-finite imaginary part

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 214 Column: 9

                  def test_basic(self):
        """Basic test of array2string."""
        a = np.arange(3)
        assert_(np.array2string(a) == '[0 1 2]')
        assert_(np.array2string(a, max_line_width=4, legacy='1.13') == '[0 1\n 2]')
        assert_(np.array2string(a, max_line_width=4) == '[0\n 1\n 2]')

    def test_unexpected_kwarg(self):
        # ensure than an appropriate TypeError

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 215 Column: 9

                      """Basic test of array2string."""
        a = np.arange(3)
        assert_(np.array2string(a) == '[0 1 2]')
        assert_(np.array2string(a, max_line_width=4, legacy='1.13') == '[0 1\n 2]')
        assert_(np.array2string(a, max_line_width=4) == '[0\n 1\n 2]')

    def test_unexpected_kwarg(self):
        # ensure than an appropriate TypeError
        # is raised when array2string receives

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 216 Column: 9

                      a = np.arange(3)
        assert_(np.array2string(a) == '[0 1 2]')
        assert_(np.array2string(a, max_line_width=4, legacy='1.13') == '[0 1\n 2]')
        assert_(np.array2string(a, max_line_width=4) == '[0\n 1\n 2]')

    def test_unexpected_kwarg(self):
        # ensure than an appropriate TypeError
        # is raised when array2string receives
        # an unexpected kwarg

            

Reported by Pylint.

numpy/core/tests/test_function_base.py
198 issues
Using deprecated method assert_()
Error

Line: 15 Column: 9

                      return float.__new__(cls, value)

    def __add__(self, x):
        assert_(isinstance(x, PhysicalQuantity))
        return PhysicalQuantity(float(x) + float(self))
    __radd__ = __add__

    def __sub__(self, x):
        assert_(isinstance(x, PhysicalQuantity))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 20 Column: 9

                  __radd__ = __add__

    def __sub__(self, x):
        assert_(isinstance(x, PhysicalQuantity))
        return PhysicalQuantity(float(self) - float(x))

    def __rsub__(self, x):
        assert_(isinstance(x, PhysicalQuantity))
        return PhysicalQuantity(float(x) - float(self))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 24 Column: 9

                      return PhysicalQuantity(float(self) - float(x))

    def __rsub__(self, x):
        assert_(isinstance(x, PhysicalQuantity))
        return PhysicalQuantity(float(x) - float(self))

    def __mul__(self, x):
        return PhysicalQuantity(float(x) * float(self))
    __rmul__ = __mul__

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 46 Column: 9

              
    def test_basic(self):
        y = logspace(0, 6)
        assert_(len(y) == 50)
        y = logspace(0, 6, num=100)
        assert_(y[-1] == 10 ** 6)
        y = logspace(0, 6, endpoint=False)
        assert_(y[-1] < 10 ** 6)
        y = logspace(0, 6, num=7)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 48 Column: 9

                      y = logspace(0, 6)
        assert_(len(y) == 50)
        y = logspace(0, 6, num=100)
        assert_(y[-1] == 10 ** 6)
        y = logspace(0, 6, endpoint=False)
        assert_(y[-1] < 10 ** 6)
        y = logspace(0, 6, num=7)
        assert_array_equal(y, [1, 10, 100, 1e3, 1e4, 1e5, 1e6])


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 50 Column: 9

                      y = logspace(0, 6, num=100)
        assert_(y[-1] == 10 ** 6)
        y = logspace(0, 6, endpoint=False)
        assert_(y[-1] < 10 ** 6)
        y = logspace(0, 6, num=7)
        assert_array_equal(y, [1, 10, 100, 1e3, 1e4, 1e5, 1e6])

    def test_start_stop_array(self):
        start = array([0., 1.])

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 96 Column: 9

              
    def test_basic(self):
        y = geomspace(1, 1e6)
        assert_(len(y) == 50)
        y = geomspace(1, 1e6, num=100)
        assert_(y[-1] == 10 ** 6)
        y = geomspace(1, 1e6, endpoint=False)
        assert_(y[-1] < 10 ** 6)
        y = geomspace(1, 1e6, num=7)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 98 Column: 9

                      y = geomspace(1, 1e6)
        assert_(len(y) == 50)
        y = geomspace(1, 1e6, num=100)
        assert_(y[-1] == 10 ** 6)
        y = geomspace(1, 1e6, endpoint=False)
        assert_(y[-1] < 10 ** 6)
        y = geomspace(1, 1e6, num=7)
        assert_array_equal(y, [1, 10, 100, 1e3, 1e4, 1e5, 1e6])


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 100 Column: 9

                      y = geomspace(1, 1e6, num=100)
        assert_(y[-1] == 10 ** 6)
        y = geomspace(1, 1e6, endpoint=False)
        assert_(y[-1] < 10 ** 6)
        y = geomspace(1, 1e6, num=7)
        assert_array_equal(y, [1, 10, 100, 1e3, 1e4, 1e5, 1e6])

        y = geomspace(8, 2, num=3)
        assert_allclose(y, [8, 4, 2])

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 141 Column: 9

                          y = geomspace(-3, 3, num=4)

        assert_equal(y[0], -3.0)
        assert_(isnan(y[1:-1]).all())
        assert_equal(y[3], 3.0)

        with errstate(invalid='ignore'):
            y = geomspace(-3, 3, num=4, endpoint=False)


            

Reported by Pylint.

numpy/core/tests/test_casting_unittests.py
196 issues
Unable to import 'pytest'
Error

Line: 9 Column: 1

              than integration tests.
"""

import pytest
import textwrap
import enum
import itertools
import random


            

Reported by Pylint.

Unable to import 'numpy.core._multiarray_umath'
Error

Line: 19 Column: 1

              from numpy.lib.stride_tricks import as_strided

from numpy.testing import assert_array_equal
from numpy.core._multiarray_umath import _get_castingimpl as get_castingimpl


# Simple skips object, parametric and long double (unsupported by struct)
simple_dtypes = "?bhilqBHILQefdFD"
if np.dtype("l").itemsize != np.dtype("q").itemsize:

            

Reported by Pylint.

Unused import itertools
Error

Line: 12 Column: 1

              import pytest
import textwrap
import enum
import itertools
import random

import numpy as np
from numpy.lib.stride_tricks import as_strided


            

Reported by Pylint.

Access to a protected member _resolve_descriptors of a client class
Error

Line: 258 Column: 27

                          cast = get_castingimpl(from_Dt, to_Dt)

            for from_dt in [from_Dt(), from_Dt().newbyteorder()]:
                default = cast._resolve_descriptors((from_dt, None))[1][1]
                assert default == to_Dt()
                del default

                for to_dt in [to_Dt(), to_Dt().newbyteorder()]:
                    casting, (from_res, to_res) = cast._resolve_descriptors(

            

Reported by Pylint.

Access to a protected member _resolve_descriptors of a client class
Error

Line: 263 Column: 51

                              del default

                for to_dt in [to_Dt(), to_Dt().newbyteorder()]:
                    casting, (from_res, to_res) = cast._resolve_descriptors(
                        (from_dt, to_dt))
                    assert(type(from_res) == from_Dt)
                    assert(type(to_res) == to_Dt)
                    if casting & Casting.cast_is_view:
                        # If a view is acceptable, this is "no" casting

            

Reported by Pylint.

Access to a protected member _resolve_descriptors of a client class
Error

Line: 303 Column: 43

                          to_dt = to_dt.values[0]
            cast = get_castingimpl(type(from_dt), type(to_dt))

            casting, (from_res, to_res) = cast._resolve_descriptors(
                (from_dt, to_dt))

            if from_res is not from_dt or to_res is not to_dt:
                # Do not test this case, it is handled in multiple steps,
                # each of which should is tested individually.

            

Reported by Pylint.

Unused variable 'safe'
Error

Line: 311 Column: 13

                              # each of which should is tested individually.
                return

            safe = (casting & ~Casting.cast_is_view) <= Casting.safe
            del from_res, to_res, casting

            arr1, arr2, values = self.get_data(from_dt, to_dt)

            cast._simple_strided_call((arr1, arr2))

            

Reported by Pylint.

Possible unbalanced tuple unpacking with sequence defined at line 178: left side has 3 label(s), right side has 2 value(s)
Error

Line: 314 Column: 13

                          safe = (casting & ~Casting.cast_is_view) <= Casting.safe
            del from_res, to_res, casting

            arr1, arr2, values = self.get_data(from_dt, to_dt)

            cast._simple_strided_call((arr1, arr2))

            # Check via python list
            assert arr2.tolist() == values

            

Reported by Pylint.

Access to a protected member _simple_strided_call of a client class
Error

Line: 316 Column: 13

              
            arr1, arr2, values = self.get_data(from_dt, to_dt)

            cast._simple_strided_call((arr1, arr2))

            # Check via python list
            assert arr2.tolist() == values

            # Check that the same results are achieved for strided loops

            

Reported by Pylint.

Access to a protected member _simple_strided_call of a client class
Error

Line: 323 Column: 13

              
            # Check that the same results are achieved for strided loops
            arr1_o, arr2_o = self.get_data_variation(arr1, arr2, True, False)
            cast._simple_strided_call((arr1_o, arr2_o))

            assert_array_equal(arr2_o, arr2)
            assert arr2_o.tobytes() == arr2.tobytes()

            # Check if alignment makes a difference, but only if supported

            

Reported by Pylint.

numpy/core/tests/test_umath_complex.py
196 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import sys
import platform
import pytest

import numpy as np
# import the c-extension module directly since _arg is not exported via umath
import numpy.core._multiarray_umath as ncu
from numpy.testing import (
    assert_raises, assert_equal, assert_array_equal, assert_almost_equal, assert_array_max_ulp

            

Reported by Pylint.

Unable to import 'numpy.core._multiarray_umath'
Error

Line: 7 Column: 1

              
import numpy as np
# import the c-extension module directly since _arg is not exported via umath
import numpy.core._multiarray_umath as ncu
from numpy.testing import (
    assert_raises, assert_equal, assert_array_equal, assert_almost_equal, assert_array_max_ulp
    )

# TODO: branch cuts (use Pauli code)

            

Reported by Pylint.

TODO: branch cuts (use Pauli code)
Error

Line: 12 Column: 3

                  assert_raises, assert_equal, assert_array_equal, assert_almost_equal, assert_array_max_ulp
    )

# TODO: branch cuts (use Pauli code)
# TODO: conj 'symmetry'
# TODO: FPU exceptions

# At least on Windows the results of many complex functions are not conforming
# to the C99 standard. See ticket 1574.

            

Reported by Pylint.

TODO: conj 'symmetry'
Error

Line: 13 Column: 3

                  )

# TODO: branch cuts (use Pauli code)
# TODO: conj 'symmetry'
# TODO: FPU exceptions

# At least on Windows the results of many complex functions are not conforming
# to the C99 standard. See ticket 1574.
# Ditto for Solaris (ticket 1642) and OS X on PowerPC.

            

Reported by Pylint.

TODO: FPU exceptions
Error

Line: 14 Column: 3

              
# TODO: branch cuts (use Pauli code)
# TODO: conj 'symmetry'
# TODO: FPU exceptions

# At least on Windows the results of many complex functions are not conforming
# to the C99 standard. See ticket 1574.
# Ditto for Solaris (ticket 1642) and OS X on PowerPC.
#FIXME: this will probably change when we require full C99 campatibility

            

Reported by Pylint.

FIXME: this will probably change when we require full C99 campatibility
Error

Line: 19 Column: 2

              # At least on Windows the results of many complex functions are not conforming
# to the C99 standard. See ticket 1574.
# Ditto for Solaris (ticket 1642) and OS X on PowerPC.
#FIXME: this will probably change when we require full C99 campatibility
with np.errstate(all='ignore'):
    functions_seem_flaky = ((np.exp(complex(np.inf, 0)).imag != 0)
                            or (np.log(complex(np.NZERO, 0)).imag != np.pi))
# TODO: replace with a check on whether platform-provided C99 funcs are used
xfail_complex_tests = (not sys.platform.startswith('linux') or functions_seem_flaky)

            

Reported by Pylint.

TODO: replace with a check on whether platform-provided C99 funcs are used
Error

Line: 23 Column: 3

              with np.errstate(all='ignore'):
    functions_seem_flaky = ((np.exp(complex(np.inf, 0)).imag != 0)
                            or (np.log(complex(np.NZERO, 0)).imag != np.pi))
# TODO: replace with a check on whether platform-provided C99 funcs are used
xfail_complex_tests = (not sys.platform.startswith('linux') or functions_seem_flaky)

# TODO This can be xfail when the generator functions are got rid of.
platform_skip = pytest.mark.skipif(xfail_complex_tests,
                                   reason="Inadequate C99 complex support")

            

Reported by Pylint.

TODO This can be xfail when the generator functions are got rid of.
Error

Line: 26 Column: 3

              # TODO: replace with a check on whether platform-provided C99 funcs are used
xfail_complex_tests = (not sys.platform.startswith('linux') or functions_seem_flaky)

# TODO This can be xfail when the generator functions are got rid of.
platform_skip = pytest.mark.skipif(xfail_complex_tests,
                                   reason="Inadequate C99 complex support")




            

Reported by Pylint.

Unused argument 'dummy'
Error

Line: 72 Column: 29

                      check(f,  np.inf, 0.75 * np.pi, -np.inf, np.inf)

        # cexp(-inf + inf i) is +-0 +- 0i (signs unspecified)
        def _check_ninf_inf(dummy):
            msgform = "cexp(-inf, inf) is (%f, %f), expected (+-0, +-0)"
            with np.errstate(invalid='ignore'):
                z = f(np.array(complex(-np.inf, np.inf)))
                if z.real != 0 or z.imag != 0:
                    raise AssertionError(msgform % (z.real, z.imag))

            

Reported by Pylint.

Unused argument 'dummy'
Error

Line: 82 Column: 28

                      _check_ninf_inf(None)

        # cexp(inf + inf i) is +-inf + NaNi and raised invalid FPU ex.
        def _check_inf_inf(dummy):
            msgform = "cexp(inf, inf) is (%f, %f), expected (+-inf, nan)"
            with np.errstate(invalid='ignore'):
                z = f(np.array(complex(np.inf, np.inf)))
                if not np.isinf(z.real) or not np.isnan(z.imag):
                    raise AssertionError(msgform % (z.real, z.imag))

            

Reported by Pylint.