The following issues were found
numpy/f2py/tests/test_return_integer.py
28 issues
Line: 1
Column: 1
import pytest
from numpy import array
from numpy.testing import assert_, assert_raises
from . import util
class TestReturnInteger(util.F2PyTest):
Reported by Pylint.
Line: 5
Column: 1
from numpy import array
from numpy.testing import assert_, assert_raises
from . import util
class TestReturnInteger(util.F2PyTest):
def check_function(self, t, tname):
Reported by Pylint.
Line: 11
Column: 9
class TestReturnInteger(util.F2PyTest):
def check_function(self, t, tname):
assert_(t(123) == 123, repr(t(123)))
assert_(t(123.6) == 123)
assert_(t('123') == 123)
assert_(t(-123) == -123)
assert_(t([123]) == 123)
assert_(t((123,)) == 123)
Reported by Pylint.
Line: 12
Column: 9
def check_function(self, t, tname):
assert_(t(123) == 123, repr(t(123)))
assert_(t(123.6) == 123)
assert_(t('123') == 123)
assert_(t(-123) == -123)
assert_(t([123]) == 123)
assert_(t((123,)) == 123)
assert_(t(array(123)) == 123)
Reported by Pylint.
Line: 13
Column: 9
def check_function(self, t, tname):
assert_(t(123) == 123, repr(t(123)))
assert_(t(123.6) == 123)
assert_(t('123') == 123)
assert_(t(-123) == -123)
assert_(t([123]) == 123)
assert_(t((123,)) == 123)
assert_(t(array(123)) == 123)
assert_(t(array([123])) == 123)
Reported by Pylint.
Line: 14
Column: 9
assert_(t(123) == 123, repr(t(123)))
assert_(t(123.6) == 123)
assert_(t('123') == 123)
assert_(t(-123) == -123)
assert_(t([123]) == 123)
assert_(t((123,)) == 123)
assert_(t(array(123)) == 123)
assert_(t(array([123])) == 123)
assert_(t(array([[123]])) == 123)
Reported by Pylint.
Line: 15
Column: 9
assert_(t(123.6) == 123)
assert_(t('123') == 123)
assert_(t(-123) == -123)
assert_(t([123]) == 123)
assert_(t((123,)) == 123)
assert_(t(array(123)) == 123)
assert_(t(array([123])) == 123)
assert_(t(array([[123]])) == 123)
assert_(t(array([123], 'b')) == 123)
Reported by Pylint.
Line: 16
Column: 9
assert_(t('123') == 123)
assert_(t(-123) == -123)
assert_(t([123]) == 123)
assert_(t((123,)) == 123)
assert_(t(array(123)) == 123)
assert_(t(array([123])) == 123)
assert_(t(array([[123]])) == 123)
assert_(t(array([123], 'b')) == 123)
assert_(t(array([123], 'h')) == 123)
Reported by Pylint.
Line: 17
Column: 9
assert_(t(-123) == -123)
assert_(t([123]) == 123)
assert_(t((123,)) == 123)
assert_(t(array(123)) == 123)
assert_(t(array([123])) == 123)
assert_(t(array([[123]])) == 123)
assert_(t(array([123], 'b')) == 123)
assert_(t(array([123], 'h')) == 123)
assert_(t(array([123], 'i')) == 123)
Reported by Pylint.
Line: 18
Column: 9
assert_(t([123]) == 123)
assert_(t((123,)) == 123)
assert_(t(array(123)) == 123)
assert_(t(array([123])) == 123)
assert_(t(array([[123]])) == 123)
assert_(t(array([123], 'b')) == 123)
assert_(t(array([123], 'h')) == 123)
assert_(t(array([123], 'i')) == 123)
assert_(t(array([123], 'l')) == 123)
Reported by Pylint.
tools/openblas_support.py
27 issues
Line: 2
Column: 1
import glob
import hashlib
import os
import platform
import sysconfig
import sys
import shutil
import tarfile
import textwrap
Reported by Pylint.
Line: 62
Column: 3
else:
default = '2014'
ret = os.environ.get("MB_ML_VER", default)
# XXX For PEP 600 this can be a glibc version
assert ret in ('1', '2010', '2014', '_2_24'), f'invalid MB_ML_VER {ret}'
return ret
def download_openblas(target, plat, ilp64):
Reported by Pylint.
Line: 97
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b310-urllib-urlopen
filename = f'{BASEURL}/openblas{fnsuffix}-{OPENBLAS_LONG}-{suffix}'
req = Request(url=filename, headers=headers)
try:
response = urlopen(req)
except HTTPError:
print(f'Could not download "{filename}"', file=sys.stderr)
raise
length = response.getheader('content-length')
if response.status != 200:
Reported by Bandit.
Line: 108
Column: 5
print(f"Downloading {length} from {filename}", file=sys.stderr)
data = response.read()
# Verify hash
key = os.path.basename(filename)
print("Saving to file", file=sys.stderr)
with open(target, 'wb') as fid:
fid.write(data)
return typ
Reported by Pylint.
Line: 132
Column: 13
typ = download_openblas(tmp, plat, ilp64)
if not typ:
return ''
osname, arch = plat.split("-")
if osname == 'win':
if not typ == 'zip':
return f'expecting to download zipfile on windows, not {typ}'
return unpack_windows_zip(tmp)
else:
Reported by Pylint.
Line: 269
Column: 20
try:
try:
target = setup_openblas(plat, ilp64)
except Exception as e:
print(f'Could not setup {plat} with ilp64 {ilp64}, ')
print(e)
errs.append(e)
continue
if not target:
Reported by Pylint.
Line: 302
Column: 23
import numpy
import ctypes
dll = ctypes.CDLL(numpy.core._multiarray_umath.__file__)
if ilp64 == "64_":
get_config = dll.openblas_get_config64_
else:
get_config = dll.openblas_get_config
get_config.restype = ctypes.c_char_p
Reported by Pylint.
Line: 1
Column: 1
import glob
import hashlib
import os
import platform
import sysconfig
import sys
import shutil
import tarfile
import textwrap
Reported by Pylint.
Line: 34
Column: 1
IS_32BIT = sys.maxsize < 2**32
def get_plat():
plat = sysconfig.get_platform()
plat_split = plat.split("-")
arch = plat_split[-1]
if arch == "win32":
plat = "win-32"
Reported by Pylint.
Line: 44
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
plat = f"macosx-{platform.uname().machine}"
elif len(plat_split) > 2:
plat = f"{plat_split[0]}-{arch}"
assert plat in SUPPORTED_PLATFORMS, f'invalid platform {plat}'
return plat
def get_ilp64():
if os.environ.get("NPY_USE_BLAS_ILP64", "0") == "0":
Reported by Bandit.
tools/travis-sorter.py
27 issues
Line: 91
Column: 15
count = 1
def summarise(jobs):
end = 0
print("ID Duration in mins")
for job in jobs:
before = " " * job.started
active = "*" * job.length
Reported by Pylint.
Line: 94
Column: 9
def summarise(jobs):
end = 0
print("ID Duration in mins")
for job in jobs:
before = " " * job.started
active = "*" * job.length
print("{:2d} {}{}".format(job.id, before, active))
if job.started + job.length > end:
end = job.started + job.length
Reported by Pylint.
Line: 108
Column: 9
class Job:
def __init__(self, length):
global count
self.id = count
count += 1
self.length = length
self.started = -1
self.status = "not started"
Reported by Pylint.
Line: 122
Column: 18
)
def count_status(jobs, status):
number = 0
for job in jobs:
if job.status == status:
number += 1
return number
Reported by Pylint.
Line: 123
Column: 5
def count_status(jobs, status):
number = 0
for job in jobs:
if job.status == status:
number += 1
return number
Reported by Pylint.
Line: 124
Column: 9
def count_status(jobs, status):
number = 0
for job in jobs:
if job.status == status:
number += 1
return number
Reported by Pylint.
Line: 130
Column: 14
return number
def simulate(jobs, limit):
time = 0
# summarise(jobs)
Reported by Pylint.
Line: 138
Column: 13
while True:
# Check if any have ended
for job in jobs:
if job.status == "active":
if time >= job.started + job.length:
# print("{}/{} Finished:".format(count_status(jobs, "active"), limit))
job.ended = time
job.status = "finished"
Reported by Pylint.
Line: 164
Column: 20
summarise(jobs)
def do_thing(repo, number):
cmd = f"travis show -r {repo} {number or ''}"
# cmd = f"travis show --com -r {repo} {number or ''}"
print(cmd)
exitcode = 0
Reported by Pylint.
Line: 223
Column: 9
minutes = []
matches = re.findall(r"(pass|fail|error)ed.* (\d+) min (\d+)? ", output)
for match in matches:
status, m, s = match
s = 0 if s == "" else int(s)
s += int(m) * 60
minutes.append(round(s / 60))
# print(minutes)
Reported by Pylint.
tools/c_coverage/c_coverage_report.py
27 issues
Line: 118
Column: 19
fd.close()
def collect_stats(files, fd, pattern):
# TODO: Handle compressed callgrind files
line_regexs = [
re.compile(r"(?P<lineno>[0-9]+)(\s[0-9]+)+"),
re.compile(r"((jump)|(jcnd))=([0-9]+)\s(?P<lineno>[0-9]+)")
]
Reported by Pylint.
Line: 119
Column: 3
def collect_stats(files, fd, pattern):
# TODO: Handle compressed callgrind files
line_regexs = [
re.compile(r"(?P<lineno>[0-9]+)(\s[0-9]+)+"),
re.compile(r"((jump)|(jcnd))=([0-9]+)\s(?P<lineno>[0-9]+)")
]
Reported by Pylint.
Line: 127
Column: 9
current_file = None
current_function = None
for i, line in enumerate(fd):
if re.match("f[lie]=.+", line):
path = line.split('=', 2)[1].strip()
if os.path.exists(path) and re.search(pattern, path):
current_file = files.get_file(path)
else:
Reported by Pylint.
Line: 10
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b406-import-xml-sax
import os
import re
import sys
from xml.sax.saxutils import quoteattr, escape
try:
import pygments
if tuple([int(x) for x in pygments.__version__.split('.')]) < (0, 11):
raise ImportError()
Reported by Bandit.
Line: 14
Column: 8
try:
import pygments
if tuple([int(x) for x in pygments.__version__.split('.')]) < (0, 11):
raise ImportError()
from pygments import highlight
from pygments.lexers import CLexer
from pygments.formatters import HtmlFormatter
has_pygments = True
Reported by Pylint.
Line: 19
Column: 5
from pygments import highlight
from pygments.lexers import CLexer
from pygments.formatters import HtmlFormatter
has_pygments = True
except ImportError:
print("This script requires pygments 0.11 or greater to generate HTML")
has_pygments = False
Reported by Pylint.
Line: 22
Column: 5
has_pygments = True
except ImportError:
print("This script requires pygments 0.11 or greater to generate HTML")
has_pygments = False
class FunctionHtmlFormatter(HtmlFormatter):
"""Custom HTML formatter to insert extra information with the lines."""
def __init__(self, lines, **kwargs):
Reported by Pylint.
Line: 25
Column: 1
has_pygments = False
class FunctionHtmlFormatter(HtmlFormatter):
"""Custom HTML formatter to insert extra information with the lines."""
def __init__(self, lines, **kwargs):
HtmlFormatter.__init__(self, **kwargs)
self.lines = lines
Reported by Pylint.
Line: 31
Column: 5
HtmlFormatter.__init__(self, **kwargs)
self.lines = lines
def wrap(self, source, outfile):
for i, (c, t) in enumerate(HtmlFormatter.wrap(self, source, outfile)):
as_functions = self.lines.get(i-1, None)
if as_functions is not None:
yield 0, ('<div title=%s style="background: #ccffcc">[%2d]' %
(quoteattr('as ' + ', '.join(as_functions)),
Reported by Pylint.
Line: 32
Column: 20
self.lines = lines
def wrap(self, source, outfile):
for i, (c, t) in enumerate(HtmlFormatter.wrap(self, source, outfile)):
as_functions = self.lines.get(i-1, None)
if as_functions is not None:
yield 0, ('<div title=%s style="background: #ccffcc">[%2d]' %
(quoteattr('as ' + ', '.join(as_functions)),
len(as_functions)))
Reported by Pylint.
numpy/core/tests/test_item_selection.py
27 issues
Line: 47
Column: 29
assert_array_equal(res, tresult[real_index])
else:
res = ta.take(index_array, mode=mode, axis=1)
assert_(res.shape == (2,) + index_array.shape)
def test_refcounting(self):
objects = [object() for i in range(10)]
for mode in ('raise', 'clip', 'wrap'):
a = np.array(objects)
Reported by Pylint.
Line: 57
Column: 17
a.take(b, out=a[:6], mode=mode)
del a
if HAS_REFCOUNT:
assert_(all(sys.getrefcount(o) == 3 for o in objects))
# not contiguous, example:
a = np.array(objects * 2)[::2]
a.take(b, out=a[:6], mode=mode)
del a
if HAS_REFCOUNT:
Reported by Pylint.
Line: 63
Column: 17
a.take(b, out=a[:6], mode=mode)
del a
if HAS_REFCOUNT:
assert_(all(sys.getrefcount(o) == 3 for o in objects))
def test_unicode_mode(self):
d = np.arange(10)
k = b'\xc3\xa4'.decode("UTF8")
assert_raises(ValueError, d.take, 5, mode=k)
Reported by Pylint.
Line: 1
Column: 1
import sys
import numpy as np
from numpy.testing import (
assert_, assert_raises, assert_array_equal, HAS_REFCOUNT
)
class TestTake:
Reported by Pylint.
Line: 9
Column: 1
)
class TestTake:
def test_simple(self):
a = [[1, 2], [3, 4]]
a_str = [[b'1', b'2'], [b'3', b'4']]
modes = ['raise', 'wrap', 'clip']
indices = [-1, 4]
Reported by Pylint.
Line: 10
Column: 5
class TestTake:
def test_simple(self):
a = [[1, 2], [3, 4]]
a_str = [[b'1', b'2'], [b'3', b'4']]
modes = ['raise', 'wrap', 'clip']
indices = [-1, 4]
index_arrays = [np.empty(0, dtype=np.intp),
Reported by Pylint.
Line: 10
Column: 5
class TestTake:
def test_simple(self):
a = [[1, 2], [3, 4]]
a_str = [[b'1', b'2'], [b'3', b'4']]
modes = ['raise', 'wrap', 'clip']
indices = [-1, 4]
index_arrays = [np.empty(0, dtype=np.intp),
Reported by Pylint.
Line: 10
Column: 5
class TestTake:
def test_simple(self):
a = [[1, 2], [3, 4]]
a_str = [[b'1', b'2'], [b'3', b'4']]
modes = ['raise', 'wrap', 'clip']
indices = [-1, 4]
index_arrays = [np.empty(0, dtype=np.intp),
Reported by Pylint.
Line: 11
Column: 9
class TestTake:
def test_simple(self):
a = [[1, 2], [3, 4]]
a_str = [[b'1', b'2'], [b'3', b'4']]
modes = ['raise', 'wrap', 'clip']
indices = [-1, 4]
index_arrays = [np.empty(0, dtype=np.intp),
np.empty(tuple(), dtype=np.intp),
Reported by Pylint.
Line: 26
Column: 13
# refcounted struct on top of object, which has a size that hits the
# default (non-specialized) path.
types = int, object, np.dtype([('', 'i2', 3)])
for t in types:
# ta works, even if the array may be odd if buffer interface is used
ta = np.array(a if np.issubdtype(t, np.number) else a_str, dtype=t)
tresult = list(ta.T.copy())
for index_array in index_arrays:
if index_array.size != 0:
Reported by Pylint.
benchmarks/benchmarks/bench_scalar.py
27 issues
Line: 1
Column: 1
from .common import Benchmark, TYPES1
import numpy as np
class ScalarMath(Benchmark):
# Test scalar math, note that each of these is run repeatedly to offset
# the function call overhead to some degree.
params = [TYPES1]
Reported by Pylint.
Line: 12
Column: 9
params = [TYPES1]
param_names = ["type"]
def setup(self, typename):
self.num = np.dtype(typename).type(2)
def time_addition(self, typename):
n = self.num
res = n + n + n + n + n + n + n + n + n + n
Reported by Pylint.
Line: 14
Column: 29
def setup(self, typename):
self.num = np.dtype(typename).type(2)
def time_addition(self, typename):
n = self.num
res = n + n + n + n + n + n + n + n + n + n
def time_addition_pyint(self, typename):
n = self.num
Reported by Pylint.
Line: 16
Column: 9
def time_addition(self, typename):
n = self.num
res = n + n + n + n + n + n + n + n + n + n
def time_addition_pyint(self, typename):
n = self.num
res = n + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
Reported by Pylint.
Line: 18
Column: 35
n = self.num
res = n + n + n + n + n + n + n + n + n + n
def time_addition_pyint(self, typename):
n = self.num
res = n + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
def time_multiplication(self, typename):
n = self.num
Reported by Pylint.
Line: 20
Column: 9
def time_addition_pyint(self, typename):
n = self.num
res = n + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
def time_multiplication(self, typename):
n = self.num
res = n * n * n * n * n * n * n * n * n * n
Reported by Pylint.
Line: 22
Column: 35
n = self.num
res = n + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
def time_multiplication(self, typename):
n = self.num
res = n * n * n * n * n * n * n * n * n * n
def time_power_of_two(self, typename):
n = self.num
Reported by Pylint.
Line: 24
Column: 9
def time_multiplication(self, typename):
n = self.num
res = n * n * n * n * n * n * n * n * n * n
def time_power_of_two(self, typename):
n = self.num
res = n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2
Reported by Pylint.
Line: 26
Column: 33
n = self.num
res = n * n * n * n * n * n * n * n * n * n
def time_power_of_two(self, typename):
n = self.num
res = n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2
def time_abs(self, typename):
n = self.num
Reported by Pylint.
Line: 28
Column: 9
def time_power_of_two(self, typename):
n = self.num
res = n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2, n**2
def time_abs(self, typename):
n = self.num
res = abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(n))))))))))
Reported by Pylint.
numpy/distutils/tests/test_fcompiler_gnu.py
27 issues
Line: 36
Column: 13
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
for vs, version in g77_version_strings:
v = fc.version_match(vs)
assert_(v == version, (vs, v))
def test_not_g77(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
for vs, _ in gfortran_version_strings:
v = fc.version_match(vs)
Reported by Pylint.
Line: 42
Column: 13
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
for vs, _ in gfortran_version_strings:
v = fc.version_match(vs)
assert_(v is None, (vs, v))
class TestGFortranVersions:
def test_gfortran_version(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu95')
for vs, version in gfortran_version_strings:
Reported by Pylint.
Line: 49
Column: 13
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu95')
for vs, version in gfortran_version_strings:
v = fc.version_match(vs)
assert_(v == version, (vs, v))
def test_not_gfortran(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu95')
for vs, _ in g77_version_strings:
v = fc.version_match(vs)
Reported by Pylint.
Line: 55
Column: 13
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu95')
for vs, _ in g77_version_strings:
v = fc.version_match(vs)
assert_(v is None, (vs, v))
Reported by Pylint.
Line: 1
Column: 1
from numpy.testing import assert_
import numpy.distutils.fcompiler
g77_version_strings = [
('GNU Fortran 0.5.25 20010319 (prerelease)', '0.5.25'),
('GNU Fortran (GCC 3.2) 3.2 20020814 (release)', '3.2'),
('GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)', '3.3.3'),
('GNU Fortran (GCC) 3.3.3 (Debian 20040401)', '3.3.3'),
Reported by Pylint.
Line: 31
Column: 1
('GNU Fortran (crosstool-NG 8a21ab48) 7.2.0', '7.2.0')
]
class TestG77Versions:
def test_g77_version(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
for vs, version in g77_version_strings:
v = fc.version_match(vs)
assert_(v == version, (vs, v))
Reported by Pylint.
Line: 32
Column: 5
]
class TestG77Versions:
def test_g77_version(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
for vs, version in g77_version_strings:
v = fc.version_match(vs)
assert_(v == version, (vs, v))
Reported by Pylint.
Line: 32
Column: 5
]
class TestG77Versions:
def test_g77_version(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
for vs, version in g77_version_strings:
v = fc.version_match(vs)
assert_(v == version, (vs, v))
Reported by Pylint.
Line: 33
Column: 9
class TestG77Versions:
def test_g77_version(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
for vs, version in g77_version_strings:
v = fc.version_match(vs)
assert_(v == version, (vs, v))
def test_not_g77(self):
Reported by Pylint.
Line: 34
Column: 13
class TestG77Versions:
def test_g77_version(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
for vs, version in g77_version_strings:
v = fc.version_match(vs)
assert_(v == version, (vs, v))
def test_not_g77(self):
fc = numpy.distutils.fcompiler.new_fcompiler(compiler='gnu')
Reported by Pylint.
benchmarks/benchmarks/bench_array_coercion.py
27 issues
Line: 3
Column: 1
from __future__ import absolute_import, division, print_function
from .common import Benchmark
import numpy as np
class ArrayCoercionSmall(Benchmark):
# More detailed benchmarks for array coercion,
Reported by Pylint.
Line: 43
Column: 5
def time_asarray_dtype(self, array_like):
np.array(array_like, dtype=self.int64)
def time_asarray_dtype(self, array_like):
np.array(array_like, dtype=self.int64, order="F")
def time_asanyarray(self, array_like):
np.asarray(array_like)
Reported by Pylint.
Line: 52
Column: 5
def time_asanyarray_dtype(self, array_like):
np.array(array_like, dtype=self.int64)
def time_asanyarray_dtype(self, array_like):
np.array(array_like, dtype=self.int64, order="F")
def time_ascontiguousarray(self, array_like):
np.ascontiguousarray(array_like)
Reported by Pylint.
Line: 1
Column: 1
from __future__ import absolute_import, division, print_function
from .common import Benchmark
import numpy as np
class ArrayCoercionSmall(Benchmark):
# More detailed benchmarks for array coercion,
Reported by Pylint.
Line: 5
Column: 1
from .common import Benchmark
import numpy as np
class ArrayCoercionSmall(Benchmark):
# More detailed benchmarks for array coercion,
# some basic benchmarks are in `bench_core.py`.
Reported by Pylint.
Line: 8
Column: 1
import numpy as np
class ArrayCoercionSmall(Benchmark):
# More detailed benchmarks for array coercion,
# some basic benchmarks are in `bench_core.py`.
params = [[range(3), [1], 1, np.array([5], dtype=np.int64), np.int64(5)]]
param_names = ['array_like']
int64 = np.dtype(np.int64)
Reported by Pylint.
Line: 15
Column: 5
param_names = ['array_like']
int64 = np.dtype(np.int64)
def time_array_invalid_kwarg(self, array_like):
try:
np.array(array_like, ndmin="not-integer")
except TypeError:
pass
Reported by Pylint.
Line: 15
Column: 5
param_names = ['array_like']
int64 = np.dtype(np.int64)
def time_array_invalid_kwarg(self, array_like):
try:
np.array(array_like, ndmin="not-integer")
except TypeError:
pass
Reported by Pylint.
Line: 21
Column: 5
except TypeError:
pass
def time_array(self, array_like):
np.array(array_like)
def time_array_dtype_not_kwargs(self, array_like):
np.array(array_like, self.int64)
Reported by Pylint.
Line: 21
Column: 5
except TypeError:
pass
def time_array(self, array_like):
np.array(array_like)
def time_array_dtype_not_kwargs(self, array_like):
np.array(array_like, self.int64)
Reported by Pylint.
numpy/matrixlib/tests/test_regression.py
26 issues
Line: 29
Column: 25
def test_matrix_std_argmax(self):
# Ticket #83
x = np.asmatrix(np.random.uniform(0, 1, (3, 3)))
assert_equal(x.std().shape, ())
assert_equal(x.argmax().shape, ())
Reported by Pylint.
Line: 14
Column: 9
def test_matrix_properties(self):
# Ticket #125
a = np.matrix([1.0], dtype=float)
assert_(type(a.real) is np.matrix)
assert_(type(a.imag) is np.matrix)
c, d = np.matrix([0.0]).nonzero()
assert_(type(c) is np.ndarray)
assert_(type(d) is np.ndarray)
Reported by Pylint.
Line: 15
Column: 9
# Ticket #125
a = np.matrix([1.0], dtype=float)
assert_(type(a.real) is np.matrix)
assert_(type(a.imag) is np.matrix)
c, d = np.matrix([0.0]).nonzero()
assert_(type(c) is np.ndarray)
assert_(type(d) is np.ndarray)
def test_matrix_multiply_by_1d_vector(self):
Reported by Pylint.
Line: 16
Column: 9
a = np.matrix([1.0], dtype=float)
assert_(type(a.real) is np.matrix)
assert_(type(a.imag) is np.matrix)
c, d = np.matrix([0.0]).nonzero()
assert_(type(c) is np.ndarray)
assert_(type(d) is np.ndarray)
def test_matrix_multiply_by_1d_vector(self):
# Ticket #473
Reported by Pylint.
Line: 17
Column: 9
assert_(type(a.real) is np.matrix)
assert_(type(a.imag) is np.matrix)
c, d = np.matrix([0.0]).nonzero()
assert_(type(c) is np.ndarray)
assert_(type(d) is np.ndarray)
def test_matrix_multiply_by_1d_vector(self):
# Ticket #473
def mul():
Reported by Pylint.
Line: 18
Column: 9
assert_(type(a.imag) is np.matrix)
c, d = np.matrix([0.0]).nonzero()
assert_(type(c) is np.ndarray)
assert_(type(d) is np.ndarray)
def test_matrix_multiply_by_1d_vector(self):
# Ticket #473
def mul():
np.mat(np.eye(2))*np.ones(2)
Reported by Pylint.
Line: 23
Column: 13
def test_matrix_multiply_by_1d_vector(self):
# Ticket #473
def mul():
np.mat(np.eye(2))*np.ones(2)
assert_raises(ValueError, mul)
def test_matrix_std_argmax(self):
# Ticket #83
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
from numpy.testing import assert_, assert_equal, assert_raises
class TestRegression:
def test_kron_matrix(self):
# Ticket #71
x = np.matrix('[1 0; 1 0]')
assert_equal(type(np.kron(x, x)), type(x))
Reported by Pylint.
Line: 5
Column: 1
from numpy.testing import assert_, assert_equal, assert_raises
class TestRegression:
def test_kron_matrix(self):
# Ticket #71
x = np.matrix('[1 0; 1 0]')
assert_equal(type(np.kron(x, x)), type(x))
Reported by Pylint.
Line: 6
Column: 5
class TestRegression:
def test_kron_matrix(self):
# Ticket #71
x = np.matrix('[1 0; 1 0]')
assert_equal(type(np.kron(x, x)), type(x))
def test_matrix_properties(self):
Reported by Pylint.
numpy/linalg/tests/test_build.py
26 issues
Line: 4
Column: 1
from subprocess import PIPE, Popen
import sys
import re
import pytest
from numpy.linalg import lapack_lite
from numpy.testing import assert_
Reported by Pylint.
Line: 17
Column: 21
try:
p = Popen(self.cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
except OSError as e:
raise RuntimeError(f'command {self.cmd} cannot be run') from e
def get_dependencies(self, lfile):
p = Popen(self.cmd + [lfile], stdout=PIPE, stderr=PIPE)
Reported by Pylint.
Line: 17
Column: 13
try:
p = Popen(self.cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
except OSError as e:
raise RuntimeError(f'command {self.cmd} cannot be run') from e
def get_dependencies(self, lfile):
p = Popen(self.cmd + [lfile], stdout=PIPE, stderr=PIPE)
Reported by Pylint.
Line: 23
Column: 17
def get_dependencies(self, lfile):
p = Popen(self.cmd + [lfile], stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if not (p.returncode == 0):
raise RuntimeError(f'failed dependencies check for {lfile}')
return stdout
Reported by Pylint.
Line: 50
Column: 9
f = FindDependenciesLdd()
deps = f.grep_dependencies(lapack_lite.__file__,
[b'libg2c', b'libgfortran'])
assert_(len(deps) <= 1,
"""Both g77 and gfortran runtimes linked in lapack_lite ! This is likely to
cause random crashes and wrong results. See numpy INSTALL.txt for more
information.""")
Reported by Pylint.
Line: 1
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
from subprocess import PIPE, Popen
import sys
import re
import pytest
from numpy.linalg import lapack_lite
from numpy.testing import assert_
Reported by Bandit.
Line: 1
Column: 1
from subprocess import PIPE, Popen
import sys
import re
import pytest
from numpy.linalg import lapack_lite
from numpy.testing import assert_
Reported by Pylint.
Line: 10
Column: 1
from numpy.testing import assert_
class FindDependenciesLdd:
def __init__(self):
self.cmd = ['ldd']
try:
Reported by Pylint.
Line: 16
Column: 13
self.cmd = ['ldd']
try:
p = Popen(self.cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
except OSError as e:
raise RuntimeError(f'command {self.cmd} cannot be run') from e
def get_dependencies(self, lfile):
Reported by Pylint.
Line: 16
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
self.cmd = ['ldd']
try:
p = Popen(self.cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
except OSError as e:
raise RuntimeError(f'command {self.cmd} cannot be run') from e
def get_dependencies(self, lfile):
Reported by Bandit.