The following issues were found
numpy/typing/tests/data/pass/ufunc_config.py
43 issues
Line: 5
Column: 19
import numpy as np
def func1(a: str, b: int) -> None: ...
def func2(a: str, b: int, c: float = ...) -> None: ...
def func3(a: str, b: int) -> int: ...
class Write1:
def write(self, a: str) -> None: ...
Reported by Pylint.
Line: 5
Column: 11
import numpy as np
def func1(a: str, b: int) -> None: ...
def func2(a: str, b: int, c: float = ...) -> None: ...
def func3(a: str, b: int) -> int: ...
class Write1:
def write(self, a: str) -> None: ...
Reported by Pylint.
Line: 6
Column: 19
import numpy as np
def func1(a: str, b: int) -> None: ...
def func2(a: str, b: int, c: float = ...) -> None: ...
def func3(a: str, b: int) -> int: ...
class Write1:
def write(self, a: str) -> None: ...
Reported by Pylint.
Line: 6
Column: 11
import numpy as np
def func1(a: str, b: int) -> None: ...
def func2(a: str, b: int, c: float = ...) -> None: ...
def func3(a: str, b: int) -> int: ...
class Write1:
def write(self, a: str) -> None: ...
Reported by Pylint.
Line: 6
Column: 27
import numpy as np
def func1(a: str, b: int) -> None: ...
def func2(a: str, b: int, c: float = ...) -> None: ...
def func3(a: str, b: int) -> int: ...
class Write1:
def write(self, a: str) -> None: ...
Reported by Pylint.
Line: 7
Column: 19
def func1(a: str, b: int) -> None: ...
def func2(a: str, b: int, c: float = ...) -> None: ...
def func3(a: str, b: int) -> int: ...
class Write1:
def write(self, a: str) -> None: ...
class Write2:
Reported by Pylint.
Line: 7
Column: 11
def func1(a: str, b: int) -> None: ...
def func2(a: str, b: int, c: float = ...) -> None: ...
def func3(a: str, b: int) -> int: ...
class Write1:
def write(self, a: str) -> None: ...
class Write2:
Reported by Pylint.
Line: 10
Column: 21
def func3(a: str, b: int) -> int: ...
class Write1:
def write(self, a: str) -> None: ...
class Write2:
def write(self, a: str, b: int = ...) -> None: ...
class Write3:
Reported by Pylint.
Line: 13
Column: 21
def write(self, a: str) -> None: ...
class Write2:
def write(self, a: str, b: int = ...) -> None: ...
class Write3:
def write(self, a: str) -> int: ...
Reported by Pylint.
Line: 13
Column: 29
def write(self, a: str) -> None: ...
class Write2:
def write(self, a: str, b: int = ...) -> None: ...
class Write3:
def write(self, a: str) -> int: ...
Reported by Pylint.
numpy/lib/_datasource.py
42 issues
Line: 73
Column: 3
# to reduce the initial 'import numpy' overhead by
# deferring the import of lzma, bz2 and gzip until needed
# TODO: .zip support, .tar support?
class _FileOpeners:
"""
Container for different methods to open (un-)compressed files.
`_FileOpeners` contains a dictionary that holds one method for each
Reported by Pylint.
Line: 155
Column: 1
_file_openers = _FileOpeners()
def open(path, mode='r', destpath=os.curdir, encoding=None, newline=None):
"""
Open `path` with `mode` and return the file object.
If ``path`` is an URL, it will be downloaded, stored in the
`DataSource` `destpath` directory and opened from there.
Reported by Pylint.
Line: 267
Column: 9
"""Test if the filename is a zip file by looking at the file extension.
"""
fname, ext = os.path.splitext(filename)
return ext in _file_openers.keys()
def _iswritemode(self, mode):
"""Test if the given mode will open a file for writing."""
Reported by Pylint.
Line: 314
Column: 41
# test that also? Similar to the way we append .gz and test for
# for compressed versions of files.
scheme, netloc, upath, uparams, uquery, ufrag = urlparse(path)
return bool(scheme and netloc)
def _cache(self, path):
"""Cache the file specified by path.
Reported by Pylint.
Line: 314
Column: 49
# test that also? Similar to the way we append .gz and test for
# for compressed versions of files.
scheme, netloc, upath, uparams, uquery, ufrag = urlparse(path)
return bool(scheme and netloc)
def _cache(self, path):
"""Cache the file specified by path.
Reported by Pylint.
Line: 314
Column: 25
# test that also? Similar to the way we append .gz and test for
# for compressed versions of files.
scheme, netloc, upath, uparams, uquery, ufrag = urlparse(path)
return bool(scheme and netloc)
def _cache(self, path):
"""Cache the file specified by path.
Reported by Pylint.
Line: 314
Column: 32
# test that also? Similar to the way we append .gz and test for
# for compressed versions of files.
scheme, netloc, upath, uparams, uquery, ufrag = urlparse(path)
return bool(scheme and netloc)
def _cache(self, path):
"""Cache the file specified by path.
Reported by Pylint.
Line: 327
Column: 9
# a significant fraction of numpy's total import time.
import shutil
from urllib.request import urlopen
from urllib.error import URLError
upath = self.abspath(path)
# ensure directory exists
if not os.path.exists(os.path.dirname(upath)):
Reported by Pylint.
Line: 335
Column: 3
if not os.path.exists(os.path.dirname(upath)):
os.makedirs(os.path.dirname(upath))
# TODO: Doesn't handle compressed files!
if self._isurl(path):
with urlopen(path) as openedurl:
with _open(upath, 'wb') as f:
shutil.copyfileobj(openedurl, f)
else:
Reported by Pylint.
Line: 337
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b310-urllib-urlopen
# TODO: Doesn't handle compressed files!
if self._isurl(path):
with urlopen(path) as openedurl:
with _open(upath, 'wb') as f:
shutil.copyfileobj(openedurl, f)
else:
shutil.copyfile(path, upath)
return upath
Reported by Bandit.
numpy/testing/_private/parameterized.py
42 issues
Line: 102
Column: 13
except TypeError as e:
if "after * must be" not in str(e):
raise
raise TypeError(
"Parameters must be tuples, but %r is not (hint: use '(%r, )')"
%(args, args),
)
def __repr__(self):
Reported by Pylint.
Line: 140
Column: 15
>>> parameterized_argument_value_pairs(func, p)
[("foo", 1), ("*args", (16, ))]
"""
argspec = inspect.getargspec(func)
arg_offset = 1 if argspec.args[:1] == ["self"] else 0
named_args = argspec.args[arg_offset:]
result = list(zip(named_args, p.args))
Reported by Pylint.
Line: 189
Column: 28
x_repr = x_repr[:n//2] + "..." + x_repr[len(x_repr) - n//2:]
return x_repr
def default_doc_func(func, num, p):
if func.__doc__ is None:
return None
all_args_with_values = parameterized_argument_value_pairs(func, p)
Reported by Pylint.
Line: 226
Column: 5
}
def set_test_runner(name):
global _test_runner_override
if name not in _test_runners:
raise TypeError(
"Invalid test runner: %r (must be one of: %s)"
%(name, ", ".join(_test_runners)),
)
Reported by Pylint.
Line: 241
Column: 5
stack frame immediately outside. """
if _test_runner_override is not None:
return _test_runner_override
global _test_runner_guess
if _test_runner_guess is False:
stack = inspect.stack()
for record in reversed(stack):
frame = record[0]
module = frame.f_globals.get("__name__").partition(".")[0]
Reported by Pylint.
Line: 277
Column: 24
assert_equal(a + b, expected)
"""
def __init__(self, input, doc_func=None):
self.get_input = self.input_as_callable(input)
self.doc_func = doc_func or default_doc_func
def __call__(self, test_func):
self.assert_not_in_testcase_subclass()
Reported by Pylint.
Line: 344
Column: 16
return []
_, _, parents = code_context.partition("(")
parents, _, _ = parents.partition(")")
return eval("[" + parents + "]", frame[0].f_globals, frame[0].f_locals)
@classmethod
def input_as_callable(cls, input):
if callable(input):
return lambda: cls.check_input_values(input())
Reported by Pylint.
Line: 344
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
return []
_, _, parents = code_context.partition("(")
parents, _, _ = parents.partition(")")
return eval("[" + parents + "]", frame[0].f_globals, frame[0].f_locals)
@classmethod
def input_as_callable(cls, input):
if callable(input):
return lambda: cls.check_input_values(input())
Reported by Bandit.
Line: 347
Column: 32
return eval("[" + parents + "]", frame[0].f_globals, frame[0].f_locals)
@classmethod
def input_as_callable(cls, input):
if callable(input):
return lambda: cls.check_input_values(input())
input_values = cls.check_input_values(input)
return lambda: input_values
Reported by Pylint.
Line: 365
Column: 21
return [ param.from_decorator(p) for p in input_values ]
@classmethod
def expand(cls, input, name_func=None, doc_func=None, **legacy):
""" A "brute force" method of parameterizing test cases. Creates new
test cases and injects them into the namespace that the wrapped
function is being defined in. Useful for parameterizing tests in
subclasses of 'UnitTest', where Nose test generators don't work.
Reported by Pylint.
numpy/core/tests/test_simd_module.py
42 issues
Line: 1
Column: 1
import pytest
from numpy.core._simd import targets
"""
This testing unit only for checking the sanity of common functionality,
therefore all we need is just to take one submodule that represents any
of enabled SIMD extensions to run the test on it and the second submodule
required to run only one check related to the possibility of mixing
the data types among each submodule.
"""
Reported by Pylint.
Line: 2
Column: 1
import pytest
from numpy.core._simd import targets
"""
This testing unit only for checking the sanity of common functionality,
therefore all we need is just to take one submodule that represents any
of enabled SIMD extensions to run the test on it and the second submodule
required to run only one check related to the possibility of mixing
the data types among each submodule.
"""
Reported by Pylint.
Line: 3
Column: 1
import pytest
from numpy.core._simd import targets
"""
This testing unit only for checking the sanity of common functionality,
therefore all we need is just to take one submodule that represents any
of enabled SIMD extensions to run the test on it and the second submodule
required to run only one check related to the possibility of mixing
the data types among each submodule.
"""
Reported by Pylint.
Line: 39
Column: 60
def test_raises(self):
a, b = [npyv.setall_u32(1)]*2
for sfx in all_sfx:
vcb = lambda intrin: getattr(npyv, f"{intrin}_{sfx}")
pytest.raises(TypeError, vcb("add"), a)
pytest.raises(TypeError, vcb("add"), a, b, a)
pytest.raises(TypeError, vcb("setall"))
pytest.raises(TypeError, vcb("setall"), [1])
pytest.raises(TypeError, vcb("load"), 1)
Reported by Pylint.
Line: 1
Column: 1
import pytest
from numpy.core._simd import targets
"""
This testing unit only for checking the sanity of common functionality,
therefore all we need is just to take one submodule that represents any
of enabled SIMD extensions to run the test on it and the second submodule
required to run only one check related to the possibility of mixing
the data types among each submodule.
"""
Reported by Pylint.
Line: 23
Column: 1
all_sfx = unsigned_sfx + int_sfx
@pytest.mark.skipif(not npyv, reason="could not find any SIMD extension with NPYV support")
class Test_SIMD_MODULE:
@pytest.mark.parametrize('sfx', all_sfx)
def test_num_lanes(self, sfx):
nlanes = getattr(npyv, "nlanes_" + sfx)
vector = getattr(npyv, "setall_" + sfx)(1)
Reported by Pylint.
Line: 23
Column: 1
all_sfx = unsigned_sfx + int_sfx
@pytest.mark.skipif(not npyv, reason="could not find any SIMD extension with NPYV support")
class Test_SIMD_MODULE:
@pytest.mark.parametrize('sfx', all_sfx)
def test_num_lanes(self, sfx):
nlanes = getattr(npyv, "nlanes_" + sfx)
vector = getattr(npyv, "setall_" + sfx)(1)
Reported by Pylint.
Line: 26
Column: 5
class Test_SIMD_MODULE:
@pytest.mark.parametrize('sfx', all_sfx)
def test_num_lanes(self, sfx):
nlanes = getattr(npyv, "nlanes_" + sfx)
vector = getattr(npyv, "setall_" + sfx)(1)
assert len(vector) == nlanes
@pytest.mark.parametrize('sfx', all_sfx)
Reported by Pylint.
Line: 26
Column: 5
class Test_SIMD_MODULE:
@pytest.mark.parametrize('sfx', all_sfx)
def test_num_lanes(self, sfx):
nlanes = getattr(npyv, "nlanes_" + sfx)
vector = getattr(npyv, "setall_" + sfx)(1)
assert len(vector) == nlanes
@pytest.mark.parametrize('sfx', all_sfx)
Reported by Pylint.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_num_lanes(self, sfx):
nlanes = getattr(npyv, "nlanes_" + sfx)
vector = getattr(npyv, "setall_" + sfx)(1)
assert len(vector) == nlanes
@pytest.mark.parametrize('sfx', all_sfx)
def test_type_name(self, sfx):
vector = getattr(npyv, "setall_" + sfx)(1)
assert vector.__name__ == "npyv_" + sfx
Reported by Bandit.
numpy/core/tests/test_scalarbuffer.py
42 issues
Line: 5
Column: 1
Test scalar buffer interface adheres to PEP 3118
"""
import numpy as np
from numpy.core._rational_tests import rational
from numpy.core._multiarray_tests import get_buffer_info
import pytest
from numpy.testing import assert_, assert_equal, assert_raises
Reported by Pylint.
Line: 6
Column: 1
"""
import numpy as np
from numpy.core._rational_tests import rational
from numpy.core._multiarray_tests import get_buffer_info
import pytest
from numpy.testing import assert_, assert_equal, assert_raises
# PEP3118 format strings for native (standard alignment and byteorder) types
Reported by Pylint.
Line: 7
Column: 1
import numpy as np
from numpy.core._rational_tests import rational
from numpy.core._multiarray_tests import get_buffer_info
import pytest
from numpy.testing import assert_, assert_equal, assert_raises
# PEP3118 format strings for native (standard alignment and byteorder) types
scalars_and_codes = [
Reported by Pylint.
Line: 74
Column: 9
def test_void_scalar_structured_data(self):
dt = np.dtype([('name', np.unicode_, 16), ('grades', np.float64, (2,))])
x = np.array(('ndarray_scalar', (1.2, 3.0)), dtype=dt)[()]
assert_(isinstance(x, np.void))
mv_x = memoryview(x)
expected_size = 16 * np.dtype((np.unicode_, 1)).itemsize
expected_size += 2 * np.dtype(np.float64).itemsize
assert_equal(mv_x.itemsize, expected_size)
assert_equal(mv_x.ndim, 0)
Reported by Pylint.
Line: 86
Column: 9
# check scalar format string against ndarray format string
a = np.array([('Sarah', (8.0, 7.0)), ('John', (6.0, 7.0))], dtype=dt)
assert_(isinstance(a, np.ndarray))
mv_a = memoryview(a)
assert_equal(mv_x.itemsize, mv_a.itemsize)
assert_equal(mv_x.format, mv_a.format)
# Check that we do not allow writeable buffer export (technically
Reported by Pylint.
Line: 9
Column: 1
from numpy.core._multiarray_tests import get_buffer_info
import pytest
from numpy.testing import assert_, assert_equal, assert_raises
# PEP3118 format strings for native (standard alignment and byteorder) types
scalars_and_codes = [
(np.bool_, '?'),
(np.byte, 'b'),
Reported by Pylint.
Line: 35
Column: 1
scalars_only, codes_only = zip(*scalars_and_codes)
class TestScalarPEP3118:
@pytest.mark.parametrize('scalar', scalars_only, ids=codes_only)
def test_scalar_match_array(self, scalar):
x = scalar()
a = np.array([], dtype=np.dtype(scalar))
Reported by Pylint.
Line: 38
Column: 5
class TestScalarPEP3118:
@pytest.mark.parametrize('scalar', scalars_only, ids=codes_only)
def test_scalar_match_array(self, scalar):
x = scalar()
a = np.array([], dtype=np.dtype(scalar))
mv_x = memoryview(x)
mv_a = memoryview(a)
assert_equal(mv_x.format, mv_a.format)
Reported by Pylint.
Line: 38
Column: 5
class TestScalarPEP3118:
@pytest.mark.parametrize('scalar', scalars_only, ids=codes_only)
def test_scalar_match_array(self, scalar):
x = scalar()
a = np.array([], dtype=np.dtype(scalar))
mv_x = memoryview(x)
mv_a = memoryview(a)
assert_equal(mv_x.format, mv_a.format)
Reported by Pylint.
Line: 39
Column: 9
@pytest.mark.parametrize('scalar', scalars_only, ids=codes_only)
def test_scalar_match_array(self, scalar):
x = scalar()
a = np.array([], dtype=np.dtype(scalar))
mv_x = memoryview(x)
mv_a = memoryview(a)
assert_equal(mv_x.format, mv_a.format)
Reported by Pylint.
numpy/core/tests/test_indexerrors.py
42 issues
Line: 1
Column: 1
import numpy as np
from numpy.testing import (
assert_raises, assert_raises_regex,
)
class TestIndexErrors:
'''Tests to exercise indexerrors not covered by other tests.'''
Reported by Pylint.
Line: 10
Column: 5
class TestIndexErrors:
'''Tests to exercise indexerrors not covered by other tests.'''
def test_arraytypes_fasttake(self):
'take from a 0-length dimension'
x = np.empty((2, 3, 0, 4))
assert_raises(IndexError, x.take, [0], axis=2)
assert_raises(IndexError, x.take, [1], axis=2)
assert_raises(IndexError, x.take, [0], axis=2, mode='wrap')
Reported by Pylint.
Line: 12
Column: 9
def test_arraytypes_fasttake(self):
'take from a 0-length dimension'
x = np.empty((2, 3, 0, 4))
assert_raises(IndexError, x.take, [0], axis=2)
assert_raises(IndexError, x.take, [1], axis=2)
assert_raises(IndexError, x.take, [0], axis=2, mode='wrap')
assert_raises(IndexError, x.take, [0], axis=2, mode='clip')
Reported by Pylint.
Line: 18
Column: 5
assert_raises(IndexError, x.take, [0], axis=2, mode='wrap')
assert_raises(IndexError, x.take, [0], axis=2, mode='clip')
def test_take_from_object(self):
# Check exception taking from object array
d = np.zeros(5, dtype=object)
assert_raises(IndexError, d.take, [6])
# Check exception taking from 0-d array
Reported by Pylint.
Line: 18
Column: 5
assert_raises(IndexError, x.take, [0], axis=2, mode='wrap')
assert_raises(IndexError, x.take, [0], axis=2, mode='clip')
def test_take_from_object(self):
# Check exception taking from object array
d = np.zeros(5, dtype=object)
assert_raises(IndexError, d.take, [6])
# Check exception taking from 0-d array
Reported by Pylint.
Line: 20
Column: 9
def test_take_from_object(self):
# Check exception taking from object array
d = np.zeros(5, dtype=object)
assert_raises(IndexError, d.take, [6])
# Check exception taking from 0-d array
d = np.zeros((5, 0), dtype=object)
assert_raises(IndexError, d.take, [1], axis=1)
Reported by Pylint.
Line: 24
Column: 9
assert_raises(IndexError, d.take, [6])
# Check exception taking from 0-d array
d = np.zeros((5, 0), dtype=object)
assert_raises(IndexError, d.take, [1], axis=1)
assert_raises(IndexError, d.take, [0], axis=1)
assert_raises(IndexError, d.take, [0])
assert_raises(IndexError, d.take, [0], mode='wrap')
assert_raises(IndexError, d.take, [0], mode='clip')
Reported by Pylint.
Line: 31
Column: 5
assert_raises(IndexError, d.take, [0], mode='wrap')
assert_raises(IndexError, d.take, [0], mode='clip')
def test_multiindex_exceptions(self):
a = np.empty(5, dtype=object)
assert_raises(IndexError, a.item, 20)
a = np.empty((5, 0), dtype=object)
assert_raises(IndexError, a.item, (0, 0))
Reported by Pylint.
Line: 31
Column: 5
assert_raises(IndexError, d.take, [0], mode='wrap')
assert_raises(IndexError, d.take, [0], mode='clip')
def test_multiindex_exceptions(self):
a = np.empty(5, dtype=object)
assert_raises(IndexError, a.item, 20)
a = np.empty((5, 0), dtype=object)
assert_raises(IndexError, a.item, (0, 0))
Reported by Pylint.
Line: 32
Column: 9
assert_raises(IndexError, d.take, [0], mode='clip')
def test_multiindex_exceptions(self):
a = np.empty(5, dtype=object)
assert_raises(IndexError, a.item, 20)
a = np.empty((5, 0), dtype=object)
assert_raises(IndexError, a.item, (0, 0))
a = np.empty(5, dtype=object)
Reported by Pylint.
numpy/core/function_base.py
42 issues
Line: 6
Column: 1
import operator
import types
from . import numeric as _nx
from .numeric import result_type, NaN, asanyarray, ndim
from numpy.core.multiarray import add_docstring
from numpy.core import overrides
__all__ = ['logspace', 'linspace', 'geomspace']
Reported by Pylint.
Line: 7
Column: 1
import types
from . import numeric as _nx
from .numeric import result_type, NaN, asanyarray, ndim
from numpy.core.multiarray import add_docstring
from numpy.core import overrides
__all__ = ['logspace', 'linspace', 'geomspace']
Reported by Pylint.
Line: 18
Column: 64
overrides.array_function_dispatch, module='numpy')
def _linspace_dispatcher(start, stop, num=None, endpoint=None, retstep=None,
dtype=None, axis=None):
return (start, stop)
@array_function_dispatch(_linspace_dispatcher)
Reported by Pylint.
Line: 18
Column: 49
overrides.array_function_dispatch, module='numpy')
def _linspace_dispatcher(start, stop, num=None, endpoint=None, retstep=None,
dtype=None, axis=None):
return (start, stop)
@array_function_dispatch(_linspace_dispatcher)
Reported by Pylint.
Line: 18
Column: 39
overrides.array_function_dispatch, module='numpy')
def _linspace_dispatcher(start, stop, num=None, endpoint=None, retstep=None,
dtype=None, axis=None):
return (start, stop)
@array_function_dispatch(_linspace_dispatcher)
Reported by Pylint.
Line: 19
Column: 26
def _linspace_dispatcher(start, stop, num=None, endpoint=None, retstep=None,
dtype=None, axis=None):
return (start, stop)
@array_function_dispatch(_linspace_dispatcher)
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None,
Reported by Pylint.
Line: 19
Column: 38
def _linspace_dispatcher(start, stop, num=None, endpoint=None, retstep=None,
dtype=None, axis=None):
return (start, stop)
@array_function_dispatch(_linspace_dispatcher)
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None,
Reported by Pylint.
Line: 178
Column: 64
return y.astype(dtype, copy=False)
def _logspace_dispatcher(start, stop, num=None, endpoint=None, base=None,
dtype=None, axis=None):
return (start, stop)
@array_function_dispatch(_logspace_dispatcher)
Reported by Pylint.
Line: 178
Column: 49
return y.astype(dtype, copy=False)
def _logspace_dispatcher(start, stop, num=None, endpoint=None, base=None,
dtype=None, axis=None):
return (start, stop)
@array_function_dispatch(_logspace_dispatcher)
Reported by Pylint.
Line: 178
Column: 39
return y.astype(dtype, copy=False)
def _logspace_dispatcher(start, stop, num=None, endpoint=None, base=None,
dtype=None, axis=None):
return (start, stop)
@array_function_dispatch(_logspace_dispatcher)
Reported by Pylint.
numpy/distutils/command/build_clib.py
41 issues
Line: 133
Column: 17
# multiple times within the same os process/thread without
# giving the chance the previous instances of `CCompilerOpt`
# to update the cache.
self.compiler_opt.cache_flush()
self.compiler_opt = new_ccompiler_opt(
compiler=self.compiler, dispatch_hpath=dispatch_hpath,
cpu_baseline=self.cpu_baseline, cpu_dispatch=self.cpu_dispatch,
cache_path=opt_cache_path
Reported by Pylint.
Line: 319
Column: 27
include_dirs=include_dirs,
debug=self.debug,
extra_postargs=extra_postargs,
ccompiler=cxx_compiler
)
if copt_c_sources:
log.info("compiling C dispatch-able sources")
objects += self.compiler_opt.try_dispatch(copt_c_sources,
Reported by Pylint.
Line: 63
Column: 17
def finalize_options(self):
if self.parallel:
try:
self.parallel = int(self.parallel)
except ValueError as e:
raise ValueError("--parallel/-j argument must be an integer") from e
old_build_clib.finalize_options(self)
self.set_undefined_options('build',
('parallel', 'parallel'),
Reported by Pylint.
Line: 76
Column: 14
)
def have_f_sources(self):
for (lib_name, build_info) in self.libraries:
if has_f_sources(build_info.get('sources', [])):
return True
return False
def have_cxx_sources(self):
Reported by Pylint.
Line: 82
Column: 14
return False
def have_cxx_sources(self):
for (lib_name, build_info) in self.libraries:
if has_cxx_sources(build_info.get('sources', [])):
return True
return False
def run(self):
Reported by Pylint.
Line: 97
Column: 14
# Make sure that extension sources are complete.
self.run_command('build_src')
for (lib_name, build_info) in self.libraries:
l = build_info.get('language', None)
if l and l not in languages:
languages.append(l)
from distutils.ccompiler import new_compiler
Reported by Pylint.
Line: 103
Column: 9
languages.append(l)
from distutils.ccompiler import new_compiler
self.compiler = new_compiler(compiler=self.compiler,
dry_run=self.dry_run,
force=self.force)
self.compiler.customize(self.distribution,
need_cxx=self.have_cxx_sources())
Reported by Pylint.
Line: 114
Column: 9
self.compiler.compiler_so.append('-Werror')
libraries = self.libraries
self.libraries = None
self.compiler.customize_cmd(self)
self.libraries = libraries
self.compiler.show_customization()
Reported by Pylint.
Line: 116
Column: 9
libraries = self.libraries
self.libraries = None
self.compiler.customize_cmd(self)
self.libraries = libraries
self.compiler.show_customization()
if not self.disable_optimization:
dispatch_hpath = os.path.join("numpy", "distutils", "include", "npy_cpu_dispatch_config.h")
Reported by Pylint.
Line: 135
Column: 13
# to update the cache.
self.compiler_opt.cache_flush()
self.compiler_opt = new_ccompiler_opt(
compiler=self.compiler, dispatch_hpath=dispatch_hpath,
cpu_baseline=self.cpu_baseline, cpu_dispatch=self.cpu_dispatch,
cache_path=opt_cache_path
)
def report(copt):
Reported by Pylint.
numpy/lib/index_tricks.py
41 issues
Line: 13
Column: 1
from numpy.core.numerictypes import find_common_type, issubdtype
import numpy.matrixlib as matrixlib
from .function_base import diff
from numpy.core.multiarray import ravel_multi_index, unravel_index
from numpy.core.overrides import set_module
from numpy.core import overrides, linspace
from numpy.lib.stride_tricks import as_strided
Reported by Pylint.
Line: 775
Column: 39
# applicable to N-dimensions.
def _fill_diagonal_dispatcher(a, val, wrap=None):
return (a,)
@array_function_dispatch(_fill_diagonal_dispatcher)
def fill_diagonal(a, val, wrap=False):
Reported by Pylint.
Line: 775
Column: 34
# applicable to N-dimensions.
def _fill_diagonal_dispatcher(a, val, wrap=None):
return (a,)
@array_function_dispatch(_fill_diagonal_dispatcher)
def fill_diagonal(a, val, wrap=False):
Reported by Pylint.
Line: 914
Column: 21
@set_module('numpy')
def diag_indices(n, ndim=2):
"""
Return the indices to access the main diagonal of an array.
This returns a tuple of indices that can be used to access the main
diagonal of an array `a` with ``a.ndim >= 2`` dimensions and shape
Reported by Pylint.
Line: 1
Column: 1
import functools
import sys
import math
import warnings
import numpy.core.numeric as _nx
from numpy.core.numeric import (
asarray, ScalarType, array, alltrue, cumprod, arange, ndim
)
Reported by Pylint.
Line: 1
Column: 1
import functools
import sys
import math
import warnings
import numpy.core.numeric as _nx
from numpy.core.numeric import (
asarray, ScalarType, array, alltrue, cumprod, arange, ndim
)
Reported by Pylint.
Line: 14
Column: 1
import numpy.matrixlib as matrixlib
from .function_base import diff
from numpy.core.multiarray import ravel_multi_index, unravel_index
from numpy.core.overrides import set_module
from numpy.core import overrides, linspace
from numpy.lib.stride_tricks import as_strided
Reported by Pylint.
Line: 15
Column: 1
import numpy.matrixlib as matrixlib
from .function_base import diff
from numpy.core.multiarray import ravel_multi_index, unravel_index
from numpy.core.overrides import set_module
from numpy.core import overrides, linspace
from numpy.lib.stride_tricks import as_strided
array_function_dispatch = functools.partial(
Reported by Pylint.
Line: 16
Column: 1
from .function_base import diff
from numpy.core.multiarray import ravel_multi_index, unravel_index
from numpy.core.overrides import set_module
from numpy.core import overrides, linspace
from numpy.lib.stride_tricks import as_strided
array_function_dispatch = functools.partial(
overrides.array_function_dispatch, module='numpy')
Reported by Pylint.
Line: 17
Column: 1
from numpy.core.multiarray import ravel_multi_index, unravel_index
from numpy.core.overrides import set_module
from numpy.core import overrides, linspace
from numpy.lib.stride_tricks import as_strided
array_function_dispatch = functools.partial(
overrides.array_function_dispatch, module='numpy')
Reported by Pylint.
numpy/typing/tests/data/reveal/modules.py
41 issues
Line: 4
Column: 1
import numpy as np
from numpy import f2py
reveal_type(np) # E: ModuleType
reveal_type(np.char) # E: ModuleType
reveal_type(np.ctypeslib) # E: ModuleType
reveal_type(np.emath) # E: ModuleType
reveal_type(np.fft) # E: ModuleType
Reported by Pylint.
Line: 6
Column: 1
reveal_type(np) # E: ModuleType
reveal_type(np.char) # E: ModuleType
reveal_type(np.ctypeslib) # E: ModuleType
reveal_type(np.emath) # E: ModuleType
reveal_type(np.fft) # E: ModuleType
reveal_type(np.lib) # E: ModuleType
reveal_type(np.linalg) # E: ModuleType
Reported by Pylint.
Line: 7
Column: 1
reveal_type(np) # E: ModuleType
reveal_type(np.char) # E: ModuleType
reveal_type(np.ctypeslib) # E: ModuleType
reveal_type(np.emath) # E: ModuleType
reveal_type(np.fft) # E: ModuleType
reveal_type(np.lib) # E: ModuleType
reveal_type(np.linalg) # E: ModuleType
reveal_type(np.ma) # E: ModuleType
Reported by Pylint.
Line: 8
Column: 1
reveal_type(np.char) # E: ModuleType
reveal_type(np.ctypeslib) # E: ModuleType
reveal_type(np.emath) # E: ModuleType
reveal_type(np.fft) # E: ModuleType
reveal_type(np.lib) # E: ModuleType
reveal_type(np.linalg) # E: ModuleType
reveal_type(np.ma) # E: ModuleType
reveal_type(np.matrixlib) # E: ModuleType
Reported by Pylint.
Line: 9
Column: 1
reveal_type(np.char) # E: ModuleType
reveal_type(np.ctypeslib) # E: ModuleType
reveal_type(np.emath) # E: ModuleType
reveal_type(np.fft) # E: ModuleType
reveal_type(np.lib) # E: ModuleType
reveal_type(np.linalg) # E: ModuleType
reveal_type(np.ma) # E: ModuleType
reveal_type(np.matrixlib) # E: ModuleType
reveal_type(np.polynomial) # E: ModuleType
Reported by Pylint.
Line: 10
Column: 1
reveal_type(np.ctypeslib) # E: ModuleType
reveal_type(np.emath) # E: ModuleType
reveal_type(np.fft) # E: ModuleType
reveal_type(np.lib) # E: ModuleType
reveal_type(np.linalg) # E: ModuleType
reveal_type(np.ma) # E: ModuleType
reveal_type(np.matrixlib) # E: ModuleType
reveal_type(np.polynomial) # E: ModuleType
reveal_type(np.random) # E: ModuleType
Reported by Pylint.
Line: 11
Column: 1
reveal_type(np.emath) # E: ModuleType
reveal_type(np.fft) # E: ModuleType
reveal_type(np.lib) # E: ModuleType
reveal_type(np.linalg) # E: ModuleType
reveal_type(np.ma) # E: ModuleType
reveal_type(np.matrixlib) # E: ModuleType
reveal_type(np.polynomial) # E: ModuleType
reveal_type(np.random) # E: ModuleType
reveal_type(np.rec) # E: ModuleType
Reported by Pylint.
Line: 12
Column: 1
reveal_type(np.fft) # E: ModuleType
reveal_type(np.lib) # E: ModuleType
reveal_type(np.linalg) # E: ModuleType
reveal_type(np.ma) # E: ModuleType
reveal_type(np.matrixlib) # E: ModuleType
reveal_type(np.polynomial) # E: ModuleType
reveal_type(np.random) # E: ModuleType
reveal_type(np.rec) # E: ModuleType
reveal_type(np.testing) # E: ModuleType
Reported by Pylint.
Line: 13
Column: 1
reveal_type(np.lib) # E: ModuleType
reveal_type(np.linalg) # E: ModuleType
reveal_type(np.ma) # E: ModuleType
reveal_type(np.matrixlib) # E: ModuleType
reveal_type(np.polynomial) # E: ModuleType
reveal_type(np.random) # E: ModuleType
reveal_type(np.rec) # E: ModuleType
reveal_type(np.testing) # E: ModuleType
reveal_type(np.version) # E: ModuleType
Reported by Pylint.
Line: 14
Column: 1
reveal_type(np.linalg) # E: ModuleType
reveal_type(np.ma) # E: ModuleType
reveal_type(np.matrixlib) # E: ModuleType
reveal_type(np.polynomial) # E: ModuleType
reveal_type(np.random) # E: ModuleType
reveal_type(np.rec) # E: ModuleType
reveal_type(np.testing) # E: ModuleType
reveal_type(np.version) # E: ModuleType
Reported by Pylint.