The following issues were found
numpy/f2py/f90mod_rules.py
64 issues
Line: 22
Column: 1
import numpy as np
from . import capi_maps
from . import func2subr
from .crackfortran import undo_rmbadname, undo_rmbadname1
# The environment provided by auxfuncs.py is needed for some calls to eval.
# As the needed functions cannot be determined by static inspection of the
Reported by Pylint.
Line: 23
Column: 1
import numpy as np
from . import capi_maps
from . import func2subr
from .crackfortran import undo_rmbadname, undo_rmbadname1
# The environment provided by auxfuncs.py is needed for some calls to eval.
# As the needed functions cannot be determined by static inspection of the
# code, it is safest to use import * pending a major refactoring of f2py.
Reported by Pylint.
Line: 24
Column: 1
from . import capi_maps
from . import func2subr
from .crackfortran import undo_rmbadname, undo_rmbadname1
# The environment provided by auxfuncs.py is needed for some calls to eval.
# As the needed functions cannot be determined by static inspection of the
# code, it is safest to use import * pending a major refactoring of f2py.
from .auxfuncs import *
Reported by Pylint.
Line: 29
Column: 1
# The environment provided by auxfuncs.py is needed for some calls to eval.
# As the needed functions cannot be determined by static inspection of the
# code, it is safest to use import * pending a major refactoring of f2py.
from .auxfuncs import *
options = {}
def findf90modules(m):
Reported by Pylint.
Line: 35
Column: 8
def findf90modules(m):
if ismodule(m):
return [m]
if not hasbody(m):
return []
ret = []
for b in m['body']:
Reported by Pylint.
Line: 37
Column: 12
def findf90modules(m):
if ismodule(m):
return [m]
if not hasbody(m):
return []
ret = []
for b in m['body']:
if ismodule(b):
ret.append(b)
Reported by Pylint.
Line: 41
Column: 12
return []
ret = []
for b in m['body']:
if ismodule(b):
ret.append(b)
else:
ret = ret + findf90modules(b)
return ret
Reported by Pylint.
Line: 88
Column: 5
def buildhooks(pymod):
from . import rules
ret = {'f90modhooks': [], 'initf90modhooks': [], 'body': [],
'need': ['F_FUNC', 'arrayobject.h'],
'separatorsfor': {'includes0': '\n', 'includes': '\n'},
'docs': ['"Fortran 90/95 modules:\\n"'],
'latexdoc': []}
Reported by Pylint.
Line: 108
Column: 12
sargsp = []
ifargs = []
mfargs = []
if hasbody(m):
for b in m['body']:
notvars.append(b['name'])
for n in m['vars'].keys():
var = m['vars'][n]
if (n not in notvars) and (not l_or(isintent_hide, isprivate)(var)):
Reported by Pylint.
Line: 113
Column: 44
notvars.append(b['name'])
for n in m['vars'].keys():
var = m['vars'][n]
if (n not in notvars) and (not l_or(isintent_hide, isprivate)(var)):
onlyvars.append(n)
mfargs.append(n)
outmess('\t\tConstructing F90 module support for "%s"...\n' %
(m['name']))
if onlyvars:
Reported by Pylint.
numpy/core/tests/test_custom_dtypes.py
63 issues
Line: 1
Column: 1
import pytest
import numpy as np
from numpy.testing import assert_array_equal
from numpy.core._multiarray_umath import (
_discover_array_parameters as discover_array_params, _get_sfloat_dtype)
SF = _get_sfloat_dtype()
Reported by Pylint.
Line: 5
Column: 1
import numpy as np
from numpy.testing import assert_array_equal
from numpy.core._multiarray_umath import (
_discover_array_parameters as discover_array_params, _get_sfloat_dtype)
SF = _get_sfloat_dtype()
Reported by Pylint.
Line: 57
Column: 44
@pytest.mark.parametrize("aligned", [True, False])
@pytest.mark.parametrize("scaling", [1., -1., 2.])
def test_sfloat_getitem(self, aligned, scaling):
a = self._get_array(1., aligned)
assert a.tolist() == [1., 2., 3.]
@pytest.mark.parametrize("aligned", [True, False])
def test_sfloat_casts(self, aligned):
Reported by Pylint.
Line: 1
Column: 1
import pytest
import numpy as np
from numpy.testing import assert_array_equal
from numpy.core._multiarray_umath import (
_discover_array_parameters as discover_array_params, _get_sfloat_dtype)
SF = _get_sfloat_dtype()
Reported by Pylint.
Line: 12
Column: 1
SF = _get_sfloat_dtype()
class TestSFloat:
def _get_array(self, scaling, aligned=True):
if not aligned:
a = np.empty(3*8 + 1, dtype=np.uint8)[1:]
a = a.view(np.float64)
a[:] = [1., 2., 3.]
Reported by Pylint.
Line: 13
Column: 5
class TestSFloat:
def _get_array(self, scaling, aligned=True):
if not aligned:
a = np.empty(3*8 + 1, dtype=np.uint8)[1:]
a = a.view(np.float64)
a[:] = [1., 2., 3.]
else:
Reported by Pylint.
Line: 15
Column: 13
class TestSFloat:
def _get_array(self, scaling, aligned=True):
if not aligned:
a = np.empty(3*8 + 1, dtype=np.uint8)[1:]
a = a.view(np.float64)
a[:] = [1., 2., 3.]
else:
a = np.array([1., 2., 3.])
Reported by Pylint.
Line: 16
Column: 13
def _get_array(self, scaling, aligned=True):
if not aligned:
a = np.empty(3*8 + 1, dtype=np.uint8)[1:]
a = a.view(np.float64)
a[:] = [1., 2., 3.]
else:
a = np.array([1., 2., 3.])
a *= 1./scaling # the casting code also uses the reciprocal.
Reported by Pylint.
Line: 19
Column: 13
a = a.view(np.float64)
a[:] = [1., 2., 3.]
else:
a = np.array([1., 2., 3.])
a *= 1./scaling # the casting code also uses the reciprocal.
return a.view(SF(scaling))
def test_sfloat_rescaled(self):
Reported by Pylint.
Line: 21
Column: 9
else:
a = np.array([1., 2., 3.])
a *= 1./scaling # the casting code also uses the reciprocal.
return a.view(SF(scaling))
def test_sfloat_rescaled(self):
sf = SF(1.)
sf2 = sf.scaled_by(2.)
Reported by Pylint.
numpy/f2py/tests/util.py
61 issues
Line: 16
Column: 1
import atexit
import textwrap
import re
import pytest
from numpy.compat import asbytes, asstr
from numpy.testing import temppath
from importlib import import_module
Reported by Pylint.
Line: 31
Column: 5
def _cleanup():
global _module_dir
if _module_dir is not None:
try:
sys.path.remove(_module_dir)
except ValueError:
pass
Reported by Pylint.
Line: 45
Column: 5
def get_module_dir():
global _module_dir
if _module_dir is None:
_module_dir = tempfile.mkdtemp()
atexit.register(_cleanup)
if _module_dir not in sys.path:
sys.path.insert(0, _module_dir)
Reported by Pylint.
Line: 56
Column: 5
def get_temp_module_name():
# Assume single-threaded, and the module dir usable only by this thread
global _module_num
d = get_module_dir()
name = "_test_ext_module_%d" % _module_num
_module_num += 1
if name in sys.modules:
# this should not be possible, but check anyway
Reported by Pylint.
Line: 57
Column: 5
def get_temp_module_name():
# Assume single-threaded, and the module dir usable only by this thread
global _module_num
d = get_module_dir()
name = "_test_ext_module_%d" % _module_num
_module_num += 1
if name in sys.modules:
# this should not be possible, but check anyway
raise RuntimeError("Temporary module name already in use.")
Reported by Pylint.
Line: 90
Column: 1
@_memoize
def build_module(source_files, options=[], skip=[], only=[], module_name=None):
"""
Compile and import a f2py module, built from the given files.
"""
Reported by Pylint.
Line: 90
Column: 1
@_memoize
def build_module(source_files, options=[], skip=[], only=[], module_name=None):
"""
Compile and import a f2py module, built from the given files.
"""
Reported by Pylint.
Line: 90
Column: 1
@_memoize
def build_module(source_files, options=[], skip=[], only=[], module_name=None):
"""
Compile and import a f2py module, built from the given files.
"""
Reported by Pylint.
Line: 111
Column: 9
shutil.copyfile(fn, dst)
dst_sources.append(dst)
base, ext = os.path.splitext(dst)
if ext in ('.f90', '.f', '.c', '.pyf'):
f2py_sources.append(dst)
# Prepare options
if module_name is None:
Reported by Pylint.
Line: 131
Column: 14
cmd = [sys.executable, '-c', code] + f2py_opts
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
out, err = p.communicate()
if p.returncode != 0:
raise RuntimeError("Running f2py failed: %s\n%s"
% (cmd[4:], asstr(out)))
finally:
os.chdir(cwd)
Reported by Pylint.
numpy/typing/tests/data/reveal/ufuncs.py
61 issues
Line: 5
Column: 8
import numpy.typing as npt
f8: np.float64
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
reveal_type(np.absolute.__doc__) # E: str
reveal_type(np.absolute.types) # E: builtins.list[builtins.str]
Reported by Pylint.
Line: 6
Column: 8
f8: np.float64
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
reveal_type(np.absolute.__doc__) # E: str
reveal_type(np.absolute.types) # E: builtins.list[builtins.str]
reveal_type(np.absolute.__name__) # E: Literal['absolute']
Reported by Pylint.
Line: 8
Column: 1
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
reveal_type(np.absolute.__doc__) # E: str
reveal_type(np.absolute.types) # E: builtins.list[builtins.str]
reveal_type(np.absolute.__name__) # E: Literal['absolute']
reveal_type(np.absolute.ntypes) # E: Literal[20]
reveal_type(np.absolute.identity) # E: None
Reported by Pylint.
Line: 9
Column: 1
AR_i8: npt.NDArray[np.int64]
reveal_type(np.absolute.__doc__) # E: str
reveal_type(np.absolute.types) # E: builtins.list[builtins.str]
reveal_type(np.absolute.__name__) # E: Literal['absolute']
reveal_type(np.absolute.ntypes) # E: Literal[20]
reveal_type(np.absolute.identity) # E: None
reveal_type(np.absolute.nin) # E: Literal[1]
Reported by Pylint.
Line: 11
Column: 1
reveal_type(np.absolute.__doc__) # E: str
reveal_type(np.absolute.types) # E: builtins.list[builtins.str]
reveal_type(np.absolute.__name__) # E: Literal['absolute']
reveal_type(np.absolute.ntypes) # E: Literal[20]
reveal_type(np.absolute.identity) # E: None
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nout) # E: Literal[1]
Reported by Pylint.
Line: 12
Column: 1
reveal_type(np.absolute.types) # E: builtins.list[builtins.str]
reveal_type(np.absolute.__name__) # E: Literal['absolute']
reveal_type(np.absolute.ntypes) # E: Literal[20]
reveal_type(np.absolute.identity) # E: None
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nout) # E: Literal[1]
reveal_type(np.absolute.nargs) # E: Literal[2]
Reported by Pylint.
Line: 13
Column: 1
reveal_type(np.absolute.__name__) # E: Literal['absolute']
reveal_type(np.absolute.ntypes) # E: Literal[20]
reveal_type(np.absolute.identity) # E: None
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nout) # E: Literal[1]
reveal_type(np.absolute.nargs) # E: Literal[2]
reveal_type(np.absolute.signature) # E: None
Reported by Pylint.
Line: 14
Column: 1
reveal_type(np.absolute.__name__) # E: Literal['absolute']
reveal_type(np.absolute.ntypes) # E: Literal[20]
reveal_type(np.absolute.identity) # E: None
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nout) # E: Literal[1]
reveal_type(np.absolute.nargs) # E: Literal[2]
reveal_type(np.absolute.signature) # E: None
reveal_type(np.absolute(f8)) # E: Any
Reported by Pylint.
Line: 15
Column: 1
reveal_type(np.absolute.ntypes) # E: Literal[20]
reveal_type(np.absolute.identity) # E: None
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nout) # E: Literal[1]
reveal_type(np.absolute.nargs) # E: Literal[2]
reveal_type(np.absolute.signature) # E: None
reveal_type(np.absolute(f8)) # E: Any
reveal_type(np.absolute(AR_f8)) # E: numpy.ndarray
Reported by Pylint.
Line: 16
Column: 1
reveal_type(np.absolute.identity) # E: None
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nin) # E: Literal[1]
reveal_type(np.absolute.nout) # E: Literal[1]
reveal_type(np.absolute.nargs) # E: Literal[2]
reveal_type(np.absolute.signature) # E: None
reveal_type(np.absolute(f8)) # E: Any
reveal_type(np.absolute(AR_f8)) # E: numpy.ndarray
reveal_type(np.absolute.at(AR_f8, AR_i8)) # E: None
Reported by Pylint.
numpy/fft/_pocketfft.py
61 issues
Line: 36
Column: 1
import functools
from numpy.core import asarray, zeros, swapaxes, conjugate, take, sqrt
from . import _pocketfft_internal as pfi
from numpy.core.multiarray import normalize_axis_index
from numpy.core import overrides
array_function_dispatch = functools.partial(
Reported by Pylint.
Line: 118
Column: 32
'"ortho" or "forward".') from None
def _fft_dispatcher(a, n=None, axis=None, norm=None):
return (a,)
@array_function_dispatch(_fft_dispatcher)
def fft(a, n=None, axis=-1, norm=None):
Reported by Pylint.
Line: 118
Column: 24
'"ortho" or "forward".') from None
def _fft_dispatcher(a, n=None, axis=None, norm=None):
return (a,)
@array_function_dispatch(_fft_dispatcher)
def fft(a, n=None, axis=-1, norm=None):
Reported by Pylint.
Line: 118
Column: 43
'"ortho" or "forward".') from None
def _fft_dispatcher(a, n=None, axis=None, norm=None):
return (a,)
@array_function_dispatch(_fft_dispatcher)
def fft(a, n=None, axis=-1, norm=None):
Reported by Pylint.
Line: 711
Column: 25
return a
def _fftn_dispatcher(a, s=None, axes=None, norm=None):
return (a,)
@array_function_dispatch(_fftn_dispatcher)
def fftn(a, s=None, axes=None, norm=None):
Reported by Pylint.
Line: 711
Column: 44
return a
def _fftn_dispatcher(a, s=None, axes=None, norm=None):
return (a,)
@array_function_dispatch(_fftn_dispatcher)
def fftn(a, s=None, axes=None, norm=None):
Reported by Pylint.
Line: 711
Column: 33
return a
def _fftn_dispatcher(a, s=None, axes=None, norm=None):
return (a,)
@array_function_dispatch(_fftn_dispatcher)
def fftn(a, s=None, axes=None, norm=None):
Reported by Pylint.
Line: 1
Column: 1
"""
Discrete Fourier Transforms
Routines in this module:
fft(a, n=None, axis=-1, norm="backward")
ifft(a, n=None, axis=-1, norm="backward")
rfft(a, n=None, axis=-1, norm="backward")
irfft(a, n=None, axis=-1, norm="backward")
Reported by Pylint.
Line: 37
Column: 1
from numpy.core import asarray, zeros, swapaxes, conjugate, take, sqrt
from . import _pocketfft_internal as pfi
from numpy.core.multiarray import normalize_axis_index
from numpy.core import overrides
array_function_dispatch = functools.partial(
overrides.array_function_dispatch, module='numpy.fft')
Reported by Pylint.
Line: 38
Column: 1
from numpy.core import asarray, zeros, swapaxes, conjugate, take, sqrt
from . import _pocketfft_internal as pfi
from numpy.core.multiarray import normalize_axis_index
from numpy.core import overrides
array_function_dispatch = functools.partial(
overrides.array_function_dispatch, module='numpy.fft')
Reported by Pylint.
numpy/distutils/command/config.py
60 issues
Line: 46
Column: 3
if sys.platform == 'win32' and (self.compiler.compiler_type in
('msvc', 'intelw', 'intelemw')):
# XXX: hack to circumvent a python 2.6 bug with msvc9compiler:
# initialize call query_vcvarsall, which throws an IOError, and
# causes an error along the way without much information. We try to
# catch it here, hoping it is early enough, and print an helpful
# message instead of Error: None.
if not self.compiler.initialized:
Reported by Pylint.
Line: 80
Column: 13
ldflags.append('/MANIFEST')
if not isinstance(self.fcompiler, FCompiler):
self.fcompiler = new_fcompiler(compiler=self.fcompiler,
dry_run=self.dry_run, force=1,
c_compiler=self.compiler)
if self.fcompiler is not None:
self.fcompiler.customize(self.distribution)
if self.fcompiler.get_version():
Reported by Pylint.
Line: 90
Column: 9
self.fcompiler.show_customization()
def _wrap_method(self, mth, lang, args):
from distutils.ccompiler import CompileError
from distutils.errors import DistutilsExecError
save_compiler = self.compiler
if lang in ['f77', 'f90']:
self.compiler = self.fcompiler
if self.compiler is None:
Reported by Pylint.
Line: 90
Column: 9
self.fcompiler.show_customization()
def _wrap_method(self, mth, lang, args):
from distutils.ccompiler import CompileError
from distutils.errors import DistutilsExecError
save_compiler = self.compiler
if lang in ['f77', 'f90']:
self.compiler = self.fcompiler
if self.compiler is None:
Reported by Pylint.
Line: 94
Column: 13
from distutils.errors import DistutilsExecError
save_compiler = self.compiler
if lang in ['f77', 'f90']:
self.compiler = self.fcompiler
if self.compiler is None:
raise CompileError('%s compiler is not set' % (lang,))
try:
ret = mth(*((self,)+args))
except (DistutilsExecError, CompileError) as e:
Reported by Pylint.
Line: 100
Column: 13
try:
ret = mth(*((self,)+args))
except (DistutilsExecError, CompileError) as e:
self.compiler = save_compiler
raise CompileError from e
self.compiler = save_compiler
return ret
def _compile (self, body, headers, include_dirs, lang):
Reported by Pylint.
Line: 102
Column: 9
except (DistutilsExecError, CompileError) as e:
self.compiler = save_compiler
raise CompileError from e
self.compiler = save_compiler
return ret
def _compile (self, body, headers, include_dirs, lang):
src, obj = self._wrap_method(old_config._compile, lang,
(body, headers, include_dirs, lang))
Reported by Pylint.
Line: 205
Column: 13
return self.try_compile(body, headers, include_dirs)
def check_type(self, type_name, headers=None, include_dirs=None,
library_dirs=None):
"""Check type availability. Return True if the type can be compiled,
False otherwise"""
self._check_compiler()
# First check the type can be compiled
Reported by Pylint.
Line: 233
Column: 75
return st
def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None, expected=None):
"""Check size of a given type."""
self._check_compiler()
# First check the type can be compiled
body = textwrap.dedent(r"""
Reported by Pylint.
Line: 316
Column: 5
low = mid + 1
return low
def check_func(self, func,
headers=None, include_dirs=None,
libraries=None, library_dirs=None,
decl=False, call=False, call_args=None):
# clean up distutils's config a bit: add void to main(), and
# return a value.
Reported by Pylint.
numpy/distutils/fcompiler/gnu.py
60 issues
Line: 19
Column: 3
TARGET_R = re.compile(r"Target: ([a-zA-Z0-9_\-]*)")
# XXX: handle cross compilation
def is_win64():
return sys.platform == "win32" and platform.architecture()[0] == "64bit"
Reported by Pylint.
Line: 26
Column: 1
return sys.platform == "win32" and platform.architecture()[0] == "64bit"
class GnuFCompiler(FCompiler):
compiler_type = 'gnu'
compiler_aliases = ('g77', )
description = 'GNU Fortran 77 compiler'
def gnu_version_match(self, version_string):
Reported by Pylint.
Line: 26
Column: 1
return sys.platform == "win32" and platform.architecture()[0] == "64bit"
class GnuFCompiler(FCompiler):
compiler_type = 'gnu'
compiler_aliases = ('g77', )
description = 'GNU Fortran 77 compiler'
def gnu_version_match(self, version_string):
Reported by Pylint.
Line: 249
Column: 42
def get_flags_arch(self):
return []
def runtime_library_dir_option(self, dir):
if sys.platform == 'win32' or sys.platform == 'cygwin':
# Linux/Solaris/Unix support RPATH, Windows does not
raise NotImplementedError
# TODO: could use -Xlinker here, if it's supported
Reported by Pylint.
Line: 254
Column: 3
# Linux/Solaris/Unix support RPATH, Windows does not
raise NotImplementedError
# TODO: could use -Xlinker here, if it's supported
assert "," not in dir
if sys.platform == 'darwin':
return f'-Wl,-rpath,{dir}'
elif sys.platform[:3] == 'aix':
Reported by Pylint.
Line: 266
Column: 1
return f'-Wl,-rpath={dir}'
class Gnu95FCompiler(GnuFCompiler):
compiler_type = 'gnu95'
compiler_aliases = ('gfortran', )
description = 'GNU Fortran 95 compiler'
def version_match(self, version_string):
Reported by Pylint.
Line: 396
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5
return ""
def _hash_files(self, filenames):
h = hashlib.sha1()
for fn in filenames:
with open(fn, 'rb') as f:
while True:
block = f.read(131072)
if not block:
Reported by Bandit.
Line: 470
Column: 5
return lib_path, dll_path
def can_ccompiler_link(self, compiler):
# MSVC cannot link objects compiled by GNU fortran
return compiler.compiler_type not in ("msvc", )
def wrap_unlinkable_objects(self, objects, output_dir, extra_dll_dir):
"""
Reported by Pylint.
Line: 549
Column: 12
print(customized_fcompiler('gnu').get_version())
try:
print(customized_fcompiler('g95').get_version())
except Exception as e:
print(e)
Reported by Pylint.
Line: 1
Column: 1
import re
import os
import sys
import warnings
import platform
import tempfile
import hashlib
import base64
import subprocess
Reported by Pylint.
numpy/linalg/tests/test_regression.py
59 issues
Line: 142
Column: 13
# gh-9891
size = 20
n_rhs = 70
G = np.random.randn(size, size) + 1j * np.random.randn(size, size)
u = np.random.randn(size, n_rhs) + 1j * np.random.randn(size, n_rhs)
b = G.dot(u)
# This should work without segmentation fault.
u_lstsq, res, rank, sv = linalg.lstsq(G, b, rcond=None)
# check results just in case
Reported by Pylint.
Line: 142
Column: 48
# gh-9891
size = 20
n_rhs = 70
G = np.random.randn(size, size) + 1j * np.random.randn(size, size)
u = np.random.randn(size, n_rhs) + 1j * np.random.randn(size, n_rhs)
b = G.dot(u)
# This should work without segmentation fault.
u_lstsq, res, rank, sv = linalg.lstsq(G, b, rcond=None)
# check results just in case
Reported by Pylint.
Line: 143
Column: 49
size = 20
n_rhs = 70
G = np.random.randn(size, size) + 1j * np.random.randn(size, size)
u = np.random.randn(size, n_rhs) + 1j * np.random.randn(size, n_rhs)
b = G.dot(u)
# This should work without segmentation fault.
u_lstsq, res, rank, sv = linalg.lstsq(G, b, rcond=None)
# check results just in case
assert_array_almost_equal(u_lstsq, u)
Reported by Pylint.
Line: 143
Column: 13
size = 20
n_rhs = 70
G = np.random.randn(size, size) + 1j * np.random.randn(size, size)
u = np.random.randn(size, n_rhs) + 1j * np.random.randn(size, n_rhs)
b = G.dot(u)
# This should work without segmentation fault.
u_lstsq, res, rank, sv = linalg.lstsq(G, b, rcond=None)
# check results just in case
assert_array_almost_equal(u_lstsq, u)
Reported by Pylint.
Line: 33
Column: 13
a = arange(13 * 13, dtype=float64)
a.shape = (13, 13)
a = a % 17
va, ve = linalg.eig(a)
va.sort()
rva.sort()
assert_array_almost_equal(va, rva)
def test_eigh_build(self):
Reported by Pylint.
Line: 46
Column: 15
[3.51489954, 88.97013878, -1.07431931],
[15.64602427, -1.07431931, 98.18223512]])
vals, vecs = linalg.eigh(cov)
assert_array_almost_equal(vals, rvals)
def test_svd_build(self):
# Ticket 627.
a = array([[0., 1.], [1., 1.], [2., 1.], [3., 1.]])
Reported by Pylint.
Line: 52
Column: 9
def test_svd_build(self):
# Ticket 627.
a = array([[0., 1.], [1., 1.], [2., 1.], [3., 1.]])
m, n = a.shape
u, s, vh = linalg.svd(a)
b = dot(transpose(u[:, n:]), a)
assert_array_almost_equal(b, np.zeros((2, 2)))
Reported by Pylint.
Line: 53
Column: 15
# Ticket 627.
a = array([[0., 1.], [1., 1.], [2., 1.], [3., 1.]])
m, n = a.shape
u, s, vh = linalg.svd(a)
b = dot(transpose(u[:, n:]), a)
assert_array_almost_equal(b, np.zeros((2, 2)))
Reported by Pylint.
Line: 53
Column: 12
# Ticket 627.
a = array([[0., 1.], [1., 1.], [2., 1.], [3., 1.]])
m, n = a.shape
u, s, vh = linalg.svd(a)
b = dot(transpose(u[:, n:]), a)
assert_array_almost_equal(b, np.zeros((2, 2)))
Reported by Pylint.
Line: 96
Column: 9
norm = linalg.norm(testvector)
assert_array_equal(norm, [0, 1])
assert_(norm.dtype == np.dtype('float64'))
norm = linalg.norm(testvector, ord=1)
assert_array_equal(norm, [0, 1])
assert_(norm.dtype != np.dtype('float64'))
Reported by Pylint.
numpy/ma/tests/test_regression.py
59 issues
Line: 24
Column: 9
a = np.zeros((1, 1))
b = np.zeros(a.shape, MaskType)
c = masked_where(b, a)
a-c
def test_masked_array_multiply(self):
# Ticket #254
a = np.ma.zeros((4, 1))
a[2, 0] = np.ma.masked
Reported by Pylint.
Line: 31
Column: 9
a = np.ma.zeros((4, 1))
a[2, 0] = np.ma.masked
b = np.zeros((4, 2))
a*b
b*a
def test_masked_array_repeat(self):
# Ticket #271
np.ma.array([1], mask=False).repeat(10)
Reported by Pylint.
Line: 32
Column: 9
a[2, 0] = np.ma.masked
b = np.zeros((4, 2))
a*b
b*a
def test_masked_array_repeat(self):
# Ticket #271
np.ma.array([1], mask=False).repeat(10)
Reported by Pylint.
Line: 46
Column: 9
# Ticket #1559
a = np.ma.masked_array([0.0, 1.2, 3.5], mask=[False, True, False])
b = np.atleast_2d(a)
assert_(a.mask.ndim == 1)
assert_(b.mask.ndim == 2)
def test_set_fill_value_unicode_py3(self):
# Ticket #2733
a = np.ma.masked_array(['a', 'b', 'c'], mask=[1, 0, 0])
Reported by Pylint.
Line: 47
Column: 9
a = np.ma.masked_array([0.0, 1.2, 3.5], mask=[False, True, False])
b = np.atleast_2d(a)
assert_(a.mask.ndim == 1)
assert_(b.mask.ndim == 2)
def test_set_fill_value_unicode_py3(self):
# Ticket #2733
a = np.ma.masked_array(['a', 'b', 'c'], mask=[1, 0, 0])
a.fill_value = 'X'
Reported by Pylint.
Line: 53
Column: 9
# Ticket #2733
a = np.ma.masked_array(['a', 'b', 'c'], mask=[1, 0, 0])
a.fill_value = 'X'
assert_(a.fill_value == 'X')
def test_var_sets_maskedarray_scalar(self):
# Issue gh-2757
a = np.ma.array(np.arange(5), mask=True)
mout = np.ma.array(-1, dtype=float)
Reported by Pylint.
Line: 60
Column: 17
a = np.ma.array(np.arange(5), mask=True)
mout = np.ma.array(-1, dtype=float)
a.var(out=mout)
assert_(mout._data == 0)
def test_ddof_corrcoef(self):
# See gh-3336
x = np.ma.masked_equal([1, 2, 3, 4, 5], 4)
y = np.array([2, 2.5, 3.1, 3, 5])
Reported by Pylint.
Line: 60
Column: 9
a = np.ma.array(np.arange(5), mask=True)
mout = np.ma.array(-1, dtype=float)
a.var(out=mout)
assert_(mout._data == 0)
def test_ddof_corrcoef(self):
# See gh-3336
x = np.ma.masked_equal([1, 2, 3, 4, 5], 4)
y = np.array([2, 2.5, 3.1, 3, 5])
Reported by Pylint.
Line: 77
Column: 9
def test_mask_not_backmangled(self):
# See gh-10314. Test case taken from gh-3140.
a = np.ma.MaskedArray([1., 2.], mask=[False, False])
assert_(a.mask.shape == (2,))
b = np.tile(a, (2, 1))
# Check that the above no longer changes a.shape to (1, 2)
assert_(a.mask.shape == (2,))
assert_(b.shape == (2, 2))
assert_(b.mask.shape == (2, 2))
Reported by Pylint.
Line: 80
Column: 9
assert_(a.mask.shape == (2,))
b = np.tile(a, (2, 1))
# Check that the above no longer changes a.shape to (1, 2)
assert_(a.mask.shape == (2,))
assert_(b.shape == (2, 2))
assert_(b.mask.shape == (2, 2))
def test_empty_list_on_structured(self):
# See gh-12464. Indexing with empty list should give empty result.
Reported by Pylint.
numpy/core/tests/test_cython.py
59 issues
Line: 5
Column: 1
import shutil
import subprocess
import sys
import pytest
import numpy as np
# This import is copied from random.tests.test_extending
try:
Reported by Pylint.
Line: 69
Column: 5
def test_is_timedelta64_object(install_temp):
import checks
assert checks.is_td64(np.timedelta64(1234))
assert checks.is_td64(np.timedelta64(1234, "ns"))
assert checks.is_td64(np.timedelta64("NaT", "ns"))
Reported by Pylint.
Line: 82
Column: 5
def test_is_datetime64_object(install_temp):
import checks
assert checks.is_dt64(np.datetime64(1234, "ns"))
assert checks.is_dt64(np.datetime64("NaT", "ns"))
assert not checks.is_dt64(1)
Reported by Pylint.
Line: 94
Column: 5
def test_get_datetime64_value(install_temp):
import checks
dt64 = np.datetime64("2016-01-01", "ns")
result = checks.get_dt64_value(dt64)
expected = dt64.view("i8")
Reported by Pylint.
Line: 99
Column: 16
dt64 = np.datetime64("2016-01-01", "ns")
result = checks.get_dt64_value(dt64)
expected = dt64.view("i8")
assert result == expected
def test_get_timedelta64_value(install_temp):
Reported by Pylint.
Line: 105
Column: 5
def test_get_timedelta64_value(install_temp):
import checks
td64 = np.timedelta64(12345, "h")
result = checks.get_td64_value(td64)
expected = td64.view("i8")
Reported by Pylint.
Line: 110
Column: 16
td64 = np.timedelta64(12345, "h")
result = checks.get_td64_value(td64)
expected = td64.view("i8")
assert result == expected
def test_get_datetime64_unit(install_temp):
Reported by Pylint.
Line: 116
Column: 5
def test_get_datetime64_unit(install_temp):
import checks
dt64 = np.datetime64("2016-01-01", "ns")
result = checks.get_dt64_unit(dt64)
expected = 10
assert result == expected
Reported by Pylint.
Line: 130
Column: 5
def test_abstract_scalars(install_temp):
import checks
assert checks.is_integer(1)
assert checks.is_integer(np.int8(1))
assert checks.is_integer(np.uint64(1))
Reported by Pylint.
Line: 31
Column: 18
@pytest.fixture
def install_temp(request, tmp_path):
# Based in part on test_cython from random.tests.test_extending
here = os.path.dirname(__file__)
ext_dir = os.path.join(here, "examples")
Reported by Pylint.