The following issues were found

numpy/distutils/from_template.py
24 issues
Unused variable 'ext'
Error

Line: 251 Column: 16

                      outfile = sys.stdout
    else:
        fid = open(file, 'r')
        (base, ext) = os.path.splitext(file)
        newname = base
        outfile = open(newname, 'w')

    allstr = fid.read()
    writestr = process_str(allstr)

            

Reported by Pylint.

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

Line: 67 Column: 9

                  spanlist = []
    ind = 0
    while True:
        m = routine_start_re.search(astr, ind)
        if m is None:
            break
        start = m.start()
        if function_start_re.match(astr, start, m.end()):
            while True:

            

Reported by Pylint.

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

Line: 80 Column: 9

                              if astr[i:i+7]!='\n     $':
                    break
        start += 1
        m = routine_end_re.search(astr, m.end())
        ind = end = m and m.end()-1 or len(astr)
        spanlist.append((start, end))
    return spanlist

template_re = re.compile(r"<\s*(\w[\w\d]*)\s*>")

            

Reported by Pylint.

Consider using ternary (m.end() - 1 if m else len(astr))
Error

Line: 81 Column: 9

                                  break
        start += 1
        m = routine_end_re.search(astr, m.end())
        ind = end = m and m.end()-1 or len(astr)
        spanlist.append((start, end))
    return spanlist

template_re = re.compile(r"<\s*(\w[\w\d]*)\s*>")
named_re = re.compile(r"<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 89 Column: 1

              named_re = re.compile(r"<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>")
list_re = re.compile(r"<\s*((.*?))\s*>")

def find_repl_patterns(astr):
    reps = named_re.findall(astr)
    names = {}
    for rep in reps:
        name = rep[0].strip() or unique_key(names)
        repl = rep[1].replace(r'\,', '@comma@')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 99 Column: 1

                      names[name] = thelist
    return names

def find_and_remove_repl_patterns(astr):
    names = find_repl_patterns(astr)
    astr = re.subn(named_re, '', astr)[0]
    return astr, names

item_re = re.compile(r"\A\\(?P<index>\d+)\Z")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 105 Column: 1

                  return astr, names

item_re = re.compile(r"\A\\(?P<index>\d+)\Z")
def conv(astr):
    b = astr.split(',')
    l = [x.strip() for x in b]
    for i in range(len(l)):
        m = item_re.match(l[i])
        if m:

            

Reported by Pylint.

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

Line: 106 Column: 5

              
item_re = re.compile(r"\A\\(?P<index>\d+)\Z")
def conv(astr):
    b = astr.split(',')
    l = [x.strip() for x in b]
    for i in range(len(l)):
        m = item_re.match(l[i])
        if m:
            j = int(m.group('index'))

            

Reported by Pylint.

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

Line: 107 Column: 5

              item_re = re.compile(r"\A\\(?P<index>\d+)\Z")
def conv(astr):
    b = astr.split(',')
    l = [x.strip() for x in b]
    for i in range(len(l)):
        m = item_re.match(l[i])
        if m:
            j = int(m.group('index'))
            l[i] = l[j]

            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 108 Column: 5

              def conv(astr):
    b = astr.split(',')
    l = [x.strip() for x in b]
    for i in range(len(l)):
        m = item_re.match(l[i])
        if m:
            j = int(m.group('index'))
            l[i] = l[j]
    return ','.join(l)

            

Reported by Pylint.

benchmarks/benchmarks/bench_app.py
24 issues
Attempted relative import beyond top-level package
Error

Line: 1 Column: 1

              from .common import Benchmark

import numpy as np


class LaplaceInplace(Benchmark):
    params = ['inplace', 'normal']
    param_names = ['update']


            

Reported by Pylint.

Unused variable 'i'
Error

Line: 37 Column: 17

                      def laplace(N, Niter=100, func=num_update, args=()):
            u = np.zeros([N, N], order='C')
            u[0] = 1
            for i in range(Niter):
                func(u, *args)
            return u

        func = {'inplace': num_inplace, 'normal': num_update}[update]


            

Reported by Pylint.

Attribute 'run' defined outside __init__
Error

Line: 46 Column: 9

                      def run():
            laplace(N, Niter, func, args=(dx2, dy2))

        self.run = run

    def time_it(self, update):
        self.run()



            

Reported by Pylint.

Unused argument 'update'
Error

Line: 48 Column: 23

              
        self.run = run

    def time_it(self, update):
        self.run()


class MaxesOfDots(Benchmark):
    def setup(self):

            

Reported by Pylint.

Attribute 'arrays' defined outside __init__
Error

Line: 59 Column: 9

                      nfeat = 100
        ntime = 200

        self.arrays = [np.random.normal(size=(ntime, nfeat))
                       for i in range(nsubj)]

    def maxes_of_dots(self, arrays):
        """
        A magical feature score for each feature in each dataset

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from .common import Benchmark

import numpy as np


class LaplaceInplace(Benchmark):
    params = ['inplace', 'normal']
    param_names = ['update']


            

Reported by Pylint.

third party import "import numpy as np" should be placed before "from .common import Benchmark"
Error

Line: 3 Column: 1

              from .common import Benchmark

import numpy as np


class LaplaceInplace(Benchmark):
    params = ['inplace', 'normal']
    param_names = ['update']


            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              import numpy as np


class LaplaceInplace(Benchmark):
    params = ['inplace', 'normal']
    param_names = ['update']

    def setup(self, update):
        N = 150

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

                  params = ['inplace', 'normal']
    param_names = ['update']

    def setup(self, update):
        N = 150
        Niter = 1000
        dx = 0.1
        dy = 0.1
        dx2 = (dx * dx)

            

Reported by Pylint.

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

Line: 11 Column: 9

                  param_names = ['update']

    def setup(self, update):
        N = 150
        Niter = 1000
        dx = 0.1
        dy = 0.1
        dx2 = (dx * dx)
        dy2 = (dy * dy)

            

Reported by Pylint.

numpy/core/tests/test_scalar_methods.py
24 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              import fractions
import platform

import pytest
import numpy as np

from numpy.testing import assert_equal, assert_raises



            

Reported by Pylint.

Instance of 'float16' has no 'as_integer_ratio' member
Error

Line: 50 Column: 25

                  def test_against_known_values(self):
        R = fractions.Fraction
        assert_equal(R(1075, 512),
                     R(*np.half(2.1).as_integer_ratio()))
        assert_equal(R(-1075, 512),
                     R(*np.half(-2.1).as_integer_ratio()))
        assert_equal(R(4404019, 2097152),
                     R(*np.single(2.1).as_integer_ratio()))
        assert_equal(R(-4404019, 2097152),

            

Reported by Pylint.

Instance of 'float16' has no 'as_integer_ratio' member
Error

Line: 52 Column: 25

                      assert_equal(R(1075, 512),
                     R(*np.half(2.1).as_integer_ratio()))
        assert_equal(R(-1075, 512),
                     R(*np.half(-2.1).as_integer_ratio()))
        assert_equal(R(4404019, 2097152),
                     R(*np.single(2.1).as_integer_ratio()))
        assert_equal(R(-4404019, 2097152),
                     R(*np.single(-2.1).as_integer_ratio()))
        assert_equal(R(4728779608739021, 2251799813685248),

            

Reported by Pylint.

Instance of 'float32' has no 'as_integer_ratio' member
Error

Line: 54 Column: 25

                      assert_equal(R(-1075, 512),
                     R(*np.half(-2.1).as_integer_ratio()))
        assert_equal(R(4404019, 2097152),
                     R(*np.single(2.1).as_integer_ratio()))
        assert_equal(R(-4404019, 2097152),
                     R(*np.single(-2.1).as_integer_ratio()))
        assert_equal(R(4728779608739021, 2251799813685248),
                     R(*np.double(2.1).as_integer_ratio()))
        assert_equal(R(-4728779608739021, 2251799813685248),

            

Reported by Pylint.

Instance of 'float32' has no 'as_integer_ratio' member
Error

Line: 56 Column: 25

                      assert_equal(R(4404019, 2097152),
                     R(*np.single(2.1).as_integer_ratio()))
        assert_equal(R(-4404019, 2097152),
                     R(*np.single(-2.1).as_integer_ratio()))
        assert_equal(R(4728779608739021, 2251799813685248),
                     R(*np.double(2.1).as_integer_ratio()))
        assert_equal(R(-4728779608739021, 2251799813685248),
                     R(*np.double(-2.1).as_integer_ratio()))
        # longdouble is platform dependent

            

Reported by Pylint.

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

Line: 94 Column: 20

                      for frac, exp in zip(frac_vals, exp_vals):
            f = np.ldexp(ftype(frac), exp)
            assert f.dtype == ftype
            n, d = f.as_integer_ratio()

            try:
                # workaround for gh-9968
                nf = np.longdouble(str(n))
                df = np.longdouble(str(d))

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              from numpy.testing import assert_equal, assert_raises


class TestAsIntegerRatio:
    # derived in part from the cpython test "test_floatasratio"

    @pytest.mark.parametrize("ftype", [
        np.half, np.single, np.double, np.longdouble])
    @pytest.mark.parametrize("f, ratio", [

            

Reported by Pylint.

Method could be a function
Error

Line: 23 Column: 5

                      (-0.875, (-7, 8)),
        (0.0, (0, 1)),
        (11.5, (23, 2)),
        ])
    def test_small(self, ftype, f, ratio):
        assert_equal(ftype(f).as_integer_ratio(), ratio)

    @pytest.mark.parametrize("ftype", [
        np.half, np.single, np.double, np.longdouble])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                      (-0.875, (-7, 8)),
        (0.0, (0, 1)),
        (11.5, (23, 2)),
        ])
    def test_small(self, ftype, f, ratio):
        assert_equal(ftype(f).as_integer_ratio(), ratio)

    @pytest.mark.parametrize("ftype", [
        np.half, np.single, np.double, np.longdouble])

            

Reported by Pylint.

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

Line: 23 Column: 5

                      (-0.875, (-7, 8)),
        (0.0, (0, 1)),
        (11.5, (23, 2)),
        ])
    def test_small(self, ftype, f, ratio):
        assert_equal(ftype(f).as_integer_ratio(), ratio)

    @pytest.mark.parametrize("ftype", [
        np.half, np.single, np.double, np.longdouble])

            

Reported by Pylint.

numpy/core/shape_base.py
24 issues
Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              import operator
import warnings

from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              import warnings

from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx


array_function_dispatch = functools.partial(

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

              
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx


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

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx


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


            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 348 Column: 31

                      return _nx.concatenate(arrs, 1)


def _stack_dispatcher(arrays, axis=None, out=None):
    arrays = _arrays_for_stack_dispatcher(arrays, stacklevel=6)
    if out is not None:
        # optimize for the typical case where only arrays is provided
        arrays = list(arrays)
        arrays.append(out)

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 452 Column: 1

                  return 'arrays' + idx_str


def _block_check_depths_match(arrays, parent_index=[]):
    """
    Recursive function checking that the depths of nested lists in `arrays`
    all match. Mismatch raises a ValueError as described in the block
    docstring below.


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              __all__ = ['atleast_1d', 'atleast_2d', 'atleast_3d', 'block', 'hstack',
           'stack', 'vstack']

import functools
import itertools
import operator
import warnings

from . import numeric as _nx

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 71 Column: 5

                      else:
            result = ary
        res.append(result)
    if len(res) == 1:
        return res[0]
    else:
        return res



            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 129 Column: 5

                      else:
            result = ary
        res.append(result)
    if len(res) == 1:
        return res[0]
    else:
        return res



            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 201 Column: 5

                      else:
            result = ary
        res.append(result)
    if len(res) == 1:
        return res[0]
    else:
        return res



            

Reported by Pylint.

numpy/core/setup_common.py
24 issues
Access to a protected member _check_compiler of a client class
Error

Line: 246 Column: 5

              
# Code to detect long double representation taken from MPFR m4 macro
def check_long_double_representation(cmd):
    cmd._check_compiler()
    body = LONG_DOUBLE_REPRESENTATION_SRC % {'type': 'long double'}

    # Disable whole program optimization (the default on vs2015, with python 3.5+)
    # which generates intermediary object files and prevents checking the
    # float representation.

            

Reported by Pylint.

Unused variable 'src'
Error

Line: 274 Column: 5

                      )

    # We need to use _compile because we need the object filename
    src, obj = cmd._compile(body, None, None, 'c')
    try:
        ltype = long_double_representation(pyod(obj))
        return ltype
    except ValueError:
        # try linking to support CC="gcc -flto" or icc -ipo

            

Reported by Pylint.

Access to a protected member _compile of a client class
Error

Line: 274 Column: 16

                      )

    # We need to use _compile because we need the object filename
    src, obj = cmd._compile(body, None, None, 'c')
    try:
        ltype = long_double_representation(pyod(obj))
        return ltype
    except ValueError:
        # try linking to support CC="gcc -flto" or icc -ipo

            

Reported by Pylint.

Access to a protected member _compile of a client class
Error

Line: 284 Column: 20

                      # additionally "clang -flto" requires the foo struct to be used
        body = body.replace('struct', 'volatile struct')
        body += "int main(void) { return foo.before[0]; }\n"
        src, obj = cmd._compile(body, None, None, 'c')
        cmd.temp_files.append("_configtest")
        cmd.compiler.link_executable([obj], "_configtest")
        ltype = long_double_representation(pyod("_configtest"))
        return ltype
    finally:

            

Reported by Pylint.

Access to a protected member _clean of a client class
Error

Line: 290 Column: 9

                      ltype = long_double_representation(pyod("_configtest"))
        return ltype
    finally:
        cmd._clean()

LONG_DOUBLE_REPRESENTATION_SRC = r"""
/* "before" is 16 bytes to ensure there's no padding between it and "x".
 *    We're not expecting any "long double" bigger than 16 bytes or with
 *       alignment requirements stricter than 16 bytes.  */

            

Reported by Pylint.

Access to a protected member _check_compiler of a client class
Error

Line: 435 Column: 5

                  This function returns True if this compiler bug is present, and we need to
    turn off optimization for the function
    """
    cmd._check_compiler()
    has_optimize = cmd.try_compile(textwrap.dedent("""\
        __attribute__((optimize("O3"))) void right_shift() {}
        """), None, None)
    if not has_optimize:
        return False

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Code common to build tools
import sys
import warnings
import copy
import textwrap

from numpy.distutils.misc_util import mingw32



            

Reported by Pylint.

Missing class docstring
Error

Line: 49 Column: 1

              # 0x0000000e - 1.22.x
C_API_VERSION = 0x0000000e

class MismatchCAPIWarning(Warning):
    pass

def is_released(config):
    """Return True if a released version of numpy is detected."""
    from distutils.version import LooseVersion

            

Reported by Pylint.

Import outside toplevel (distutils.version.LooseVersion)
Error

Line: 54 Column: 5

              
def is_released(config):
    """Return True if a released version of numpy is detected."""
    from distutils.version import LooseVersion

    v = config.get_version('../_version.py')
    if v is None:
        raise ValueError("Could not get version")
    pv = LooseVersion(vstring=v).version

            

Reported by Pylint.

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

Line: 56 Column: 5

                  """Return True if a released version of numpy is detected."""
    from distutils.version import LooseVersion

    v = config.get_version('../_version.py')
    if v is None:
        raise ValueError("Could not get version")
    pv = LooseVersion(vstring=v).version
    if len(pv) > 3:
        return False

            

Reported by Pylint.

numpy/lib/arraysetops.py
24 issues
Unused argument 'return_index'
Error

Line: 133 Column: 28

                      return x


def _unique_dispatcher(ar, return_index=None, return_inverse=None,
                       return_counts=None, axis=None):
    return (ar,)


@array_function_dispatch(_unique_dispatcher)

            

Reported by Pylint.

Unused argument 'return_inverse'
Error

Line: 133 Column: 47

                      return x


def _unique_dispatcher(ar, return_index=None, return_inverse=None,
                       return_counts=None, axis=None):
    return (ar,)


@array_function_dispatch(_unique_dispatcher)

            

Reported by Pylint.

Unused argument 'return_counts'
Error

Line: 134 Column: 24

              

def _unique_dispatcher(ar, return_index=None, return_inverse=None,
                       return_counts=None, axis=None):
    return (ar,)


@array_function_dispatch(_unique_dispatcher)
def unique(ar, return_index=False, return_inverse=False,

            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 134 Column: 44

              

def _unique_dispatcher(ar, return_index=None, return_inverse=None,
                       return_counts=None, axis=None):
    return (ar,)


@array_function_dispatch(_unique_dispatcher)
def unique(ar, return_index=False, return_inverse=False,

            

Reported by Pylint.

Unused argument 'assume_unique'
Error

Line: 365 Column: 19

              

def _intersect1d_dispatcher(
        ar1, ar2, assume_unique=None, return_indices=None):
    return (ar1, ar2)


@array_function_dispatch(_intersect1d_dispatcher)
def intersect1d(ar1, ar2, assume_unique=False, return_indices=False):

            

Reported by Pylint.

Unused argument 'return_indices'
Error

Line: 365 Column: 39

              

def _intersect1d_dispatcher(
        ar1, ar2, assume_unique=None, return_indices=None):
    return (ar1, ar2)


@array_function_dispatch(_intersect1d_dispatcher)
def intersect1d(ar1, ar2, assume_unique=False, return_indices=False):

            

Reported by Pylint.

Unused argument 'assume_unique'
Error

Line: 468 Column: 36

                      return int1d


def _setxor1d_dispatcher(ar1, ar2, assume_unique=None):
    return (ar1, ar2)


@array_function_dispatch(_setxor1d_dispatcher)
def setxor1d(ar1, ar2, assume_unique=False):

            

Reported by Pylint.

Unused argument 'assume_unique'
Error

Line: 515 Column: 32

                  return aux[flag[1:] & flag[:-1]]


def _in1d_dispatcher(ar1, ar2, assume_unique=None, invert=None):
    return (ar1, ar2)


@array_function_dispatch(_in1d_dispatcher)
def in1d(ar1, ar2, assume_unique=False, invert=False):

            

Reported by Pylint.

Unused argument 'invert'
Error

Line: 515 Column: 52

                  return aux[flag[1:] & flag[:-1]]


def _in1d_dispatcher(ar1, ar2, assume_unique=None, invert=None):
    return (ar1, ar2)


@array_function_dispatch(_in1d_dispatcher)
def in1d(ar1, ar2, assume_unique=False, invert=False):

            

Reported by Pylint.

Unused argument 'invert'
Error

Line: 636 Column: 66

                      return ret[rev_idx]


def _isin_dispatcher(element, test_elements, assume_unique=None, invert=None):
    return (element, test_elements)


@array_function_dispatch(_isin_dispatcher)
def isin(element, test_elements, assume_unique=False, invert=False):

            

Reported by Pylint.

numpy/distutils/fcompiler/mips.py
23 issues
Method 'find_library_file' is abstract in class 'CCompiler' but is not overridden
Error

Line: 6 Column: 1

              
compilers = ['MIPSFCompiler']

class MIPSFCompiler(FCompiler):

    compiler_type = 'mips'
    description = 'MIPSpro Fortran Compiler'
    version_pattern =  r'MIPSpro Compilers: Version (?P<version>[^\s*,]*)'


            

Reported by Pylint.

Method 'runtime_library_dir_option' is abstract in class 'CCompiler' but is not overridden
Error

Line: 6 Column: 1

              
compilers = ['MIPSFCompiler']

class MIPSFCompiler(FCompiler):

    compiler_type = 'mips'
    description = 'MIPSpro Fortran Compiler'
    version_pattern =  r'MIPSpro Compilers: Version (?P<version>[^\s*,]*)'


            

Reported by Pylint.

Method 'wrap_unlinkable_objects' is abstract in class 'FCompiler' but is not overridden
Error

Line: 6 Column: 1

              
compilers = ['MIPSFCompiler']

class MIPSFCompiler(FCompiler):

    compiler_type = 'mips'
    description = 'MIPSpro Fortran Compiler'
    version_pattern =  r'MIPSpro Compilers: Version (?P<version>[^\s*,]*)'


            

Reported by Pylint.

XXX: fix me
Error

Line: 21 Column: 2

                      'archiver'     : ["ar", "-cr"],
        'ranlib'       : None
        }
    module_dir_switch = None #XXX: fix me
    module_include_switch = None #XXX: fix me
    pic_flags = ['-KPIC']

    def get_flags(self):
        return self.pic_flags + ['-n32']

            

Reported by Pylint.

XXX: fix me
Error

Line: 22 Column: 2

                      'ranlib'       : None
        }
    module_dir_switch = None #XXX: fix me
    module_include_switch = None #XXX: fix me
    pic_flags = ['-KPIC']

    def get_flags(self):
        return self.pic_flags + ['-n32']
    def get_flags_opt(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from numpy.distutils.cpuinfo import cpu
from numpy.distutils.fcompiler import FCompiler

compilers = ['MIPSFCompiler']

class MIPSFCompiler(FCompiler):

    compiler_type = 'mips'
    description = 'MIPSpro Fortran Compiler'

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              
compilers = ['MIPSFCompiler']

class MIPSFCompiler(FCompiler):

    compiler_type = 'mips'
    description = 'MIPSpro Fortran Compiler'
    version_pattern =  r'MIPSpro Compilers: Version (?P<version>[^\s*,]*)'


            

Reported by Pylint.

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

Line: 31 Column: 13

                      return ['-O3']
    def get_flags_arch(self):
        opt = []
        for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():
            if getattr(cpu, 'is_IP%s'%a)():
                opt.append('-TARG:platform=IP%s' % a)
                break
        return opt
    def get_flags_arch_f77(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 5

                              opt.append('-TARG:platform=IP%s' % a)
                break
        return opt
    def get_flags_arch_f77(self):
        r = None
        if cpu.is_r10000(): r = 10000
        elif cpu.is_r12000(): r = 12000
        elif cpu.is_r8000(): r = 8000
        elif cpu.is_r5000(): r = 5000

            

Reported by Pylint.

Method could be a function
Error

Line: 36 Column: 5

                              opt.append('-TARG:platform=IP%s' % a)
                break
        return opt
    def get_flags_arch_f77(self):
        r = None
        if cpu.is_r10000(): r = 10000
        elif cpu.is_r12000(): r = 12000
        elif cpu.is_r8000(): r = 8000
        elif cpu.is_r5000(): r = 5000

            

Reported by Pylint.

numpy/core/_dtype_ctypes.py
23 issues
Access to a protected member _type_ of a client class
Error

Line: 33 Column: 45

              

def _from_ctypes_array(t):
    return np.dtype((dtype_from_ctypes_type(t._type_), (t._length_,)))


def _from_ctypes_structure(t):
    for item in t._fields_:
        if len(item) > 2:

            

Reported by Pylint.

Access to a protected member _length_ of a client class
Error

Line: 33 Column: 57

              

def _from_ctypes_array(t):
    return np.dtype((dtype_from_ctypes_type(t._type_), (t._length_,)))


def _from_ctypes_structure(t):
    for item in t._fields_:
        if len(item) > 2:

            

Reported by Pylint.

Access to a protected member _fields_ of a client class
Error

Line: 37 Column: 17

              

def _from_ctypes_structure(t):
    for item in t._fields_:
        if len(item) > 2:
            raise TypeError(
                "ctypes bitfields have no dtype equivalent")

    if hasattr(t, "_pack_"):

            

Reported by Pylint.

Access to a protected member _fields_ of a client class
Error

Line: 48 Column: 28

                      offsets = []
        names = []
        current_offset = 0
        for fname, ftyp in t._fields_:
            names.append(fname)
            formats.append(dtype_from_ctypes_type(ftyp))
            # Each type has a default offset, this is platform dependent for some types.
            effective_pack = min(t._pack_, ctypes.alignment(ftyp))
            current_offset = ((current_offset + effective_pack - 1) // effective_pack) * effective_pack

            

Reported by Pylint.

Access to a protected member _pack_ of a client class
Error

Line: 52 Column: 34

                          names.append(fname)
            formats.append(dtype_from_ctypes_type(ftyp))
            # Each type has a default offset, this is platform dependent for some types.
            effective_pack = min(t._pack_, ctypes.alignment(ftyp))
            current_offset = ((current_offset + effective_pack - 1) // effective_pack) * effective_pack
            offsets.append(current_offset)
            current_offset += ctypes.sizeof(ftyp)

        return np.dtype(dict(

            

Reported by Pylint.

Access to a protected member _fields_ of a client class
Error

Line: 64 Column: 28

                          itemsize=ctypes.sizeof(t)))
    else:
        fields = []
        for fname, ftyp in t._fields_:
            fields.append((fname, dtype_from_ctypes_type(ftyp)))

        # by default, ctypes structs are aligned
        return np.dtype(fields, align=True)


            

Reported by Pylint.

Access to a protected member _type_ of a client class
Error

Line: 76 Column: 31

                  Return the dtype type with endianness included if it's the case
    """
    if getattr(t, '__ctype_be__', None) is t:
        return np.dtype('>' + t._type_)
    elif getattr(t, '__ctype_le__', None) is t:
        return np.dtype('<' + t._type_)
    else:
        return np.dtype(t._type_)


            

Reported by Pylint.

Access to a protected member _type_ of a client class
Error

Line: 78 Column: 31

                  if getattr(t, '__ctype_be__', None) is t:
        return np.dtype('>' + t._type_)
    elif getattr(t, '__ctype_le__', None) is t:
        return np.dtype('<' + t._type_)
    else:
        return np.dtype(t._type_)


def _from_ctypes_union(t):

            

Reported by Pylint.

Access to a protected member _type_ of a client class
Error

Line: 80 Column: 25

                  elif getattr(t, '__ctype_le__', None) is t:
        return np.dtype('<' + t._type_)
    else:
        return np.dtype(t._type_)


def _from_ctypes_union(t):
    import ctypes
    formats = []

            

Reported by Pylint.

Access to a protected member _fields_ of a client class
Error

Line: 88 Column: 24

                  formats = []
    offsets = []
    names = []
    for fname, ftyp in t._fields_:
        names.append(fname)
        formats.append(dtype_from_ctypes_type(ftyp))
        offsets.append(0)  # Union fields are offset to 0

    return np.dtype(dict(

            

Reported by Pylint.

numpy/lib/scimath.py
23 issues
Module 'numpy.core.numeric' has no 'sqrt' member; maybe 'sort'?
Error

Line: 240 Column: 12

              
    """
    x = _fix_real_lt_zero(x)
    return nx.sqrt(x)


@array_function_dispatch(_unary_dispatcher)
def log(x):
    """

            

Reported by Pylint.

Module 'numpy.core.numeric' has no 'log10' member; maybe 'log1p'?
Error

Line: 338 Column: 12

              
    """
    x = _fix_real_lt_zero(x)
    return nx.log10(x)


def _logn_dispatcher(n, x):
    return (n, x,)


            

Reported by Pylint.

Redefining built-in 'any'
Error

Line: 36 Column: 1

              """
import numpy.core.numeric as nx
import numpy.core.numerictypes as nt
from numpy.core.numeric import asarray, any
from numpy.core.overrides import array_function_dispatch
from numpy.lib.type_check import isreal


__all__ = [

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 106 Column: 5

                  >>> cc
    array([1.+0.j,  2.+0.j,  3.+0.j], dtype=complex64)
    """
    if issubclass(arr.dtype.type, (nt.single, nt.byte, nt.short, nt.ubyte,
                                   nt.ushort, nt.csingle)):
        return arr.astype(nt.csingle)
    else:
        return arr.astype(nt.cdouble)


            

Reported by Pylint.

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

Line: 113 Column: 1

                      return arr.astype(nt.cdouble)


def _fix_real_lt_zero(x):
    """Convert `x` to complex if it has real, negative components.

    Otherwise, output is just the array version of the input (via asarray).

    Parameters

            

Reported by Pylint.

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

Line: 141 Column: 1

                  return x


def _fix_int_lt_zero(x):
    """Convert `x` to double if it has real, negative components.

    Otherwise, output is just the array version of the input (via asarray).

    Parameters

            

Reported by Pylint.

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

Line: 168 Column: 1

                  return x


def _fix_real_abs_gt_1(x):
    """Convert `x` to complex if it has real components x_i with abs(x_i)>1.

    Otherwise, output is just the array version of the input (via asarray).

    Parameters

            

Reported by Pylint.

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

Line: 195 Column: 1

                  return x


def _unary_dispatcher(x):
    return (x,)


@array_function_dispatch(_unary_dispatcher)
def sqrt(x):

            

Reported by Pylint.

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

Line: 200 Column: 1

              

@array_function_dispatch(_unary_dispatcher)
def sqrt(x):
    """
    Compute the square root of x.

    For negative input elements, a complex value is returned
    (unlike `numpy.sqrt` which returns NaN).

            

Reported by Pylint.

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

Line: 244 Column: 1

              

@array_function_dispatch(_unary_dispatcher)
def log(x):
    """
    Compute the natural logarithm of `x`.

    Return the "principal value" (for a description of this, see `numpy.log`)
    of :math:`log_e(x)`. For real `x > 0`, this is a real number (``log(0)``

            

Reported by Pylint.

numpy/f2py/tests/test_assumed_shape.py
23 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import os
import pytest
import tempfile

from numpy.testing import assert_
from . import util


def _path(*a):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              import tempfile

from numpy.testing import assert_
from . import util


def _path(*a):
    return os.path.join(*((os.path.dirname(__file__),) + a))


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 24 Column: 9

                  @pytest.mark.slow
    def test_all(self):
        r = self.module.fsum([1, 2])
        assert_(r == 3, repr(r))
        r = self.module.sum([1, 2])
        assert_(r == 3, repr(r))
        r = self.module.sum_with_use([1, 2])
        assert_(r == 3, repr(r))


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 26 Column: 9

                      r = self.module.fsum([1, 2])
        assert_(r == 3, repr(r))
        r = self.module.sum([1, 2])
        assert_(r == 3, repr(r))
        r = self.module.sum_with_use([1, 2])
        assert_(r == 3, repr(r))

        r = self.module.mod.sum([1, 2])
        assert_(r == 3, repr(r))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 28 Column: 9

                      r = self.module.sum([1, 2])
        assert_(r == 3, repr(r))
        r = self.module.sum_with_use([1, 2])
        assert_(r == 3, repr(r))

        r = self.module.mod.sum([1, 2])
        assert_(r == 3, repr(r))
        r = self.module.mod.fsum([1, 2])
        assert_(r == 3, repr(r))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 31 Column: 9

                      assert_(r == 3, repr(r))

        r = self.module.mod.sum([1, 2])
        assert_(r == 3, repr(r))
        r = self.module.mod.fsum([1, 2])
        assert_(r == 3, repr(r))


class TestF2cmapOption(TestAssumedShapeSumExample):

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 33 Column: 9

                      r = self.module.mod.sum([1, 2])
        assert_(r == 3, repr(r))
        r = self.module.mod.fsum([1, 2])
        assert_(r == 3, repr(r))


class TestF2cmapOption(TestAssumedShapeSumExample):
    def setup(self):
        # Use a custom file name for .f2py_f2cmap

            

Reported by Pylint.

Attribute 'f2cmap_file' defined outside __init__
Error

Line: 42 Column: 9

                      self.sources = list(self.sources)
        f2cmap_src = self.sources.pop(-1)

        self.f2cmap_file = tempfile.NamedTemporaryFile(delete=False)
        with open(f2cmap_src, 'rb') as f:
            self.f2cmap_file.write(f.read())
        self.f2cmap_file.close()

        self.sources.append(self.f2cmap_file.name)

            

Reported by Pylint.

Attribute 'options' defined outside __init__
Error

Line: 48 Column: 9

                      self.f2cmap_file.close()

        self.sources.append(self.f2cmap_file.name)
        self.options = ["--f2cmap", self.f2cmap_file.name]

        super().setup()

    def teardown(self):
        os.unlink(self.f2cmap_file.name)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import pytest
import tempfile

from numpy.testing import assert_
from . import util


def _path(*a):

            

Reported by Pylint.