The following issues were found
numpy/core/src/multiarray/nditer_constr.c
13 issues
Line: 570
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
newiter = (NpyIter*)PyObject_Malloc(size);
/* Copy the raw values to the new iterator */
memcpy(newiter, iter, size);
/* Take ownership of references to the operands and dtypes */
objects = NIT_OPERANDS(newiter);
dtypes = NIT_DTYPES(newiter);
for (iop = 0; iop < nop; ++iop) {
Reported by FlawFinder.
Line: 809
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
npyiter_check_op_axes(int nop, int oa_ndim, int **op_axes,
const npy_intp *itershape)
{
char axes_dupcheck[NPY_MAXDIMS];
int iop, idim;
if (oa_ndim < 0) {
/*
* If `oa_ndim < 0`, `op_axes` and `itershape` are signalled to
Reported by FlawFinder.
Line: 1581
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
/* Need to fill the first axisdata, even if the iterator is 0-d */
NAD_SHAPE(axisdata) = 1;
NAD_INDEX(axisdata) = 0;
memcpy(NAD_PTRS(axisdata), op_dataptr, NPY_SIZEOF_INTP*nop);
memset(NAD_STRIDES(axisdata), 0, NPY_SIZEOF_INTP*nop);
}
/* Now process the operands, filling in the axisdata */
for (idim = 0; idim < ndim; ++idim) {
Reported by FlawFinder.
Line: 1592
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
NAD_SHAPE(axisdata) = bshape;
NAD_INDEX(axisdata) = 0;
memcpy(NAD_PTRS(axisdata), op_dataptr, NPY_SIZEOF_INTP*nop);
for (iop = 0; iop < nop; ++iop) {
op_cur = op[iop];
if (op_axes == NULL || op_axes[iop] == NULL) {
Reported by FlawFinder.
Line: 610
Column: 35
CWE codes:
120
20
}
}
if (transferinfo[iop].read.func != NULL) {
if (out_of_memory) {
transferinfo[iop].read.func = NULL; /* No cleanup */
}
else {
if (NPY_cast_info_copy(&transferinfo[iop].read,
Reported by FlawFinder.
Line: 612
Column: 39
CWE codes:
120
20
if (transferinfo[iop].read.func != NULL) {
if (out_of_memory) {
transferinfo[iop].read.func = NULL; /* No cleanup */
}
else {
if (NPY_cast_info_copy(&transferinfo[iop].read,
&transferinfo[iop].read) < 0) {
out_of_memory = 1;
Reported by FlawFinder.
Line: 615
Column: 63
CWE codes:
120
20
transferinfo[iop].read.func = NULL; /* No cleanup */
}
else {
if (NPY_cast_info_copy(&transferinfo[iop].read,
&transferinfo[iop].read) < 0) {
out_of_memory = 1;
}
}
}
Reported by FlawFinder.
Line: 707
Column: 48
CWE codes:
120
20
NpyIter_TransferInfo *transferinfo = NBF_TRANSFERINFO(bufferdata);
/* read bufferdata */
for (iop = 0; iop < nop; ++iop, ++transferinfo) {
NPY_cast_info_xfree(&transferinfo->read);
NPY_cast_info_xfree(&transferinfo->write);
}
}
/*
Reported by FlawFinder.
Line: 3170
Column: 60
CWE codes:
120
20
PyArray_DESCR(op[iop]),
op_dtype[iop],
move_references,
&transferinfo[iop].read,
&needs_api) != NPY_SUCCEED) {
iop -= 1; /* This one cannot be cleaned up yet. */
goto fail;
}
}
Reported by FlawFinder.
numpy/testing/print_coercion_tables.py
13 issues
Line: 87
Column: 5
"""Prints new casts, the values given are default "can-cast" values, not
actual ones.
"""
from numpy.core._multiarray_tests import get_all_cast_information
cast_table = {
0 : "#", # No cast (classify as equivalent here)
1 : "#", # equivalent casting
2 : "=", # safe casting
Reported by Pylint.
Line: 6
Column: 1
"""
import numpy as np
from collections import namedtuple
# Generic object that can be added, but doesn't do anything else
class GenericObject:
def __init__(self, v):
self.v = v
Reported by Pylint.
Line: 9
Column: 1
from collections import namedtuple
# Generic object that can be added, but doesn't do anything else
class GenericObject:
def __init__(self, v):
self.v = v
def __add__(self, other):
return self
Reported by Pylint.
Line: 11
Column: 9
# Generic object that can be added, but doesn't do anything else
class GenericObject:
def __init__(self, v):
self.v = v
def __add__(self, other):
return self
def __radd__(self, other):
Reported by Pylint.
Line: 21
Column: 1
dtype = np.dtype('O')
def print_cancast_table(ntypes):
print('X', end=' ')
for char in ntypes:
print(char, end=' ')
print()
for row in ntypes:
Reported by Pylint.
Line: 42
Column: 1
print(cast, end=' ')
print()
def print_coercion_table(ntypes, inputfirstvalue, inputsecondvalue, firstarray, use_promote_types=False):
print('+', end=' ')
for char in ntypes:
print(char, end=' ')
print()
for row in ntypes:
Reported by Pylint.
Line: 42
Column: 1
print(cast, end=' ')
print()
def print_coercion_table(ntypes, inputfirstvalue, inputsecondvalue, firstarray, use_promote_types=False):
print('+', end=' ')
for char in ntypes:
print(char, end=' ')
print()
for row in ntypes:
Reported by Pylint.
Line: 42
Column: 1
print(cast, end=' ')
print()
def print_coercion_table(ntypes, inputfirstvalue, inputsecondvalue, firstarray, use_promote_types=False):
print('+', end=' ')
for char in ntypes:
print(char, end=' ')
print()
for row in ntypes:
Reported by Pylint.
Line: 83
Column: 1
print()
def print_new_cast_table(*, can_cast=True, legacy=False, flags=False):
"""Prints new casts, the values given are default "can-cast" values, not
actual ones.
"""
from numpy.core._multiarray_tests import get_all_cast_information
Reported by Pylint.
Line: 83
Column: 1
print()
def print_new_cast_table(*, can_cast=True, legacy=False, flags=False):
"""Prints new casts, the values given are default "can-cast" values, not
actual ones.
"""
from numpy.core._multiarray_tests import get_all_cast_information
Reported by Pylint.
numpy/linalg/setup.py
12 issues
Line: 6
Column: 5
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import (
get_info, system_info, lapack_opt_info, blas_opt_info)
config = Configuration('linalg', parent_package, top_path)
config.add_subpackage('tests')
Reported by Pylint.
Line: 6
Column: 5
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import (
get_info, system_info, lapack_opt_info, blas_opt_info)
config = Configuration('linalg', parent_package, top_path)
config.add_subpackage('tests')
Reported by Pylint.
Line: 53
Column: 33
lapack_info = numpy_linalg_lapack_lite().get_info(2)
def get_lapack_lite_sources(ext, build_dir):
if use_lapack_lite:
print("### Warning: Using unoptimized lapack ###")
return all_sources
else:
if sys.platform == 'win32':
Reported by Pylint.
Line: 53
Column: 38
lapack_info = numpy_linalg_lapack_lite().get_info(2)
def get_lapack_lite_sources(ext, build_dir):
if use_lapack_lite:
print("### Warning: Using unoptimized lapack ###")
return all_sources
else:
if sys.platform == 'win32':
Reported by Pylint.
Line: 1
Column: 1
import os
import sys
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import (
get_info, system_info, lapack_opt_info, blas_opt_info)
config = Configuration('linalg', parent_package, top_path)
Reported by Pylint.
Line: 4
Column: 1
import os
import sys
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import (
get_info, system_info, lapack_opt_info, blas_opt_info)
config = Configuration('linalg', parent_package, top_path)
Reported by Pylint.
Line: 5
Column: 5
import sys
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import (
get_info, system_info, lapack_opt_info, blas_opt_info)
config = Configuration('linalg', parent_package, top_path)
config.add_subpackage('tests')
Reported by Pylint.
Line: 6
Column: 5
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import (
get_info, system_info, lapack_opt_info, blas_opt_info)
config = Configuration('linalg', parent_package, top_path)
config.add_subpackage('tests')
Reported by Pylint.
Line: 38
Column: 9
if use_lapack_lite:
# This makes numpy.distutils write the fact that lapack_lite
# is being used to numpy.__config__
class numpy_linalg_lapack_lite(system_info):
def calc_info(self):
info = {'language': 'c'}
if sys.maxsize > 2**32:
# Build lapack-lite in 64-bit integer mode.
# The suffix is arbitrary (lapack_lite symbols follow it),
Reported by Pylint.
Line: 38
Column: 9
if use_lapack_lite:
# This makes numpy.distutils write the fact that lapack_lite
# is being used to numpy.__config__
class numpy_linalg_lapack_lite(system_info):
def calc_info(self):
info = {'language': 'c'}
if sys.maxsize > 2**32:
# Build lapack-lite in 64-bit integer mode.
# The suffix is arbitrary (lapack_lite symbols follow it),
Reported by Pylint.
numpy/core/src/multiarray/ctors.c
12 issues
Line: 340
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
#define _COPY_N_SIZE(size) \
for(i=0; i<N; i++) { \
memcpy(tout, tin, size); \
tin += instrides; \
tout += outstrides; \
} \
return
Reported by FlawFinder.
Line: 437
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
npy_intp srcstrides, int swap)
{
if ((numitems == 1) || (itemsize == srcstrides)) {
memcpy(dst, src, itemsize*numitems);
}
else {
npy_intp i;
char *s1 = (char *)src;
char *d1 = (char *)dst;
Reported by FlawFinder.
Line: 445
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
char *d1 = (char *)dst;
for (i = 0; i < numitems; i++) {
memcpy(d1, s1, itemsize);
d1 += itemsize;
s1 += srcstrides;
}
}
Reported by FlawFinder.
Line: 681
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
PyObject *ret;
npy_intp newdims[2*NPY_MAXDIMS];
npy_intp *newstrides = NULL;
memcpy(newdims, dims, nd*sizeof(npy_intp));
if (strides) {
newstrides = newdims + NPY_MAXDIMS;
memcpy(newstrides, strides, nd*sizeof(npy_intp));
}
nd =_update_descr_and_dimensions(&descr, newdims,
Reported by FlawFinder.
Line: 684
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
memcpy(newdims, dims, nd*sizeof(npy_intp));
if (strides) {
newstrides = newdims + NPY_MAXDIMS;
memcpy(newstrides, strides, nd*sizeof(npy_intp));
}
nd =_update_descr_and_dimensions(&descr, newdims,
newstrides, nd);
ret = PyArray_NewFromDescr_int(
subtype, descr,
Reported by FlawFinder.
Line: 2403
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
}
if (n) {
memcpy(PyArray_STRIDES(ret), strides, n*sizeof(npy_intp));
}
}
PyArray_UpdateFlags(ret, NPY_ARRAY_UPDATE_ALL);
Py_DECREF(iface);
return (PyObject *)ret;
Reported by FlawFinder.
Line: 2692
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
dst_count = *dst_countptr;
src_count = *src_countptr;
char *args[2] = {src_dataptr[0], dst_dataptr[0]};
npy_intp strides[2] = {src_stride, dst_stride};
int res = 0;
for(;;) {
/* Transfer the biggest amount that fits both */
Reported by FlawFinder.
Line: 3724
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (ret == NULL) {
return NULL;
}
memcpy(PyArray_DATA(ret), data, size_to_copy);
}
else {
/* read from character-based string */
size_t nread = 0;
char *end;
Reported by FlawFinder.
Line: 123
Column: 24
CWE codes:
126
int skip_space = 0;
char *s, *start;
s = start = malloc(strlen(sep)+3);
if (s == NULL) {
PyErr_NoMemory();
return NULL;
}
/* add space to front if there isn't one */
Reported by FlawFinder.
numpy/typing/tests/data/fail/bitwise_ops.py
12 issues
Line: 5
Column: 6
i8 = np.int64()
i4 = np.int32()
u8 = np.uint64()
b_ = np.bool_()
i = int()
f8 = np.float64()
Reported by Pylint.
Line: 6
Column: 6
i8 = np.int64()
i4 = np.int32()
u8 = np.uint64()
b_ = np.bool_()
i = int()
f8 = np.float64()
b_ >> f8 # E: No overload variant
Reported by Pylint.
Line: 9
Column: 6
b_ = np.bool_()
i = int()
f8 = np.float64()
b_ >> f8 # E: No overload variant
i8 << f8 # E: No overload variant
i | f8 # E: Unsupported operand types
i8 ^ f8 # E: No overload variant
Reported by Pylint.
Line: 16
Column: 1
i | f8 # E: Unsupported operand types
i8 ^ f8 # E: No overload variant
u8 & f8 # E: No overload variant
~f8 # E: Unsupported operand type
# mypys' error message for `NoReturn` is unfortunately pretty bad
# TODO: Reenable this once we add support for numerical precision for `number`s
# a = u8 | 0 # E: Need type annotation
Reported by Pylint.
Line: 11
Column: 1
f8 = np.float64()
b_ >> f8 # E: No overload variant
i8 << f8 # E: No overload variant
i | f8 # E: Unsupported operand types
i8 ^ f8 # E: No overload variant
u8 & f8 # E: No overload variant
~f8 # E: Unsupported operand type
Reported by Pylint.
Line: 12
Column: 1
f8 = np.float64()
b_ >> f8 # E: No overload variant
i8 << f8 # E: No overload variant
i | f8 # E: Unsupported operand types
i8 ^ f8 # E: No overload variant
u8 & f8 # E: No overload variant
~f8 # E: Unsupported operand type
Reported by Pylint.
Line: 13
Column: 1
b_ >> f8 # E: No overload variant
i8 << f8 # E: No overload variant
i | f8 # E: Unsupported operand types
i8 ^ f8 # E: No overload variant
u8 & f8 # E: No overload variant
~f8 # E: Unsupported operand type
# mypys' error message for `NoReturn` is unfortunately pretty bad
Reported by Pylint.
Line: 14
Column: 1
b_ >> f8 # E: No overload variant
i8 << f8 # E: No overload variant
i | f8 # E: Unsupported operand types
i8 ^ f8 # E: No overload variant
u8 & f8 # E: No overload variant
~f8 # E: Unsupported operand type
# mypys' error message for `NoReturn` is unfortunately pretty bad
# TODO: Reenable this once we add support for numerical precision for `number`s
Reported by Pylint.
Line: 15
Column: 1
i8 << f8 # E: No overload variant
i | f8 # E: Unsupported operand types
i8 ^ f8 # E: No overload variant
u8 & f8 # E: No overload variant
~f8 # E: Unsupported operand type
# mypys' error message for `NoReturn` is unfortunately pretty bad
# TODO: Reenable this once we add support for numerical precision for `number`s
# a = u8 | 0 # E: Need type annotation
Reported by Pylint.
Line: 16
Column: 1
i | f8 # E: Unsupported operand types
i8 ^ f8 # E: No overload variant
u8 & f8 # E: No overload variant
~f8 # E: Unsupported operand type
# mypys' error message for `NoReturn` is unfortunately pretty bad
# TODO: Reenable this once we add support for numerical precision for `number`s
# a = u8 | 0 # E: Need type annotation
Reported by Pylint.
numpy/lib/tests/test_arrayterator.py
12 issues
Line: 11
Column: 5
def test():
np.random.seed(np.arange(10))
# Create a random array
ndims = randint(5)+1
shape = tuple(randint(10)+1 for dim in range(ndims))
els = reduce(mul, shape)
Reported by Pylint.
Line: 25
Column: 9
# Check that each block has at most ``buf_size`` elements
for block in b:
assert_(len(block.flat) <= (buf_size or els))
# Check that all elements are iterated correctly
assert_(list(b.flat) == list(a.flat))
# Slice arrayterator
Reported by Pylint.
Line: 28
Column: 5
assert_(len(block.flat) <= (buf_size or els))
# Check that all elements are iterated correctly
assert_(list(b.flat) == list(a.flat))
# Slice arrayterator
start = [randint(dim) for dim in shape]
stop = [randint(dim)+1 for dim in shape]
step = [randint(dim)+1 for dim in shape]
Reported by Pylint.
Line: 40
Column: 9
# Check that each block has at most ``buf_size`` elements
for block in c:
assert_(len(block.flat) <= (buf_size or els))
# Check that the arrayterator is sliced correctly
assert_(np.all(c.__array__() == d))
# Check that all elements are iterated correctly
Reported by Pylint.
Line: 43
Column: 5
assert_(len(block.flat) <= (buf_size or els))
# Check that the arrayterator is sliced correctly
assert_(np.all(c.__array__() == d))
# Check that all elements are iterated correctly
assert_(list(c.flat) == list(d.flat))
Reported by Pylint.
Line: 46
Column: 5
assert_(np.all(c.__array__() == d))
# Check that all elements are iterated correctly
assert_(list(c.flat) == list(d.flat))
Reported by Pylint.
Line: 1
Column: 1
from operator import mul
from functools import reduce
import numpy as np
from numpy.random import randint
from numpy.lib import Arrayterator
from numpy.testing import assert_
Reported by Pylint.
Line: 10
Column: 1
from numpy.testing import assert_
def test():
np.random.seed(np.arange(10))
# Create a random array
ndims = randint(5)+1
shape = tuple(randint(10)+1 for dim in range(ndims))
Reported by Pylint.
Line: 17
Column: 5
ndims = randint(5)+1
shape = tuple(randint(10)+1 for dim in range(ndims))
els = reduce(mul, shape)
a = np.arange(els)
a.shape = shape
buf_size = randint(2*els)
b = Arrayterator(a, buf_size)
Reported by Pylint.
Line: 21
Column: 5
a.shape = shape
buf_size = randint(2*els)
b = Arrayterator(a, buf_size)
# Check that each block has at most ``buf_size`` elements
for block in b:
assert_(len(block.flat) <= (buf_size or els))
Reported by Pylint.
numpy/f2py/tests/test_abstract_interface.py
12 issues
Line: 2
Column: 1
import textwrap
from . import util
from numpy.f2py import crackfortran
class TestAbstractInterface(util.F2PyTest):
suffix = '.f90'
skip = ['add1', 'add2']
Reported by Pylint.
Line: 1
Column: 1
import textwrap
from . import util
from numpy.f2py import crackfortran
class TestAbstractInterface(util.F2PyTest):
suffix = '.f90'
skip = ['add1', 'add2']
Reported by Pylint.
Line: 3
Column: 1
import textwrap
from . import util
from numpy.f2py import crackfortran
class TestAbstractInterface(util.F2PyTest):
suffix = '.f90'
skip = ['add1', 'add2']
Reported by Pylint.
Line: 6
Column: 1
from numpy.f2py import crackfortran
class TestAbstractInterface(util.F2PyTest):
suffix = '.f90'
skip = ['add1', 'add2']
code = textwrap.dedent("""
Reported by Pylint.
Line: 48
Column: 5
end subroutine
""")
def test_abstract_interface(self):
assert self.module.ops_module.foo(3, 5) == (8, 13)
def test_parse_abstract_interface(self, tmp_path):
# Test gh18403
f_path = tmp_path / "gh18403_mod.f90"
Reported by Pylint.
Line: 49
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
""")
def test_abstract_interface(self):
assert self.module.ops_module.foo(3, 5) == (8, 13)
def test_parse_abstract_interface(self, tmp_path):
# Test gh18403
f_path = tmp_path / "gh18403_mod.f90"
with f_path.open('w') as ff:
Reported by Bandit.
Line: 51
Column: 5
def test_abstract_interface(self):
assert self.module.ops_module.foo(3, 5) == (8, 13)
def test_parse_abstract_interface(self, tmp_path):
# Test gh18403
f_path = tmp_path / "gh18403_mod.f90"
with f_path.open('w') as ff:
ff.write(textwrap.dedent("""\
module test
Reported by Pylint.
Line: 51
Column: 5
def test_abstract_interface(self):
assert self.module.ops_module.foo(3, 5) == (8, 13)
def test_parse_abstract_interface(self, tmp_path):
# Test gh18403
f_path = tmp_path / "gh18403_mod.f90"
with f_path.open('w') as ff:
ff.write(textwrap.dedent("""\
module test
Reported by Pylint.
Line: 54
Column: 34
def test_parse_abstract_interface(self, tmp_path):
# Test gh18403
f_path = tmp_path / "gh18403_mod.f90"
with f_path.open('w') as ff:
ff.write(textwrap.dedent("""\
module test
abstract interface
subroutine foo()
end subroutine
Reported by Pylint.
Line: 64
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
end module test
"""))
mod = crackfortran.crackfortran([str(f_path)])
assert len(mod) == 1
assert len(mod[0]['body']) == 1
assert mod[0]['body'][0]['block'] == 'abstract interface'
Reported by Bandit.
numpy/distutils/command/autodist.py
12 issues
Line: 10
Column: 5
def check_inline(cmd):
"""Return the inline identifier (may be empty)."""
cmd._check_compiler()
body = textwrap.dedent("""
#ifndef __cplusplus
static %(inline)s int static_func (void)
{
return 0;
Reported by Pylint.
Line: 33
Column: 5
def check_restrict(cmd):
"""Return the restrict identifier (may be empty)."""
cmd._check_compiler()
body = textwrap.dedent("""
static int static_func (char * %(restrict)s a)
{
return 0;
}
Reported by Pylint.
Line: 52
Column: 5
def check_compiler_gcc(cmd):
"""Check if the compiler is GCC."""
cmd._check_compiler()
body = textwrap.dedent("""
int
main()
{
#if (! defined __GNUC__)
Reported by Pylint.
Line: 70
Column: 5
"""
Check that the gcc version is at least the specified version."""
cmd._check_compiler()
version = '.'.join([str(major), str(minor), str(patchlevel)])
body = textwrap.dedent("""
int
main()
{
Reported by Pylint.
Line: 92
Column: 5
def check_gcc_function_attribute(cmd, attribute, name):
"""Return True if the given function attribute is supported."""
cmd._check_compiler()
body = textwrap.dedent("""
#pragma GCC diagnostic error "-Wattributes"
#pragma clang diagnostic error "-Wattributes"
int %s %s(void* unused)
Reported by Pylint.
Line: 115
Column: 5
include):
"""Return True if the given function attribute is supported with
intrinsics."""
cmd._check_compiler()
body = textwrap.dedent("""
#include<%s>
int %s %s(void)
{
%s;
Reported by Pylint.
Line: 135
Column: 5
def check_gcc_variable_attribute(cmd, attribute):
"""Return True if the given variable attribute is supported."""
cmd._check_compiler()
body = textwrap.dedent("""
#pragma GCC diagnostic error "-Wattributes"
#pragma clang diagnostic error "-Wattributes"
int %s foo;
Reported by Pylint.
Line: 23
Column: 9
}
#endif""")
for kw in ['inline', '__inline__', '__inline']:
st = cmd.try_compile(body % {'inline': kw}, None, None)
if st:
return kw
return ''
Reported by Pylint.
Line: 24
Column: 9
#endif""")
for kw in ['inline', '__inline__', '__inline']:
st = cmd.try_compile(body % {'inline': kw}, None, None)
if st:
return kw
return ''
Reported by Pylint.
Line: 41
Column: 9
}
""")
for kw in ['restrict', '__restrict__', '__restrict']:
st = cmd.try_compile(body % {'restrict': kw}, None, None)
if st:
return kw
return ''
Reported by Pylint.
numpy/dual.py
12 issues
Line: 67
Column: 9
def register_func(name, func):
if name not in __all__:
raise ValueError("{} not a dual function.".format(name))
f = sys._getframe(0).f_globals
_restore_dict[name] = f[name]
f[name] = func
def restore_func(name):
if name not in __all__:
Reported by Pylint.
Line: 79
Column: 9
except KeyError:
return
else:
sys._getframe(0).f_globals[name] = val
def restore_all():
for name in _restore_dict.keys():
restore_func(name)
Reported by Pylint.
Line: 36
Column: 1
'norm', 'inv', 'svd', 'solve', 'det', 'eig', 'eigvals',
'eigh', 'eigvalsh', 'lstsq', 'pinv', 'cholesky', 'i0']
import numpy.linalg as linpkg
import numpy.fft as fftpkg
from numpy.lib import i0
import sys
Reported by Pylint.
Line: 37
Column: 1
'eigh', 'eigvalsh', 'lstsq', 'pinv', 'cholesky', 'i0']
import numpy.linalg as linpkg
import numpy.fft as fftpkg
from numpy.lib import i0
import sys
fft = fftpkg.fft
Reported by Pylint.
Line: 38
Column: 1
import numpy.linalg as linpkg
import numpy.fft as fftpkg
from numpy.lib import i0
import sys
fft = fftpkg.fft
ifft = fftpkg.ifft
Reported by Pylint.
Line: 39
Column: 1
import numpy.linalg as linpkg
import numpy.fft as fftpkg
from numpy.lib import i0
import sys
fft = fftpkg.fft
ifft = fftpkg.ifft
fftn = fftpkg.fftn
Reported by Pylint.
Line: 39
Column: 1
import numpy.linalg as linpkg
import numpy.fft as fftpkg
from numpy.lib import i0
import sys
fft = fftpkg.fft
ifft = fftpkg.ifft
fftn = fftpkg.fftn
Reported by Pylint.
Line: 64
Column: 1
_restore_dict = {}
def register_func(name, func):
if name not in __all__:
raise ValueError("{} not a dual function.".format(name))
f = sys._getframe(0).f_globals
_restore_dict[name] = f[name]
f[name] = func
Reported by Pylint.
Line: 67
Column: 5
def register_func(name, func):
if name not in __all__:
raise ValueError("{} not a dual function.".format(name))
f = sys._getframe(0).f_globals
_restore_dict[name] = f[name]
f[name] = func
def restore_func(name):
if name not in __all__:
Reported by Pylint.
Line: 71
Column: 1
_restore_dict[name] = f[name]
f[name] = func
def restore_func(name):
if name not in __all__:
raise ValueError("{} not a dual function.".format(name))
try:
val = _restore_dict[name]
except KeyError:
Reported by Pylint.
numpy/lib/user_array.py
12 issues
Line: 16
Column: 1
)
class container:
"""
container(data, dtype=None, copy=True)
Standard container-class for easy multiple-inheritance.
Reported by Pylint.
Line: 34
Column: 9
self.array = array(data, dtype, copy=copy)
def __repr__(self):
if self.ndim > 0:
return self.__class__.__name__ + repr(self.array)[len("array"):]
else:
return self.__class__.__name__ + "(" + repr(self.array) + ")"
def __array__(self, t=None):
Reported by Pylint.
Line: 39
Column: 5
else:
return self.__class__.__name__ + "(" + repr(self.array) + ")"
def __array__(self, t=None):
if t:
return self.array.astype(t)
return self.array
# Array as sequence
Reported by Pylint.
Line: 183
Column: 9
return self._rc(invert(self.array))
def _scalarfunc(self, func):
if self.ndim == 0:
return func(self[0])
else:
raise TypeError(
"only rank-0 arrays can be converted to Python scalars.")
Reported by Pylint.
Line: 222
Column: 5
def __ge__(self, other):
return self._rc(greater_equal(self.array, other))
def copy(self):
""
return self._rc(self.array.copy())
def tostring(self):
""
Reported by Pylint.
Line: 226
Column: 5
""
return self._rc(self.array.copy())
def tostring(self):
""
return self.array.tostring()
def tobytes(self):
""
Reported by Pylint.
Line: 230
Column: 5
""
return self.array.tostring()
def tobytes(self):
""
return self.array.tobytes()
def byteswap(self):
""
Reported by Pylint.
Line: 234
Column: 5
""
return self.array.tobytes()
def byteswap(self):
""
return self._rc(self.array.byteswap())
def astype(self, typecode):
""
Reported by Pylint.
Line: 238
Column: 5
""
return self._rc(self.array.byteswap())
def astype(self, typecode):
""
return self._rc(self.array.astype(typecode))
def _rc(self, a):
if len(shape(a)) == 0:
Reported by Pylint.
Line: 242
Column: 5
""
return self._rc(self.array.astype(typecode))
def _rc(self, a):
if len(shape(a)) == 0:
return a
else:
return self.__class__(a)
Reported by Pylint.