The following issues were found
numpy/typing/tests/data/reveal/array_constructors.py
147 issues
Line: 9
Column: 16
_SCT = TypeVar("_SCT", bound=np.generic, covariant=True)
class SubClass(np.ndarray[Any, np.dtype[_SCT]]): ...
i8: np.int64
A: npt.NDArray[np.float64]
B: SubClass[np.float64]
Reported by Pylint.
Line: 13
Column: 4
i8: np.int64
A: npt.NDArray[np.float64]
B: SubClass[np.float64]
C: List[int]
def func(i: int, j: int, **kwargs: Any) -> SubClass[np.float64]: ...
Reported by Pylint.
Line: 19
Column: 1
def func(i: int, j: int, **kwargs: Any) -> SubClass[np.float64]: ...
reveal_type(np.empty_like(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.empty_like(B)) # E: SubClass[{float64}]
reveal_type(np.empty_like([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.empty_like(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.empty_like(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
Reported by Pylint.
Line: 20
Column: 1
def func(i: int, j: int, **kwargs: Any) -> SubClass[np.float64]: ...
reveal_type(np.empty_like(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.empty_like(B)) # E: SubClass[{float64}]
reveal_type(np.empty_like([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.empty_like(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.empty_like(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
Reported by Pylint.
Line: 21
Column: 1
reveal_type(np.empty_like(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.empty_like(B)) # E: SubClass[{float64}]
reveal_type(np.empty_like([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.empty_like(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.empty_like(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
Reported by Pylint.
Line: 22
Column: 1
reveal_type(np.empty_like(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.empty_like(B)) # E: SubClass[{float64}]
reveal_type(np.empty_like([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.empty_like(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.empty_like(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B, subok=True)) # E: SubClass[{float64}]
Reported by Pylint.
Line: 23
Column: 1
reveal_type(np.empty_like(B)) # E: SubClass[{float64}]
reveal_type(np.empty_like([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.empty_like(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.empty_like(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B, subok=True)) # E: SubClass[{float64}]
reveal_type(np.array([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
Reported by Pylint.
Line: 25
Column: 1
reveal_type(np.empty_like(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.empty_like(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B, subok=True)) # E: SubClass[{float64}]
reveal_type(np.array([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.array(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
Reported by Pylint.
Line: 26
Column: 1
reveal_type(np.empty_like(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B, subok=True)) # E: SubClass[{float64}]
reveal_type(np.array([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.array(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
Reported by Pylint.
Line: 27
Column: 1
reveal_type(np.array(A)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.array(B, subok=True)) # E: SubClass[{float64}]
reveal_type(np.array([1, 1.0])) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.array(A, dtype=np.int64)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.array(A, dtype='c16')) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.zeros([1, 5, 6])) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
Reported by Pylint.
numpy/tests/test_ctypeslib.py
146 issues
Line: 2
Column: 1
import sys
import pytest
import weakref
import numpy as np
from numpy.ctypeslib import ndpointer, load_library, as_array
from numpy.distutils.misc_util import get_shared_lib_extension
from numpy.testing import assert_, assert_array_equal, assert_raises, assert_equal
Reported by Pylint.
Line: 19
Column: 56
test_cdll = None
if hasattr(sys, 'gettotalrefcount'):
try:
cdll = load_library('_multiarray_umath_d', np.core._multiarray_umath.__file__)
except OSError:
pass
try:
test_cdll = load_library('_multiarray_tests', np.core._multiarray_tests.__file__)
except OSError:
Reported by Pylint.
Line: 23
Column: 59
except OSError:
pass
try:
test_cdll = load_library('_multiarray_tests', np.core._multiarray_tests.__file__)
except OSError:
pass
if cdll is None:
cdll = load_library('_multiarray_umath', np.core._multiarray_umath.__file__)
if test_cdll is None:
Reported by Pylint.
Line: 27
Column: 50
except OSError:
pass
if cdll is None:
cdll = load_library('_multiarray_umath', np.core._multiarray_umath.__file__)
if test_cdll is None:
test_cdll = load_library('_multiarray_tests', np.core._multiarray_tests.__file__)
c_forward_pointer = test_cdll.forward_pointer
Reported by Pylint.
Line: 29
Column: 55
if cdll is None:
cdll = load_library('_multiarray_umath', np.core._multiarray_umath.__file__)
if test_cdll is None:
test_cdll = load_library('_multiarray_tests', np.core._multiarray_tests.__file__)
c_forward_pointer = test_cdll.forward_pointer
@pytest.mark.skipif(ctypes is None,
Reported by Pylint.
Line: 42
Column: 47
def test_basic(self):
try:
# Should succeed
load_library('_multiarray_umath', np.core._multiarray_umath.__file__)
except ImportError as e:
msg = ("ctypes is not available on this python: skipping the test"
" (import error was: %s)" % str(e))
print(msg)
Reported by Pylint.
Line: 55
Column: 58
try:
so = get_shared_lib_extension(is_python_ext=True)
# Should succeed
load_library('_multiarray_umath%s' % so, np.core._multiarray_umath.__file__)
except ImportError:
print("No distutils available, skipping test.")
except ImportError as e:
msg = ("ctypes is not available on this python: skipping the test"
" (import error was: %s)" % str(e))
Reported by Pylint.
Line: 170
Column: 13
assert_equal(arr2.shape, arr.shape)
assert_equal(
arr2.__array_interface__['data'],
arr.__array_interface__['data']
)
def test_vague_return_value(self):
""" Test that vague ndpointer return values do not promote to arrays """
arr = np.zeros((2, 3))
Reported by Pylint.
Line: 19
Column: 56
test_cdll = None
if hasattr(sys, 'gettotalrefcount'):
try:
cdll = load_library('_multiarray_umath_d', np.core._multiarray_umath.__file__)
except OSError:
pass
try:
test_cdll = load_library('_multiarray_tests', np.core._multiarray_tests.__file__)
except OSError:
Reported by Pylint.
Line: 23
Column: 59
except OSError:
pass
try:
test_cdll = load_library('_multiarray_tests', np.core._multiarray_tests.__file__)
except OSError:
pass
if cdll is None:
cdll = load_library('_multiarray_umath', np.core._multiarray_umath.__file__)
if test_cdll is None:
Reported by Pylint.
numpy/typing/tests/data/reveal/scalars.py
143 issues
Line: 14
Column: 1
U: np.str_
S: np.bytes_
reveal_type(c8.real) # E: {float32}
reveal_type(c8.imag) # E: {float32}
reveal_type(c8.real.real) # E: {float32}
reveal_type(c8.real.imag) # E: {float32}
Reported by Pylint.
Line: 15
Column: 1
S: np.bytes_
reveal_type(c8.real) # E: {float32}
reveal_type(c8.imag) # E: {float32}
reveal_type(c8.real.real) # E: {float32}
reveal_type(c8.real.imag) # E: {float32}
reveal_type(c8.itemsize) # E: int
Reported by Pylint.
Line: 17
Column: 1
reveal_type(c8.real) # E: {float32}
reveal_type(c8.imag) # E: {float32}
reveal_type(c8.real.real) # E: {float32}
reveal_type(c8.real.imag) # E: {float32}
reveal_type(c8.itemsize) # E: int
reveal_type(c8.shape) # E: Tuple[]
reveal_type(c8.strides) # E: Tuple[]
Reported by Pylint.
Line: 18
Column: 1
reveal_type(c8.imag) # E: {float32}
reveal_type(c8.real.real) # E: {float32}
reveal_type(c8.real.imag) # E: {float32}
reveal_type(c8.itemsize) # E: int
reveal_type(c8.shape) # E: Tuple[]
reveal_type(c8.strides) # E: Tuple[]
Reported by Pylint.
Line: 20
Column: 1
reveal_type(c8.real.real) # E: {float32}
reveal_type(c8.real.imag) # E: {float32}
reveal_type(c8.itemsize) # E: int
reveal_type(c8.shape) # E: Tuple[]
reveal_type(c8.strides) # E: Tuple[]
reveal_type(c8.ndim) # E: Literal[0]
reveal_type(c8.size) # E: Literal[1]
Reported by Pylint.
Line: 21
Column: 1
reveal_type(c8.real.imag) # E: {float32}
reveal_type(c8.itemsize) # E: int
reveal_type(c8.shape) # E: Tuple[]
reveal_type(c8.strides) # E: Tuple[]
reveal_type(c8.ndim) # E: Literal[0]
reveal_type(c8.size) # E: Literal[1]
Reported by Pylint.
Line: 22
Column: 1
reveal_type(c8.itemsize) # E: int
reveal_type(c8.shape) # E: Tuple[]
reveal_type(c8.strides) # E: Tuple[]
reveal_type(c8.ndim) # E: Literal[0]
reveal_type(c8.size) # E: Literal[1]
reveal_type(c8.squeeze()) # E: {complex64}
Reported by Pylint.
Line: 24
Column: 1
reveal_type(c8.shape) # E: Tuple[]
reveal_type(c8.strides) # E: Tuple[]
reveal_type(c8.ndim) # E: Literal[0]
reveal_type(c8.size) # E: Literal[1]
reveal_type(c8.squeeze()) # E: {complex64}
reveal_type(c8.byteswap()) # E: {complex64}
reveal_type(c8.transpose()) # E: {complex64}
Reported by Pylint.
Line: 25
Column: 1
reveal_type(c8.strides) # E: Tuple[]
reveal_type(c8.ndim) # E: Literal[0]
reveal_type(c8.size) # E: Literal[1]
reveal_type(c8.squeeze()) # E: {complex64}
reveal_type(c8.byteswap()) # E: {complex64}
reveal_type(c8.transpose()) # E: {complex64}
Reported by Pylint.
Line: 27
Column: 1
reveal_type(c8.ndim) # E: Literal[0]
reveal_type(c8.size) # E: Literal[1]
reveal_type(c8.squeeze()) # E: {complex64}
reveal_type(c8.byteswap()) # E: {complex64}
reveal_type(c8.transpose()) # E: {complex64}
reveal_type(c8.dtype) # E: numpy.dtype[{complex64}]
Reported by Pylint.
numpy/core/multiarray.py
143 issues
Line: 10
Column: 1
"""
import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import * # noqa: F403
# These imports are needed for backward compatibility,
# do not change them. issue gh-15518
# _get_ndarray_c_version is semi-public, on purpose not added to __all__
Reported by Pylint.
Line: 11
Column: 1
import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import * # noqa: F403
# These imports are needed for backward compatibility,
# do not change them. issue gh-15518
# _get_ndarray_c_version is semi-public, on purpose not added to __all__
from ._multiarray_umath import (
Reported by Pylint.
Line: 12
Column: 1
import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import * # noqa: F403
# These imports are needed for backward compatibility,
# do not change them. issue gh-15518
# _get_ndarray_c_version is semi-public, on purpose not added to __all__
from ._multiarray_umath import (
_fastCopyAndTranspose, _flagdict, _insert, _reconstruct, _vec_string,
Reported by Pylint.
Line: 16
Column: 1
# These imports are needed for backward compatibility,
# do not change them. issue gh-15518
# _get_ndarray_c_version is semi-public, on purpose not added to __all__
from ._multiarray_umath import (
_fastCopyAndTranspose, _flagdict, _insert, _reconstruct, _vec_string,
_ARRAY_API, _monotonicity, _get_ndarray_c_version, _set_madvise_hugepage,
)
__all__ = [
Reported by Pylint.
Line: 22
Column: 19
)
__all__ = [
'_ARRAY_API', 'ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DATETIMEUNITS',
'ITEM_HASOBJECT', 'ITEM_IS_POINTER', 'LIST_PICKLE', 'MAXDIMS',
'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'NEEDS_INIT', 'NEEDS_PYAPI',
'RAISE', 'USE_GETITEM', 'USE_SETITEM', 'WRAP', '_fastCopyAndTranspose',
'_flagdict', '_insert', '_reconstruct', '_vec_string', '_monotonicity',
'add_docstring', 'arange', 'array', 'asarray', 'asanyarray',
Reported by Pylint.
Line: 22
Column: 55
)
__all__ = [
'_ARRAY_API', 'ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DATETIMEUNITS',
'ITEM_HASOBJECT', 'ITEM_IS_POINTER', 'LIST_PICKLE', 'MAXDIMS',
'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'NEEDS_INIT', 'NEEDS_PYAPI',
'RAISE', 'USE_GETITEM', 'USE_SETITEM', 'WRAP', '_fastCopyAndTranspose',
'_flagdict', '_insert', '_reconstruct', '_vec_string', '_monotonicity',
'add_docstring', 'arange', 'array', 'asarray', 'asanyarray',
Reported by Pylint.
Line: 22
Column: 47
)
__all__ = [
'_ARRAY_API', 'ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DATETIMEUNITS',
'ITEM_HASOBJECT', 'ITEM_IS_POINTER', 'LIST_PICKLE', 'MAXDIMS',
'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'NEEDS_INIT', 'NEEDS_PYAPI',
'RAISE', 'USE_GETITEM', 'USE_SETITEM', 'WRAP', '_fastCopyAndTranspose',
'_flagdict', '_insert', '_reconstruct', '_vec_string', '_monotonicity',
'add_docstring', 'arange', 'array', 'asarray', 'asanyarray',
Reported by Pylint.
Line: 22
Column: 36
)
__all__ = [
'_ARRAY_API', 'ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DATETIMEUNITS',
'ITEM_HASOBJECT', 'ITEM_IS_POINTER', 'LIST_PICKLE', 'MAXDIMS',
'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'NEEDS_INIT', 'NEEDS_PYAPI',
'RAISE', 'USE_GETITEM', 'USE_SETITEM', 'WRAP', '_fastCopyAndTranspose',
'_flagdict', '_insert', '_reconstruct', '_vec_string', '_monotonicity',
'add_docstring', 'arange', 'array', 'asarray', 'asanyarray',
Reported by Pylint.
Line: 23
Column: 5
__all__ = [
'_ARRAY_API', 'ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DATETIMEUNITS',
'ITEM_HASOBJECT', 'ITEM_IS_POINTER', 'LIST_PICKLE', 'MAXDIMS',
'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'NEEDS_INIT', 'NEEDS_PYAPI',
'RAISE', 'USE_GETITEM', 'USE_SETITEM', 'WRAP', '_fastCopyAndTranspose',
'_flagdict', '_insert', '_reconstruct', '_vec_string', '_monotonicity',
'add_docstring', 'arange', 'array', 'asarray', 'asanyarray',
'ascontiguousarray', 'asfortranarray', 'bincount', 'broadcast',
Reported by Pylint.
Line: 23
Column: 57
__all__ = [
'_ARRAY_API', 'ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DATETIMEUNITS',
'ITEM_HASOBJECT', 'ITEM_IS_POINTER', 'LIST_PICKLE', 'MAXDIMS',
'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'NEEDS_INIT', 'NEEDS_PYAPI',
'RAISE', 'USE_GETITEM', 'USE_SETITEM', 'WRAP', '_fastCopyAndTranspose',
'_flagdict', '_insert', '_reconstruct', '_vec_string', '_monotonicity',
'add_docstring', 'arange', 'array', 'asarray', 'asanyarray',
'ascontiguousarray', 'asfortranarray', 'bincount', 'broadcast',
Reported by Pylint.
numpy/f2py/rules.py
143 issues
Line: 58
Column: 1
import copy
# __version__.version is now the same as the NumPy version
from . import __version__
f2py_version = __version__.version
numpy_version = __version__.version
from .auxfuncs import (
applyrules, debugcapi, dictappend, errmess, gentitle, getargs2,
Reported by Pylint.
Line: 62
Column: 1
f2py_version = __version__.version
numpy_version = __version__.version
from .auxfuncs import (
applyrules, debugcapi, dictappend, errmess, gentitle, getargs2,
hascallstatement, hasexternals, hasinitvalue, hasnote, hasresultnote,
isarray, isarrayofstrings, iscomplex, iscomplexarray,
iscomplexfunction, iscomplexfunction_warn, isdummyroutine, isexternal,
isfunction, isfunction_wrap, isint1array, isintent_aux, isintent_c,
Reported by Pylint.
Line: 79
Column: 1
l_and, l_not, l_or, outmess, replace, stripcomma, requiresf90wrapper
)
from . import capi_maps
from . import cfuncs
from . import common_rules
from . import use_rules
from . import f90mod_rules
from . import func2subr
Reported by Pylint.
Line: 80
Column: 1
)
from . import capi_maps
from . import cfuncs
from . import common_rules
from . import use_rules
from . import f90mod_rules
from . import func2subr
Reported by Pylint.
Line: 81
Column: 1
from . import capi_maps
from . import cfuncs
from . import common_rules
from . import use_rules
from . import f90mod_rules
from . import func2subr
options = {}
Reported by Pylint.
Line: 82
Column: 1
from . import capi_maps
from . import cfuncs
from . import common_rules
from . import use_rules
from . import f90mod_rules
from . import func2subr
options = {}
sepdict = {}
Reported by Pylint.
Line: 83
Column: 1
from . import cfuncs
from . import common_rules
from . import use_rules
from . import f90mod_rules
from . import func2subr
options = {}
sepdict = {}
#for k in ['need_cfuncs']: sepdict[k]=','
Reported by Pylint.
Line: 84
Column: 1
from . import common_rules
from . import use_rules
from . import f90mod_rules
from . import func2subr
options = {}
sepdict = {}
#for k in ['need_cfuncs']: sepdict[k]=','
for k in ['decl',
Reported by Pylint.
Line: 1202
Column: 17
continue
nb_list = [nb]
if 'entry' in nb:
for k, a in nb['entry'].items():
nb1 = copy.deepcopy(nb)
del nb1['entry']
nb1['name'] = k
nb1['args'] = a
nb_list.append(nb1)
Reported by Pylint.
Line: 1465
Column: 9
replace('#docreturn#', {'docreturn': rd['docreturn']})) + ' = '
rd['docstrsigns'] = []
rd['latexdocstrsigns'] = []
for k in ['docstrreq', 'docstropt', 'docstrout', 'docstrcbs']:
if k in rd and isinstance(rd[k], list):
rd['docstrsigns'] = rd['docstrsigns'] + rd[k]
k = 'latex' + k
if k in rd and isinstance(rd[k], list):
rd['latexdocstrsigns'] = rd['latexdocstrsigns'] + rd[k][0:1] +\
Reported by Pylint.
numpy/core/setup.py
142 issues
Line: 14
Column: 1
from distutils.dep_util import newer
from sysconfig import get_config_var
from numpy.compat import npy_load_module
from setup_common import * # noqa: F403
# Set to True to enable relaxed strides checking. This (mostly) means
# that `strides[dim]` is ignored if `shape[dim] == 1` when setting flags.
NPY_RELAXED_STRIDES_CHECKING = (os.environ.get('NPY_RELAXED_STRIDES_CHECKING', "1") != "0")
Reported by Pylint.
Line: 115
Column: 31
st = config.check_funcs_once(funcs_name, libraries=mathlibs,
decl=decl, call=decl)
if st:
moredefs.extend([(fname2def(f), 1) for f in funcs_name])
return st
def check_funcs(funcs_name):
# Use check_funcs_once first, and if it does not work, test func per
# func. Return success only if all the functions are available
Reported by Pylint.
Line: 125
Column: 38
# Global check failed, check func per func
for f in funcs_name:
if check_func(f):
moredefs.append((fname2def(f), 1))
return 0
else:
return 1
#use_msvc = config.check_decl("_MSC_VER")
Reported by Pylint.
Line: 132
Column: 29
#use_msvc = config.check_decl("_MSC_VER")
if not check_funcs_once(MANDATORY_FUNCS):
raise SystemError("One of the required function to build numpy is not"
" available (the list is %s)." % str(MANDATORY_FUNCS))
# Standard functions which may not be available and for which we have a
# replacement implementation. Note that some of these are C99 functions.
Reported by Pylint.
Line: 134
Column: 54
if not check_funcs_once(MANDATORY_FUNCS):
raise SystemError("One of the required function to build numpy is not"
" available (the list is %s)." % str(MANDATORY_FUNCS))
# Standard functions which may not be available and for which we have a
# replacement implementation. Note that some of these are C99 functions.
# XXX: hack to circumvent cpp pollution from python: python put its
Reported by Pylint.
Line: 143
Column: 14
# config.h in the public namespace, so we have a clash for the common
# functions we test. We remove every function tested by python's
# autoconf, hoping their own test are correct
for f in OPTIONAL_STDFUNCS_MAYBE:
if config.check_decl(fname2def(f),
headers=["Python.h", "math.h"]):
OPTIONAL_STDFUNCS.remove(f)
check_funcs(OPTIONAL_STDFUNCS)
Reported by Pylint.
Line: 144
Column: 30
# functions we test. We remove every function tested by python's
# autoconf, hoping their own test are correct
for f in OPTIONAL_STDFUNCS_MAYBE:
if config.check_decl(fname2def(f),
headers=["Python.h", "math.h"]):
OPTIONAL_STDFUNCS.remove(f)
check_funcs(OPTIONAL_STDFUNCS)
Reported by Pylint.
Line: 146
Column: 13
for f in OPTIONAL_STDFUNCS_MAYBE:
if config.check_decl(fname2def(f),
headers=["Python.h", "math.h"]):
OPTIONAL_STDFUNCS.remove(f)
check_funcs(OPTIONAL_STDFUNCS)
for h in OPTIONAL_HEADERS:
if config.check_func("", decl=False, call=False, headers=[h]):
Reported by Pylint.
Line: 148
Column: 17
headers=["Python.h", "math.h"]):
OPTIONAL_STDFUNCS.remove(f)
check_funcs(OPTIONAL_STDFUNCS)
for h in OPTIONAL_HEADERS:
if config.check_func("", decl=False, call=False, headers=[h]):
h = h.replace(".", "_").replace(os.path.sep, "_")
moredefs.append((fname2def(h), 1))
Reported by Pylint.
Line: 150
Column: 14
check_funcs(OPTIONAL_STDFUNCS)
for h in OPTIONAL_HEADERS:
if config.check_func("", decl=False, call=False, headers=[h]):
h = h.replace(".", "_").replace(os.path.sep, "_")
moredefs.append((fname2def(h), 1))
for tup in OPTIONAL_INTRINSICS:
Reported by Pylint.
benchmarks/benchmarks/bench_core.py
141 issues
Line: 1
Column: 1
from .common import Benchmark
import numpy as np
class Core(Benchmark):
def setup(self):
self.l100 = range(100)
self.l50 = range(50)
Reported by Pylint.
Line: 8
Column: 9
class Core(Benchmark):
def setup(self):
self.l100 = range(100)
self.l50 = range(50)
self.float_l1000 = [float(i) for i in range(1000)]
self.float64_l1000 = [np.float64(i) for i in range(1000)]
self.int_l1000 = list(range(1000))
self.l = [np.arange(1000), np.arange(1000)]
Reported by Pylint.
Line: 9
Column: 9
class Core(Benchmark):
def setup(self):
self.l100 = range(100)
self.l50 = range(50)
self.float_l1000 = [float(i) for i in range(1000)]
self.float64_l1000 = [np.float64(i) for i in range(1000)]
self.int_l1000 = list(range(1000))
self.l = [np.arange(1000), np.arange(1000)]
self.l_view = [memoryview(a) for a in self.l]
Reported by Pylint.
Line: 10
Column: 9
def setup(self):
self.l100 = range(100)
self.l50 = range(50)
self.float_l1000 = [float(i) for i in range(1000)]
self.float64_l1000 = [np.float64(i) for i in range(1000)]
self.int_l1000 = list(range(1000))
self.l = [np.arange(1000), np.arange(1000)]
self.l_view = [memoryview(a) for a in self.l]
self.l10x10 = np.ones((10, 10))
Reported by Pylint.
Line: 11
Column: 9
self.l100 = range(100)
self.l50 = range(50)
self.float_l1000 = [float(i) for i in range(1000)]
self.float64_l1000 = [np.float64(i) for i in range(1000)]
self.int_l1000 = list(range(1000))
self.l = [np.arange(1000), np.arange(1000)]
self.l_view = [memoryview(a) for a in self.l]
self.l10x10 = np.ones((10, 10))
self.float64_dtype = np.dtype(np.float64)
Reported by Pylint.
Line: 12
Column: 9
self.l50 = range(50)
self.float_l1000 = [float(i) for i in range(1000)]
self.float64_l1000 = [np.float64(i) for i in range(1000)]
self.int_l1000 = list(range(1000))
self.l = [np.arange(1000), np.arange(1000)]
self.l_view = [memoryview(a) for a in self.l]
self.l10x10 = np.ones((10, 10))
self.float64_dtype = np.dtype(np.float64)
Reported by Pylint.
Line: 13
Column: 9
self.float_l1000 = [float(i) for i in range(1000)]
self.float64_l1000 = [np.float64(i) for i in range(1000)]
self.int_l1000 = list(range(1000))
self.l = [np.arange(1000), np.arange(1000)]
self.l_view = [memoryview(a) for a in self.l]
self.l10x10 = np.ones((10, 10))
self.float64_dtype = np.dtype(np.float64)
def time_array_1(self):
Reported by Pylint.
Line: 14
Column: 9
self.float64_l1000 = [np.float64(i) for i in range(1000)]
self.int_l1000 = list(range(1000))
self.l = [np.arange(1000), np.arange(1000)]
self.l_view = [memoryview(a) for a in self.l]
self.l10x10 = np.ones((10, 10))
self.float64_dtype = np.dtype(np.float64)
def time_array_1(self):
np.array(1)
Reported by Pylint.
Line: 15
Column: 9
self.int_l1000 = list(range(1000))
self.l = [np.arange(1000), np.arange(1000)]
self.l_view = [memoryview(a) for a in self.l]
self.l10x10 = np.ones((10, 10))
self.float64_dtype = np.dtype(np.float64)
def time_array_1(self):
np.array(1)
Reported by Pylint.
Line: 16
Column: 9
self.l = [np.arange(1000), np.arange(1000)]
self.l_view = [memoryview(a) for a in self.l]
self.l10x10 = np.ones((10, 10))
self.float64_dtype = np.dtype(np.float64)
def time_array_1(self):
np.array(1)
def time_array_empty(self):
Reported by Pylint.
numpy/matrixlib/tests/test_interaction.py
140 issues
Line: 5
Column: 1
Note that tests with MaskedArray and linalg are done in separate files.
"""
import pytest
import textwrap
import warnings
import numpy as np
Reported by Pylint.
Line: 233
Column: 19
def test_average_matrix():
# 2018-04-29: moved here from core.tests.test_function_base.
y = np.matrix(np.random.rand(5, 5))
assert_array_equal(y.mean(0), np.average(y, 0))
a = np.matrix([[1, 2], [3, 4]])
w = np.matrix([[1, 2], [3, 4]])
Reported by Pylint.
Line: 23
Column: 5
# 2018-04-29: moved here from core.tests.test_index.
m = np.matrix([[1, 2], [3, 4]])
assert_(isinstance(m[[0, 1, 0], :], np.matrix))
# gh-3110. Note the transpose currently because matrices do *not*
# support dimension fixing for fancy indexing correctly.
x = np.asmatrix(np.arange(50).reshape(5, 10))
assert_equal(x[:2, np.array(-1)], x[:2, -1].T)
Reported by Pylint.
Line: 38
Column: 5
dom2 = [1, 3]
x = np.matrix([dom1, dom1])
res = np.polynomial.polyutils.mapdomain(x, dom1, dom2)
assert_(isinstance(res, np.matrix))
def test_sort_matrix_none():
# 2018-04-29: moved here from core.tests.test_multiarray
a = np.matrix([[2, 1, 0]])
Reported by Pylint.
Line: 47
Column: 5
actual = np.sort(a, axis=None)
expected = np.matrix([[0, 1, 2]])
assert_equal(actual, expected)
assert_(type(expected) is np.matrix)
def test_partition_matrix_none():
# gh-4301
# 2018-04-29: moved here from core.tests.test_multiarray
Reported by Pylint.
Line: 57
Column: 5
actual = np.partition(a, 1, axis=None)
expected = np.matrix([[0, 1, 2]])
assert_equal(actual, expected)
assert_(type(expected) is np.matrix)
def test_dot_scalar_and_matrix_of_objects():
# Ticket #2469
# 2018-04-29: moved here from core.tests.test_multiarray
Reported by Pylint.
Line: 98
Column: 5
b = np.arange(4).reshape(2, 2).T
i = np.nditer([a, b, None], [],
[['readonly'], ['readonly'], ['writeonly', 'allocate']])
assert_(type(i.operands[2]) is np.matrix)
assert_(type(i.operands[2]) is not np.ndarray)
assert_equal(i.operands[2].shape, (2, 2))
# matrix always wants things to be 2D
b = np.arange(4).reshape(1, 2, 2)
Reported by Pylint.
Line: 99
Column: 5
i = np.nditer([a, b, None], [],
[['readonly'], ['readonly'], ['writeonly', 'allocate']])
assert_(type(i.operands[2]) is np.matrix)
assert_(type(i.operands[2]) is not np.ndarray)
assert_equal(i.operands[2].shape, (2, 2))
# matrix always wants things to be 2D
b = np.arange(4).reshape(1, 2, 2)
assert_raises(RuntimeError, np.nditer, [a, b, None], [],
Reported by Pylint.
Line: 110
Column: 5
i = np.nditer([a, b, None], [],
[['readonly'], ['readonly'],
['writeonly', 'allocate', 'no_subtype']])
assert_(type(i.operands[2]) is np.ndarray)
assert_(type(i.operands[2]) is not np.matrix)
assert_equal(i.operands[2].shape, (1, 2, 2))
def like_function():
Reported by Pylint.
Line: 111
Column: 5
[['readonly'], ['readonly'],
['writeonly', 'allocate', 'no_subtype']])
assert_(type(i.operands[2]) is np.ndarray)
assert_(type(i.operands[2]) is not np.matrix)
assert_equal(i.operands[2].shape, (1, 2, 2))
def like_function():
# 2018-04-29: moved here from core.tests.test_numeric
Reported by Pylint.
tools/npy_tempita/__init__.py
140 issues
Line: 47
Column: 1
from cgi import escape as html_escape
import os
import tokenize
from ._looper import looper
from .compat3 import (
bytes, basestring_, next, is_unicode, coerce_text, iteritems)
__all__ = ['TemplateError', 'Template', 'sub', 'HTMLTemplate',
Reported by Pylint.
Line: 48
Column: 1
import os
import tokenize
from ._looper import looper
from .compat3 import (
bytes, basestring_, next, is_unicode, coerce_text, iteritems)
__all__ = ['TemplateError', 'Template', 'sub', 'HTMLTemplate',
'sub_html', 'html', 'bunch']
Reported by Pylint.
Line: 48
Column: 1
import os
import tokenize
from ._looper import looper
from .compat3 import (
bytes, basestring_, next, is_unicode, coerce_text, iteritems)
__all__ = ['TemplateError', 'Template', 'sub', 'HTMLTemplate',
'sub_html', 'html', 'bunch']
Reported by Pylint.
Line: 48
Column: 1
import os
import tokenize
from ._looper import looper
from .compat3 import (
bytes, basestring_, next, is_unicode, coerce_text, iteritems)
__all__ = ['TemplateError', 'Template', 'sub', 'HTMLTemplate',
'sub_html', 'html', 'bunch']
Reported by Pylint.
Line: 129
Column: 17
except ValueError:
pass
else:
globals = caller.f_globals
lineno = caller.f_lineno
if '__file__' in globals:
name = globals['__file__']
if name.endswith('.pyc') or name.endswith('.pyo'):
name = name[:-1]
Reported by Pylint.
Line: 216
Column: 9
self_ = TemplateObject(self.name)
for name, value in iteritems(defs):
setattr(self_, name, value)
self_.body = body
ns = ns.copy()
ns['self'] = self_
return templ.substitute(ns)
def _interpret_codes(self, codes, ns, out, defs):
Reported by Pylint.
Line: 239
Column: 13
elif name == 'break':
raise _TemplateBreak()
elif name == 'for':
vars, expr, content = code[2], code[3], code[4]
expr = self._eval(expr, ns, pos)
self._interpret_for(vars, expr, content, ns, out, defs)
elif name == 'cond':
parts = code[2:]
self._interpret_if(parts, ns, out, defs)
Reported by Pylint.
Line: 272
Column: 30
else:
assert 0, "Unknown code: %r" % name
def _interpret_for(self, vars, expr, content, ns, out, defs):
# __traceback_hide__ = True
for item in expr:
if len(vars) == 1:
ns[vars[0]] = item
else:
Reported by Pylint.
Line: 309
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
# __traceback_hide__ = True
try:
try:
value = eval(code, self.default_namespace, ns)
except SyntaxError as e:
raise SyntaxError(
'invalid syntax in expression: %s' % code)
return value
except:
Reported by Bandit.
Line: 309
Column: 25
# __traceback_hide__ = True
try:
try:
value = eval(code, self.default_namespace, ns)
except SyntaxError as e:
raise SyntaxError(
'invalid syntax in expression: %s' % code)
return value
except:
Reported by Pylint.
numpy/lib/nanfunctions.py
137 issues
Line: 948
Column: 18
if out is not None and not issubclass(out.dtype.type, np.inexact):
raise TypeError("If a is inexact, then out must be inexact")
cnt = np.sum(~mask, axis=axis, dtype=np.intp, keepdims=keepdims)
tot = np.sum(arr, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
avg = _divide_by_count(tot, cnt, out=out)
isbad = (cnt == 0)
if isbad.any():
Reported by Pylint.
Line: 1540
Column: 18
# keepdims=True, however matrix now raises an error in this case, but
# the reason that it drops the keepdims kwarg is to force keepdims=True
# so this used to work by serendipity.
cnt = np.sum(~mask, axis=axis, dtype=np.intp, keepdims=_keepdims)
avg = np.sum(arr, axis=axis, dtype=dtype, keepdims=_keepdims)
avg = _divide_by_count(avg, cnt)
# Compute squared deviation from mean.
np.subtract(arr, avg, out=arr, casting='unsafe')
Reported by Pylint.
Line: 224
Column: 27
return np.divide(a, b, out=out, casting='unsafe')
def _nanmin_dispatcher(a, axis=None, out=None, keepdims=None):
return (a, out)
@array_function_dispatch(_nanmin_dispatcher)
def nanmin(a, axis=None, out=None, keepdims=np._NoValue):
Reported by Pylint.
Line: 224
Column: 48
return np.divide(a, b, out=out, casting='unsafe')
def _nanmin_dispatcher(a, axis=None, out=None, keepdims=None):
return (a, out)
@array_function_dispatch(_nanmin_dispatcher)
def nanmin(a, axis=None, out=None, keepdims=np._NoValue):
Reported by Pylint.
Line: 229
Column: 45
@array_function_dispatch(_nanmin_dispatcher)
def nanmin(a, axis=None, out=None, keepdims=np._NoValue):
"""
Return minimum of an array or minimum along an axis, ignoring any NaNs.
When all-NaN slices are encountered a ``RuntimeWarning`` is raised and
Nan is returned for that slice.
Reported by Pylint.
Line: 314
Column: 24
"""
kwargs = {}
if keepdims is not np._NoValue:
kwargs['keepdims'] = keepdims
if type(a) is np.ndarray and a.dtype != np.object_:
# Fast, but not safe for subclasses of ndarray, or object arrays,
# which do not implement isnan (gh-9009), or fmin correctly (gh-8975)
res = np.fmin.reduce(a, axis=axis, out=out, **kwargs)
Reported by Pylint.
Line: 339
Column: 27
return res
def _nanmax_dispatcher(a, axis=None, out=None, keepdims=None):
return (a, out)
@array_function_dispatch(_nanmax_dispatcher)
def nanmax(a, axis=None, out=None, keepdims=np._NoValue):
Reported by Pylint.
Line: 339
Column: 48
return res
def _nanmax_dispatcher(a, axis=None, out=None, keepdims=None):
return (a, out)
@array_function_dispatch(_nanmax_dispatcher)
def nanmax(a, axis=None, out=None, keepdims=np._NoValue):
Reported by Pylint.
Line: 344
Column: 45
@array_function_dispatch(_nanmax_dispatcher)
def nanmax(a, axis=None, out=None, keepdims=np._NoValue):
"""
Return the maximum of an array or maximum along an axis, ignoring any
NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is
raised and NaN is returned for that slice.
Reported by Pylint.
Line: 429
Column: 24
"""
kwargs = {}
if keepdims is not np._NoValue:
kwargs['keepdims'] = keepdims
if type(a) is np.ndarray and a.dtype != np.object_:
# Fast, but not safe for subclasses of ndarray, or object arrays,
# which do not implement isnan (gh-9009), or fmax correctly (gh-8975)
res = np.fmax.reduce(a, axis=axis, out=out, **kwargs)
Reported by Pylint.