The following issues were found
numpy/core/tests/test__exceptions.py
53 issues
Line: 7
Column: 1
import pickle
import pytest
import numpy as np
_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError
Reported by Pylint.
Line: 10
Column: 21
import pytest
import numpy as np
_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError
class TestArrayMemoryError:
def test_pickling(self):
""" Test that _ArrayMemoryError can be pickled """
Reported by Pylint.
Line: 10
Column: 21
import pytest
import numpy as np
_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError
class TestArrayMemoryError:
def test_pickling(self):
""" Test that _ArrayMemoryError can be pickled """
Reported by Pylint.
Line: 11
Column: 21
import numpy as np
_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError
class TestArrayMemoryError:
def test_pickling(self):
""" Test that _ArrayMemoryError can be pickled """
error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
Reported by Pylint.
Line: 11
Column: 21
import numpy as np
_ArrayMemoryError = np.core._exceptions._ArrayMemoryError
_UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError
class TestArrayMemoryError:
def test_pickling(self):
""" Test that _ArrayMemoryError can be pickled """
error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
Reported by Pylint.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b301-pickle
def test_pickling(self):
""" Test that _ArrayMemoryError can be pickled """
error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
res = pickle.loads(pickle.dumps(error))
assert res._total_size == error._total_size
def test_str(self):
e = _ArrayMemoryError((1023,), np.dtype(np.uint8))
str(e) # not crashing is enough
Reported by Bandit.
Line: 18
Column: 16
""" Test that _ArrayMemoryError can be pickled """
error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
res = pickle.loads(pickle.dumps(error))
assert res._total_size == error._total_size
def test_str(self):
e = _ArrayMemoryError((1023,), np.dtype(np.uint8))
str(e) # not crashing is enough
Reported by Pylint.
Line: 18
Column: 35
""" Test that _ArrayMemoryError can be pickled """
error = _ArrayMemoryError((1023,), np.dtype(np.uint8))
res = pickle.loads(pickle.dumps(error))
assert res._total_size == error._total_size
def test_str(self):
e = _ArrayMemoryError((1023,), np.dtype(np.uint8))
str(e) # not crashing is enough
Reported by Pylint.
Line: 27
Column: 13
# testing these properties is easier than testing the full string repr
def test__size_to_string(self):
""" Test e._size_to_string """
f = _ArrayMemoryError._size_to_string
Ki = 1024
assert f(0) == '0 bytes'
assert f(1) == '1 bytes'
assert f(1023) == '1023 bytes'
assert f(Ki) == '1.00 KiB'
Reported by Pylint.
Line: 50
Column: 16
def test__total_size(self):
""" Test e._total_size """
e = _ArrayMemoryError((1,), np.dtype(np.uint8))
assert e._total_size == 1
e = _ArrayMemoryError((2, 4), np.dtype((np.uint64, 16)))
assert e._total_size == 1024
Reported by Pylint.
numpy/typing/tests/data/reveal/numeric.py
52 issues
Line: 20
Column: 1
B: List[int]
C: SubClass
reveal_type(np.count_nonzero(i8)) # E: int
reveal_type(np.count_nonzero(A)) # E: int
reveal_type(np.count_nonzero(B)) # E: int
reveal_type(np.count_nonzero(A, keepdims=True)) # E: Any
reveal_type(np.count_nonzero(A, axis=0)) # E: Any
Reported by Pylint.
Line: 21
Column: 1
C: SubClass
reveal_type(np.count_nonzero(i8)) # E: int
reveal_type(np.count_nonzero(A)) # E: int
reveal_type(np.count_nonzero(B)) # E: int
reveal_type(np.count_nonzero(A, keepdims=True)) # E: Any
reveal_type(np.count_nonzero(A, axis=0)) # E: Any
reveal_type(np.isfortran(i8)) # E: bool
Reported by Pylint.
Line: 22
Column: 1
reveal_type(np.count_nonzero(i8)) # E: int
reveal_type(np.count_nonzero(A)) # E: int
reveal_type(np.count_nonzero(B)) # E: int
reveal_type(np.count_nonzero(A, keepdims=True)) # E: Any
reveal_type(np.count_nonzero(A, axis=0)) # E: Any
reveal_type(np.isfortran(i8)) # E: bool
reveal_type(np.isfortran(A)) # E: bool
Reported by Pylint.
Line: 23
Column: 1
reveal_type(np.count_nonzero(i8)) # E: int
reveal_type(np.count_nonzero(A)) # E: int
reveal_type(np.count_nonzero(B)) # E: int
reveal_type(np.count_nonzero(A, keepdims=True)) # E: Any
reveal_type(np.count_nonzero(A, axis=0)) # E: Any
reveal_type(np.isfortran(i8)) # E: bool
reveal_type(np.isfortran(A)) # E: bool
Reported by Pylint.
Line: 24
Column: 1
reveal_type(np.count_nonzero(A)) # E: int
reveal_type(np.count_nonzero(B)) # E: int
reveal_type(np.count_nonzero(A, keepdims=True)) # E: Any
reveal_type(np.count_nonzero(A, axis=0)) # E: Any
reveal_type(np.isfortran(i8)) # E: bool
reveal_type(np.isfortran(A)) # E: bool
reveal_type(np.argwhere(i8)) # E: numpy.ndarray[Any, Any]
Reported by Pylint.
Line: 26
Column: 1
reveal_type(np.count_nonzero(A, keepdims=True)) # E: Any
reveal_type(np.count_nonzero(A, axis=0)) # E: Any
reveal_type(np.isfortran(i8)) # E: bool
reveal_type(np.isfortran(A)) # E: bool
reveal_type(np.argwhere(i8)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argwhere(A)) # E: numpy.ndarray[Any, Any]
Reported by Pylint.
Line: 27
Column: 1
reveal_type(np.count_nonzero(A, axis=0)) # E: Any
reveal_type(np.isfortran(i8)) # E: bool
reveal_type(np.isfortran(A)) # E: bool
reveal_type(np.argwhere(i8)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argwhere(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.flatnonzero(i8)) # E: numpy.ndarray[Any, Any]
Reported by Pylint.
Line: 29
Column: 1
reveal_type(np.isfortran(i8)) # E: bool
reveal_type(np.isfortran(A)) # E: bool
reveal_type(np.argwhere(i8)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argwhere(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.flatnonzero(i8)) # E: numpy.ndarray[Any, Any]
reveal_type(np.flatnonzero(A)) # E: numpy.ndarray[Any, Any]
Reported by Pylint.
Line: 30
Column: 1
reveal_type(np.isfortran(A)) # E: bool
reveal_type(np.argwhere(i8)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argwhere(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.flatnonzero(i8)) # E: numpy.ndarray[Any, Any]
reveal_type(np.flatnonzero(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.correlate(B, A, mode="valid")) # E: numpy.ndarray[Any, Any]
Reported by Pylint.
Line: 32
Column: 1
reveal_type(np.argwhere(i8)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argwhere(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.flatnonzero(i8)) # E: numpy.ndarray[Any, Any]
reveal_type(np.flatnonzero(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.correlate(B, A, mode="valid")) # E: numpy.ndarray[Any, Any]
reveal_type(np.correlate(A, A, mode="same")) # E: numpy.ndarray[Any, Any]
Reported by Pylint.
numpy/typing/tests/data/reveal/index_tricks.py
52 issues
Line: 9
Column: 8
AR_LIKE_f: List[float]
AR_LIKE_U: List[str]
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
reveal_type(np.ndenumerate(AR_i8)) # E: numpy.ndenumerate[{int64}]
reveal_type(np.ndenumerate(AR_LIKE_f)) # E: numpy.ndenumerate[{double}]
reveal_type(np.ndenumerate(AR_LIKE_U)) # E: numpy.ndenumerate[numpy.str_]
Reported by Pylint.
Line: 11
Column: 1
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
reveal_type(np.ndenumerate(AR_i8)) # E: numpy.ndenumerate[{int64}]
reveal_type(np.ndenumerate(AR_LIKE_f)) # E: numpy.ndenumerate[{double}]
reveal_type(np.ndenumerate(AR_LIKE_U)) # E: numpy.ndenumerate[numpy.str_]
reveal_type(np.ndenumerate(AR_i8).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{int64}]]]
reveal_type(np.ndenumerate(AR_LIKE_f).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{double}]]]
Reported by Pylint.
Line: 12
Column: 1
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
reveal_type(np.ndenumerate(AR_i8)) # E: numpy.ndenumerate[{int64}]
reveal_type(np.ndenumerate(AR_LIKE_f)) # E: numpy.ndenumerate[{double}]
reveal_type(np.ndenumerate(AR_LIKE_U)) # E: numpy.ndenumerate[numpy.str_]
reveal_type(np.ndenumerate(AR_i8).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{int64}]]]
reveal_type(np.ndenumerate(AR_LIKE_f).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{double}]]]
reveal_type(np.ndenumerate(AR_LIKE_U).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[numpy.str_]]]
Reported by Pylint.
Line: 13
Column: 1
reveal_type(np.ndenumerate(AR_i8)) # E: numpy.ndenumerate[{int64}]
reveal_type(np.ndenumerate(AR_LIKE_f)) # E: numpy.ndenumerate[{double}]
reveal_type(np.ndenumerate(AR_LIKE_U)) # E: numpy.ndenumerate[numpy.str_]
reveal_type(np.ndenumerate(AR_i8).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{int64}]]]
reveal_type(np.ndenumerate(AR_LIKE_f).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{double}]]]
reveal_type(np.ndenumerate(AR_LIKE_U).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[numpy.str_]]]
Reported by Pylint.
Line: 15
Column: 1
reveal_type(np.ndenumerate(AR_LIKE_f)) # E: numpy.ndenumerate[{double}]
reveal_type(np.ndenumerate(AR_LIKE_U)) # E: numpy.ndenumerate[numpy.str_]
reveal_type(np.ndenumerate(AR_i8).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{int64}]]]
reveal_type(np.ndenumerate(AR_LIKE_f).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{double}]]]
reveal_type(np.ndenumerate(AR_LIKE_U).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[numpy.str_]]]
reveal_type(next(np.ndenumerate(AR_i8))) # E: Tuple[builtins.tuple[builtins.int], {int64}]
reveal_type(next(np.ndenumerate(AR_LIKE_f))) # E: Tuple[builtins.tuple[builtins.int], {double}]
Reported by Pylint.
Line: 16
Column: 1
reveal_type(np.ndenumerate(AR_LIKE_U)) # E: numpy.ndenumerate[numpy.str_]
reveal_type(np.ndenumerate(AR_i8).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{int64}]]]
reveal_type(np.ndenumerate(AR_LIKE_f).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{double}]]]
reveal_type(np.ndenumerate(AR_LIKE_U).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[numpy.str_]]]
reveal_type(next(np.ndenumerate(AR_i8))) # E: Tuple[builtins.tuple[builtins.int], {int64}]
reveal_type(next(np.ndenumerate(AR_LIKE_f))) # E: Tuple[builtins.tuple[builtins.int], {double}]
reveal_type(next(np.ndenumerate(AR_LIKE_U))) # E: Tuple[builtins.tuple[builtins.int], numpy.str_]
Reported by Pylint.
Line: 17
Column: 1
reveal_type(np.ndenumerate(AR_i8).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{int64}]]]
reveal_type(np.ndenumerate(AR_LIKE_f).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{double}]]]
reveal_type(np.ndenumerate(AR_LIKE_U).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[numpy.str_]]]
reveal_type(next(np.ndenumerate(AR_i8))) # E: Tuple[builtins.tuple[builtins.int], {int64}]
reveal_type(next(np.ndenumerate(AR_LIKE_f))) # E: Tuple[builtins.tuple[builtins.int], {double}]
reveal_type(next(np.ndenumerate(AR_LIKE_U))) # E: Tuple[builtins.tuple[builtins.int], numpy.str_]
Reported by Pylint.
Line: 19
Column: 1
reveal_type(np.ndenumerate(AR_LIKE_f).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[{double}]]]
reveal_type(np.ndenumerate(AR_LIKE_U).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[numpy.str_]]]
reveal_type(next(np.ndenumerate(AR_i8))) # E: Tuple[builtins.tuple[builtins.int], {int64}]
reveal_type(next(np.ndenumerate(AR_LIKE_f))) # E: Tuple[builtins.tuple[builtins.int], {double}]
reveal_type(next(np.ndenumerate(AR_LIKE_U))) # E: Tuple[builtins.tuple[builtins.int], numpy.str_]
reveal_type(iter(np.ndenumerate(AR_i8))) # E: Iterator[Tuple[builtins.tuple[builtins.int], {int64}]]
reveal_type(iter(np.ndenumerate(AR_LIKE_f))) # E: Iterator[Tuple[builtins.tuple[builtins.int], {double}]]
Reported by Pylint.
Line: 20
Column: 1
reveal_type(np.ndenumerate(AR_LIKE_U).iter) # E: numpy.flatiter[numpy.ndarray[Any, numpy.dtype[numpy.str_]]]
reveal_type(next(np.ndenumerate(AR_i8))) # E: Tuple[builtins.tuple[builtins.int], {int64}]
reveal_type(next(np.ndenumerate(AR_LIKE_f))) # E: Tuple[builtins.tuple[builtins.int], {double}]
reveal_type(next(np.ndenumerate(AR_LIKE_U))) # E: Tuple[builtins.tuple[builtins.int], numpy.str_]
reveal_type(iter(np.ndenumerate(AR_i8))) # E: Iterator[Tuple[builtins.tuple[builtins.int], {int64}]]
reveal_type(iter(np.ndenumerate(AR_LIKE_f))) # E: Iterator[Tuple[builtins.tuple[builtins.int], {double}]]
reveal_type(iter(np.ndenumerate(AR_LIKE_U))) # E: Iterator[Tuple[builtins.tuple[builtins.int], numpy.str_]]
Reported by Pylint.
Line: 21
Column: 1
reveal_type(next(np.ndenumerate(AR_i8))) # E: Tuple[builtins.tuple[builtins.int], {int64}]
reveal_type(next(np.ndenumerate(AR_LIKE_f))) # E: Tuple[builtins.tuple[builtins.int], {double}]
reveal_type(next(np.ndenumerate(AR_LIKE_U))) # E: Tuple[builtins.tuple[builtins.int], numpy.str_]
reveal_type(iter(np.ndenumerate(AR_i8))) # E: Iterator[Tuple[builtins.tuple[builtins.int], {int64}]]
reveal_type(iter(np.ndenumerate(AR_LIKE_f))) # E: Iterator[Tuple[builtins.tuple[builtins.int], {double}]]
reveal_type(iter(np.ndenumerate(AR_LIKE_U))) # E: Iterator[Tuple[builtins.tuple[builtins.int], numpy.str_]]
Reported by Pylint.
numpy/core/tests/test_getlimits.py
51 issues
Line: 108
Column: 5
# Suppress warning for broken discovery of double double on PPC
with np.errstate(all='ignore'):
ld_ma = _discovered_machar(np.longdouble)
bytes = np.dtype(np.longdouble).itemsize
if (ld_ma.it, ld_ma.maxexp) == (63, 16384) and bytes in (12, 16):
# 80-bit extended precision
assert_ma_equal(ld_ma, _float_ma[80])
elif (ld_ma.it, ld_ma.maxexp) == (112, 16384) and bytes == 16:
# IEE 754 128-bit
Reported by Pylint.
Line: 121
Column: 5
"""Test that the subnormal is zero warning is not being raised."""
with np.errstate(all='ignore'):
ld_ma = _discovered_machar(np.longdouble)
bytes = np.dtype(np.longdouble).itemsize
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
if (ld_ma.it, ld_ma.maxexp) == (63, 16384) and bytes in (12, 16):
# 80-bit extended precision
ld_ma.smallest_subnormal
Reported by Pylint.
Line: 126
Column: 13
warnings.simplefilter('always')
if (ld_ma.it, ld_ma.maxexp) == (63, 16384) and bytes in (12, 16):
# 80-bit extended precision
ld_ma.smallest_subnormal
assert len(w) == 0
elif (ld_ma.it, ld_ma.maxexp) == (112, 16384) and bytes == 16:
# IEE 754 128-bit
ld_ma.smallest_subnormal
assert len(w) == 0
Reported by Pylint.
Line: 130
Column: 13
assert len(w) == 0
elif (ld_ma.it, ld_ma.maxexp) == (112, 16384) and bytes == 16:
# IEE 754 128-bit
ld_ma.smallest_subnormal
assert len(w) == 0
else:
# Double double
ld_ma.smallest_subnormal
# This test may fail on some platforms
Reported by Pylint.
Line: 134
Column: 13
assert len(w) == 0
else:
# Double double
ld_ma.smallest_subnormal
# This test may fail on some platforms
assert len(w) == 0
def test_plausible_finfo():
Reported by Pylint.
Line: 143
Column: 9
# Assert that finfo returns reasonable results for all types
for ftype in np.sctypes['float'] + np.sctypes['complex']:
info = np.finfo(ftype)
assert_(info.nmant > 1)
assert_(info.minexp < -1)
assert_(info.maxexp > 1)
Reported by Pylint.
Line: 144
Column: 9
for ftype in np.sctypes['float'] + np.sctypes['complex']:
info = np.finfo(ftype)
assert_(info.nmant > 1)
assert_(info.minexp < -1)
assert_(info.maxexp > 1)
Reported by Pylint.
Line: 145
Column: 9
info = np.finfo(ftype)
assert_(info.nmant > 1)
assert_(info.minexp < -1)
assert_(info.maxexp > 1)
Reported by Pylint.
Line: 13
Column: 1
##################################################
class TestPythonFloat:
def test_singleton(self):
ftype = finfo(float)
ftype2 = finfo(float)
assert_equal(id(ftype), id(ftype2))
Reported by Pylint.
Line: 13
Column: 1
##################################################
class TestPythonFloat:
def test_singleton(self):
ftype = finfo(float)
ftype2 = finfo(float)
assert_equal(id(ftype), id(ftype2))
Reported by Pylint.
numpy/distutils/command/build_ext.py
51 issues
Line: 161
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: 65
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
# Ensure that self.include_dirs and self.distribution.include_dirs
# refer to the same list object. finalize_options will modify
Reported by Pylint.
Line: 78
Column: 13
# The include paths will be passed to the compiler in the order:
# numpy paths, --include-dirs paths, Python include path.
if isinstance(self.include_dirs, str):
self.include_dirs = self.include_dirs.split(os.pathsep)
incl_dirs = self.include_dirs or []
if self.distribution.include_dirs is None:
self.distribution.include_dirs = []
self.include_dirs = self.distribution.include_dirs
self.include_dirs.extend(incl_dirs)
Reported by Pylint.
Line: 82
Column: 9
incl_dirs = self.include_dirs or []
if self.distribution.include_dirs is None:
self.distribution.include_dirs = []
self.include_dirs = self.distribution.include_dirs
self.include_dirs.extend(incl_dirs)
old_build_ext.finalize_options(self)
self.set_undefined_options('build',
('parallel', 'parallel'),
Reported by Pylint.
Line: 135
Column: 9
compiler_type = self.compiler
# Initialize C compiler:
self.compiler = new_compiler(compiler=compiler_type,
verbose=self.verbose,
dry_run=self.dry_run,
force=self.force)
self.compiler.customize(self.distribution)
self.compiler.customize_cmd(self)
Reported by Pylint.
Line: 163
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.
Line: 176
Column: 9
atexit.register(report, self.compiler_opt)
# Setup directory for storing generated extra DLL files on Windows
self.extra_dll_dir = os.path.join(self.build_temp, '.libs')
if not os.path.isdir(self.extra_dll_dir):
os.makedirs(self.extra_dll_dir)
# Create mapping of libraries built by build_clib:
clibs = {}
Reported by Pylint.
Line: 256
Column: 13
# Initialize C++ compiler:
if need_cxx_compiler:
self._cxx_compiler = new_compiler(compiler=compiler_type,
verbose=self.verbose,
dry_run=self.dry_run,
force=self.force)
compiler = self._cxx_compiler
compiler.customize(self.distribution, need_cxx=need_cxx_compiler)
Reported by Pylint.
Line: 264
Column: 13
compiler.customize(self.distribution, need_cxx=need_cxx_compiler)
compiler.customize_cmd(self)
compiler.show_customization()
self._cxx_compiler = compiler.cxx_compiler()
else:
self._cxx_compiler = None
# Initialize Fortran 77 compiler:
if need_f77_compiler:
Reported by Pylint.
Line: 266
Column: 13
compiler.show_customization()
self._cxx_compiler = compiler.cxx_compiler()
else:
self._cxx_compiler = None
# Initialize Fortran 77 compiler:
if need_f77_compiler:
ctype = self.fcompiler
self._f77_compiler = new_fcompiler(compiler=self.fcompiler,
Reported by Pylint.
numpy/typing/tests/data/reveal/dtype.py
50 issues
Line: 8
Column: 1
dtype_V: np.dtype[np.void]
dtype_i8: np.dtype[np.int64]
reveal_type(np.dtype(np.float64)) # E: numpy.dtype[{float64}]
reveal_type(np.dtype(np.int64)) # E: numpy.dtype[{int64}]
# String aliases
reveal_type(np.dtype("float64")) # E: numpy.dtype[{float64}]
reveal_type(np.dtype("float32")) # E: numpy.dtype[{float32}]
Reported by Pylint.
Line: 9
Column: 1
dtype_i8: np.dtype[np.int64]
reveal_type(np.dtype(np.float64)) # E: numpy.dtype[{float64}]
reveal_type(np.dtype(np.int64)) # E: numpy.dtype[{int64}]
# String aliases
reveal_type(np.dtype("float64")) # E: numpy.dtype[{float64}]
reveal_type(np.dtype("float32")) # E: numpy.dtype[{float32}]
reveal_type(np.dtype("int64")) # E: numpy.dtype[{int64}]
Reported by Pylint.
Line: 12
Column: 1
reveal_type(np.dtype(np.int64)) # E: numpy.dtype[{int64}]
# String aliases
reveal_type(np.dtype("float64")) # E: numpy.dtype[{float64}]
reveal_type(np.dtype("float32")) # E: numpy.dtype[{float32}]
reveal_type(np.dtype("int64")) # E: numpy.dtype[{int64}]
reveal_type(np.dtype("int32")) # E: numpy.dtype[{int32}]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
Reported by Pylint.
Line: 13
Column: 1
# String aliases
reveal_type(np.dtype("float64")) # E: numpy.dtype[{float64}]
reveal_type(np.dtype("float32")) # E: numpy.dtype[{float32}]
reveal_type(np.dtype("int64")) # E: numpy.dtype[{int64}]
reveal_type(np.dtype("int32")) # E: numpy.dtype[{int32}]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
Reported by Pylint.
Line: 14
Column: 1
# String aliases
reveal_type(np.dtype("float64")) # E: numpy.dtype[{float64}]
reveal_type(np.dtype("float32")) # E: numpy.dtype[{float32}]
reveal_type(np.dtype("int64")) # E: numpy.dtype[{int64}]
reveal_type(np.dtype("int32")) # E: numpy.dtype[{int32}]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
Reported by Pylint.
Line: 15
Column: 1
reveal_type(np.dtype("float64")) # E: numpy.dtype[{float64}]
reveal_type(np.dtype("float32")) # E: numpy.dtype[{float32}]
reveal_type(np.dtype("int64")) # E: numpy.dtype[{int64}]
reveal_type(np.dtype("int32")) # E: numpy.dtype[{int32}]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
# Python types
Reported by Pylint.
Line: 16
Column: 1
reveal_type(np.dtype("float32")) # E: numpy.dtype[{float32}]
reveal_type(np.dtype("int64")) # E: numpy.dtype[{int64}]
reveal_type(np.dtype("int32")) # E: numpy.dtype[{int32}]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
# Python types
reveal_type(np.dtype(complex)) # E: numpy.dtype[{cdouble}]
Reported by Pylint.
Line: 17
Column: 1
reveal_type(np.dtype("int64")) # E: numpy.dtype[{int64}]
reveal_type(np.dtype("int32")) # E: numpy.dtype[{int32}]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
# Python types
reveal_type(np.dtype(complex)) # E: numpy.dtype[{cdouble}]
reveal_type(np.dtype(float)) # E: numpy.dtype[{double}]
Reported by Pylint.
Line: 18
Column: 1
reveal_type(np.dtype("int32")) # E: numpy.dtype[{int32}]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
# Python types
reveal_type(np.dtype(complex)) # E: numpy.dtype[{cdouble}]
reveal_type(np.dtype(float)) # E: numpy.dtype[{double}]
reveal_type(np.dtype(int)) # E: numpy.dtype[{int_}]
Reported by Pylint.
Line: 21
Column: 1
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
# Python types
reveal_type(np.dtype(complex)) # E: numpy.dtype[{cdouble}]
reveal_type(np.dtype(float)) # E: numpy.dtype[{double}]
reveal_type(np.dtype(int)) # E: numpy.dtype[{int_}]
reveal_type(np.dtype(bool)) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype(str)) # E: numpy.dtype[numpy.str_]
reveal_type(np.dtype(bytes)) # E: numpy.dtype[numpy.bytes_]
Reported by Pylint.
numpy/typing/tests/data/fail/arithmetic.py
49 issues
Line: 4
Column: 6
from typing import List, Any
import numpy as np
b_ = np.bool_()
dt = np.datetime64(0, "D")
td = np.timedelta64(0, "D")
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
Reported by Pylint.
Line: 8
Column: 7
dt = np.datetime64(0, "D")
td = np.timedelta64(0, "D")
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
Reported by Pylint.
Line: 9
Column: 7
td = np.timedelta64(0, "D")
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
Reported by Pylint.
Line: 10
Column: 7
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
Reported by Pylint.
Line: 11
Column: 7
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
ANY: Any
Reported by Pylint.
Line: 12
Column: 7
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
ANY: Any
Reported by Pylint.
Line: 13
Column: 7
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
ANY: Any
AR_LIKE_b: List[bool]
Reported by Pylint.
Line: 14
Column: 7
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
ANY: Any
AR_LIKE_b: List[bool]
AR_LIKE_u: List[np.uint32]
Reported by Pylint.
Line: 119
Column: 1
td / dt # E: No overload
td % dt # E: Unsupported operand types
-b_ # E: Unsupported operand type
+b_ # E: Unsupported operand type
Reported by Pylint.
Line: 120
Column: 1
td % dt # E: Unsupported operand types
-b_ # E: Unsupported operand type
+b_ # E: Unsupported operand type
Reported by Pylint.
numpy/f2py/tests/test_return_logical.py
49 issues
Line: 1
Column: 1
import pytest
from numpy import array
from numpy.testing import assert_, assert_raises
from . import util
class TestReturnLogical(util.F2PyTest):
Reported by Pylint.
Line: 5
Column: 1
from numpy import array
from numpy.testing import assert_, assert_raises
from . import util
class TestReturnLogical(util.F2PyTest):
def check_function(self, t):
Reported by Pylint.
Line: 11
Column: 9
class TestReturnLogical(util.F2PyTest):
def check_function(self, t):
assert_(t(True) == 1, repr(t(True)))
assert_(t(False) == 0, repr(t(False)))
assert_(t(0) == 0)
assert_(t(None) == 0)
assert_(t(0.0) == 0)
assert_(t(0j) == 0)
Reported by Pylint.
Line: 12
Column: 9
def check_function(self, t):
assert_(t(True) == 1, repr(t(True)))
assert_(t(False) == 0, repr(t(False)))
assert_(t(0) == 0)
assert_(t(None) == 0)
assert_(t(0.0) == 0)
assert_(t(0j) == 0)
assert_(t(1j) == 1)
Reported by Pylint.
Line: 13
Column: 9
def check_function(self, t):
assert_(t(True) == 1, repr(t(True)))
assert_(t(False) == 0, repr(t(False)))
assert_(t(0) == 0)
assert_(t(None) == 0)
assert_(t(0.0) == 0)
assert_(t(0j) == 0)
assert_(t(1j) == 1)
assert_(t(234) == 1)
Reported by Pylint.
Line: 14
Column: 9
assert_(t(True) == 1, repr(t(True)))
assert_(t(False) == 0, repr(t(False)))
assert_(t(0) == 0)
assert_(t(None) == 0)
assert_(t(0.0) == 0)
assert_(t(0j) == 0)
assert_(t(1j) == 1)
assert_(t(234) == 1)
assert_(t(234.6) == 1)
Reported by Pylint.
Line: 15
Column: 9
assert_(t(False) == 0, repr(t(False)))
assert_(t(0) == 0)
assert_(t(None) == 0)
assert_(t(0.0) == 0)
assert_(t(0j) == 0)
assert_(t(1j) == 1)
assert_(t(234) == 1)
assert_(t(234.6) == 1)
assert_(t(234.6 + 3j) == 1)
Reported by Pylint.
Line: 16
Column: 9
assert_(t(0) == 0)
assert_(t(None) == 0)
assert_(t(0.0) == 0)
assert_(t(0j) == 0)
assert_(t(1j) == 1)
assert_(t(234) == 1)
assert_(t(234.6) == 1)
assert_(t(234.6 + 3j) == 1)
assert_(t('234') == 1)
Reported by Pylint.
Line: 17
Column: 9
assert_(t(None) == 0)
assert_(t(0.0) == 0)
assert_(t(0j) == 0)
assert_(t(1j) == 1)
assert_(t(234) == 1)
assert_(t(234.6) == 1)
assert_(t(234.6 + 3j) == 1)
assert_(t('234') == 1)
assert_(t('aaa') == 1)
Reported by Pylint.
Line: 18
Column: 9
assert_(t(0.0) == 0)
assert_(t(0j) == 0)
assert_(t(1j) == 1)
assert_(t(234) == 1)
assert_(t(234.6) == 1)
assert_(t(234.6 + 3j) == 1)
assert_(t('234') == 1)
assert_(t('aaa') == 1)
assert_(t('') == 0)
Reported by Pylint.
numpy/fft/tests/test_helper.py
49 issues
Line: 25
Column: 17
def test_inverse(self):
for n in [1, 4, 9, 100, 211]:
x = np.random.random((n,))
assert_array_almost_equal(fft.ifftshift(fft.fftshift(x)), x)
def test_axes_keyword(self):
freqs = [[0, 1, 2], [3, 4, -4], [-3, -2, -1]]
shifted = [[-1, -3, -2], [2, 0, 1], [-4, 3, 4]]
Reported by Pylint.
Line: 127
Column: 27
for i in range(16):
for j in range(16):
for axes_keyword in [0, 1, None, (0,), (0, 1)]:
inp = np.random.rand(i, j)
assert_array_almost_equal(fft.fftshift(inp, axes_keyword),
original_fftshift(inp, axes_keyword))
assert_array_almost_equal(fft.ifftshift(inp, axes_keyword),
Reported by Pylint.
Line: 161
Column: 18
class TestIRFFTN:
def test_not_last_axis_success(self):
ar, ai = np.random.random((2, 16, 8, 32))
a = ar + 1j*ai
axes = (-2,)
# Should not raise error
Reported by Pylint.
Line: 11
Column: 1
from numpy import fft, pi
class TestFFTShift:
def test_definition(self):
x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
y = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
Reported by Pylint.
Line: 13
Column: 5
class TestFFTShift:
def test_definition(self):
x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
y = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
Reported by Pylint.
Line: 13
Column: 5
class TestFFTShift:
def test_definition(self):
x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
y = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
Reported by Pylint.
Line: 14
Column: 9
class TestFFTShift:
def test_definition(self):
x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
y = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
y = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]
Reported by Pylint.
Line: 15
Column: 9
def test_definition(self):
x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
y = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
y = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
Reported by Pylint.
Line: 18
Column: 9
y = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
y = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
def test_inverse(self):
Reported by Pylint.
Line: 19
Column: 9
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
y = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]
assert_array_almost_equal(fft.fftshift(x), y)
assert_array_almost_equal(fft.ifftshift(y), x)
def test_inverse(self):
for n in [1, 4, 9, 100, 211]:
Reported by Pylint.
tools/cythonize.py
48 issues
Line: 161
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5
f.write("%s %s %s\n" % (key, value[0], value[1]))
def sha1_of_file(filename):
h = hashlib.sha1()
with open(filename, "rb") as f:
h.update(f.read())
return h.hexdigest()
#
Reported by Bandit.
Line: 213
Column: 9
reverse=True)
for filename in files:
in_file = os.path.join(root_dir, filename + ".in")
for fromext, value in rules.items():
if filename.endswith(fromext):
if not value:
break
function, toext = value
Reported by Pylint.
Line: 37
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import re
import sys
import hashlib
import subprocess
HASH_FILE = 'cythonize.dat'
DEFAULT_ROOT = 'numpy'
VENDOR = 'NumPy'
Reported by Bandit.
Line: 47
Column: 5
try:
WindowsError
except NameError:
WindowsError = None
#
# Rules
#
def process_pyx(fromfile, tofile):
Reported by Pylint.
Line: 52
Column: 1
#
# Rules
#
def process_pyx(fromfile, tofile):
flags = ['-3', '--fast-fail']
if tofile.endswith('.cxx'):
flags.append('--cplus')
try:
Reported by Pylint.
Line: 59
Column: 9
try:
# try the cython in the installed python first (somewhat related to scipy/scipy#2397)
import Cython
from Cython.Compiler.Version import version as cython_version
except ImportError as e:
# The `cython` command need not point to the version installed in the
# Python running this script, so raise an error to avoid the chance of
# using the wrong version of Cython.
Reported by Pylint.
Line: 60
Column: 9
try:
# try the cython in the installed python first (somewhat related to scipy/scipy#2397)
import Cython
from Cython.Compiler.Version import version as cython_version
except ImportError as e:
# The `cython` command need not point to the version installed in the
# Python running this script, so raise an error to avoid the chance of
# using the wrong version of Cython.
msg = 'Cython needs to be installed in Python as a module'
Reported by Pylint.
Line: 61
Column: 5
# try the cython in the installed python first (somewhat related to scipy/scipy#2397)
import Cython
from Cython.Compiler.Version import version as cython_version
except ImportError as e:
# The `cython` command need not point to the version installed in the
# Python running this script, so raise an error to avoid the chance of
# using the wrong version of Cython.
msg = 'Cython needs to be installed in Python as a module'
raise OSError(msg) from e
Reported by Pylint.
Line: 69
Column: 9
raise OSError(msg) from e
else:
# check the version, and invoke through python
from distutils.version import LooseVersion
# Cython 0.29.21 is required for Python 3.9 and there are
# other fixes in the 0.29 series that are needed even for earlier
# Python versions.
# Note: keep in sync with that in pyproject.toml
Reported by Pylint.
Line: 82
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
cython_path = Cython.__file__
raise RuntimeError(f'Building {VENDOR} requires Cython >= {required_version}'
f', found {cython_version} at {cython_path}')
subprocess.check_call(
[sys.executable, '-m', 'cython'] + flags + ["-o", tofile, fromfile])
def process_tempita_pyx(fromfile, tofile):
import npy_tempita as tempita
Reported by Bandit.