The following issues were found
tools/swig/test/testFortran.py
34 issues
Line: 12
Column: 1
if major == 0: BadListError = TypeError
else: BadListError = ValueError
import Fortran
######################################################################
class FortranTestCase(unittest.TestCase):
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python3
# System imports
import sys
import unittest
# Import NumPy
import numpy as np
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
if major == 0: BadListError = TypeError
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python3
# System imports
import sys
import unittest
# Import NumPy
import numpy as np
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
if major == 0: BadListError = TypeError
Reported by Pylint.
Line: 9
Column: 16
# Import NumPy
import numpy as np
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
if major == 0: BadListError = TypeError
else: BadListError = ValueError
import Fortran
######################################################################
Reported by Pylint.
Line: 12
Column: 1
if major == 0: BadListError = TypeError
else: BadListError = ValueError
import Fortran
######################################################################
class FortranTestCase(unittest.TestCase):
Reported by Pylint.
Line: 16
Column: 1
######################################################################
class FortranTestCase(unittest.TestCase):
def __init__(self, methodName="runTests"):
unittest.TestCase.__init__(self, methodName)
self.typeStr = "double"
self.typeCode = "d"
Reported by Pylint.
Line: 20
Column: 9
def __init__(self, methodName="runTests"):
unittest.TestCase.__init__(self, methodName)
self.typeStr = "double"
self.typeCode = "d"
# Test (type* IN_FARRAY2, int DIM1, int DIM2) typemap
def testSecondElementFortran(self):
"Test Fortran matrix initialized from reshaped NumPy fortranarray"
Reported by Pylint.
Line: 21
Column: 9
def __init__(self, methodName="runTests"):
unittest.TestCase.__init__(self, methodName)
self.typeStr = "double"
self.typeCode = "d"
# Test (type* IN_FARRAY2, int DIM1, int DIM2) typemap
def testSecondElementFortran(self):
"Test Fortran matrix initialized from reshaped NumPy fortranarray"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
Reported by Pylint.
Line: 24
Column: 5
self.typeCode = "d"
# Test (type* IN_FARRAY2, int DIM1, int DIM2) typemap
def testSecondElementFortran(self):
"Test Fortran matrix initialized from reshaped NumPy fortranarray"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
second = Fortran.__dict__[self.typeStr + "SecondElement"]
matrix = np.asfortranarray(np.arange(9).reshape(3, 3),
self.typeCode)
Reported by Pylint.
Line: 32
Column: 5
self.typeCode)
self.assertEqual(second(matrix), 3)
def testSecondElementObject(self):
"Test Fortran matrix initialized from nested list fortranarray"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
second = Fortran.__dict__[self.typeStr + "SecondElement"]
matrix = np.asfortranarray([[0, 1, 2], [3, 4, 5], [6, 7, 8]], self.typeCode)
self.assertEqual(second(matrix), 3)
Reported by Pylint.
numpy/f2py/src/fortranobject.c
34 issues
Line: 655
Column: 9
CWE codes:
134
Suggestion:
Use a constant for the format specification
int i;
printf("[");
for(i=0;i<rank;++i) {
printf("%3" NPY_INTP_FMT, dims[i]);
}
printf("]\n");
}
void dump_attrs(const PyArrayObject* obj) {
const PyArrayObject_fields *arr = (const PyArrayObject_fields*) obj;
Reported by FlawFinder.
Line: 776
Column: 17
CWE codes:
134
Suggestion:
Make format string constant
if (!PyArray_ISONESEGMENT(arr))
strcat(mess, " -- input must be in one segment");
if (PyArray_ITEMSIZE(arr)<elsize)
sprintf(mess+strlen(mess),
" -- expected at least elsize=%d but got %" NPY_INTP_FMT,
elsize,
(npy_intp)PyArray_ITEMSIZE(arr)
);
PyErr_SetString(PyExc_ValueError,mess);
Reported by FlawFinder.
Line: 818
Column: 17
CWE codes:
134
Suggestion:
Make format string constant
if (!(intent & F2PY_INTENT_C) && !PyArray_ISFARRAY(arr))
strcat(mess, " -- input not fortran contiguous");
if (PyArray_ITEMSIZE(arr)!=elsize)
sprintf(mess+strlen(mess),
" -- expected elsize=%d but got %" NPY_INTP_FMT,
elsize,
(npy_intp)PyArray_ITEMSIZE(arr)
);
if (!(ARRAY_ISCOMPATIBLE(arr,type_num)))
Reported by FlawFinder.
Line: 1040
Column: 17
CWE codes:
134
Suggestion:
Use a constant for the format specification
size, arr_size, rank, effrank, PyArray_NDIM(arr));
for (i = 0; i < rank; ++i) {
len = strlen(msg);
snprintf(msg + len, sizeof(msg) - len,
" %" NPY_INTP_FMT, dims[i]);
}
len = strlen(msg);
snprintf(msg + len, sizeof(msg) - len, " ], arr.dims=[");
for (i = 0; i < PyArray_NDIM(arr); ++i) {
Reported by FlawFinder.
Line: 1047
Column: 17
CWE codes:
134
Suggestion:
Use a constant for the format specification
snprintf(msg + len, sizeof(msg) - len, " ], arr.dims=[");
for (i = 0; i < PyArray_NDIM(arr); ++i) {
len = strlen(msg);
snprintf(msg + len, sizeof(msg) - len,
" %" NPY_INTP_FMT, PyArray_DIM(arr, i));
}
len = strlen(msg);
snprintf(msg + len, sizeof(msg) - len, " ]\n");
PyErr_SetString(PyExc_ValueError, msg);
Reported by FlawFinder.
Line: 215
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if ((size_t) size < sizeof(notalloc)) {
return -1;
}
memcpy(p, notalloc, sizeof(notalloc));
p += sizeof(notalloc);
size -= sizeof(notalloc);
}
return p - buf;
Reported by FlawFinder.
Line: 245
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (n > size) {
goto fail;
}
memcpy(p, def.doc, n);
p += n;
size -= n;
}
else {
n = PyOS_snprintf(p, size, "%s - no docs available", def.name);
Reported by FlawFinder.
Line: 289
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (size < n) {
goto fail;
}
memcpy(p, "scalar", n);
p += n;
size -= n;
}
}
Reported by FlawFinder.
Line: 416
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
(*(fp->defs[i].func))(&fp->defs[i].rank,dims,set_data,&flag);
for(k=0;k<fp->defs[i].rank;k++) dims[k]=-1;
}
memcpy(fp->defs[i].dims.d,dims,fp->defs[i].rank*sizeof(npy_intp));
} else { /* not allocatable array */
if ((arr = array_from_pyobj(fp->defs[i].type,fp->defs[i].dims.d,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)
return -1;
}
if (fp->defs[i].data!=NULL) { /* copy Python object to Fortran array */
Reported by FlawFinder.
Line: 426
Column: 18
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (s==-1)
s = PyArray_MultiplyList(PyArray_DIMS(arr),PyArray_NDIM(arr));
if (s<0 ||
(memcpy(fp->defs[i].data,PyArray_DATA(arr),s*PyArray_ITEMSIZE(arr)))==NULL) {
if ((PyObject*)arr!=v) {
Py_DECREF(arr);
}
return -1;
}
Reported by FlawFinder.
numpy/compat/py3k.py
34 issues
Line: 131
Column: 12
# Explicitly lazy import this to avoid paying the cost
# of importing importlib at startup
from importlib.machinery import SourceFileLoader
return SourceFileLoader(name, fn).load_module()
os_fspath = os.fspath
os_PathLike = os.PathLike
Reported by Pylint.
Line: 32
Column: 1
integer_types = (int,)
basestring = str
unicode = str
bytes = bytes
def asunicode(s):
if isinstance(s, bytes):
return s.decode('latin1')
return str(s)
Reported by Pylint.
Line: 32
Column: 1
integer_types = (int,)
basestring = str
unicode = str
bytes = bytes
def asunicode(s):
if isinstance(s, bytes):
return s.decode('latin1')
return str(s)
Reported by Pylint.
Line: 108
Column: 31
pass
def npy_load_module(name, fn, info=None):
"""
Load a module.
.. versionadded:: 1.11.2
Reported by Pylint.
Line: 131
Column: 12
# Explicitly lazy import this to avoid paying the cost
# of importing importlib at startup
from importlib.machinery import SourceFileLoader
return SourceFileLoader(name, fn).load_module()
os_fspath = os.fspath
os_PathLike = os.PathLike
Reported by Pylint.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b403-import-pickle
from pathlib import Path
import io
try:
import pickle5 as pickle
except ImportError:
import pickle
long = int
integer_types = (int,)
Reported by Bandit.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b403-import-pickle
try:
import pickle5 as pickle
except ImportError:
import pickle
long = int
integer_types = (int,)
basestring = str
unicode = str
Reported by Bandit.
Line: 28
Column: 1
except ImportError:
import pickle
long = int
integer_types = (int,)
basestring = str
unicode = str
bytes = bytes
Reported by Pylint.
Line: 30
Column: 1
long = int
integer_types = (int,)
basestring = str
unicode = str
bytes = bytes
def asunicode(s):
if isinstance(s, bytes):
Reported by Pylint.
Line: 31
Column: 1
long = int
integer_types = (int,)
basestring = str
unicode = str
bytes = bytes
def asunicode(s):
if isinstance(s, bytes):
return s.decode('latin1')
Reported by Pylint.
numpy/f2py/tests/test_return_complex.py
34 issues
Line: 1
Column: 1
import pytest
from numpy import array
from numpy.testing import assert_, assert_raises
from . import util
class TestReturnComplex(util.F2PyTest):
Reported by Pylint.
Line: 5
Column: 1
from numpy import array
from numpy.testing import assert_, assert_raises
from . import util
class TestReturnComplex(util.F2PyTest):
def check_function(self, t, tname):
Reported by Pylint.
Line: 15
Column: 9
err = 1e-5
else:
err = 0.0
assert_(abs(t(234j) - 234.0j) <= err)
assert_(abs(t(234.6) - 234.6) <= err)
assert_(abs(t(234) - 234.0) <= err)
assert_(abs(t(234.6 + 3j) - (234.6 + 3j)) <= err)
#assert_( abs(t('234')-234.)<=err)
#assert_( abs(t('234.6')-234.6)<=err)
Reported by Pylint.
Line: 16
Column: 9
else:
err = 0.0
assert_(abs(t(234j) - 234.0j) <= err)
assert_(abs(t(234.6) - 234.6) <= err)
assert_(abs(t(234) - 234.0) <= err)
assert_(abs(t(234.6 + 3j) - (234.6 + 3j)) <= err)
#assert_( abs(t('234')-234.)<=err)
#assert_( abs(t('234.6')-234.6)<=err)
assert_(abs(t(-234) + 234.) <= err)
Reported by Pylint.
Line: 17
Column: 9
err = 0.0
assert_(abs(t(234j) - 234.0j) <= err)
assert_(abs(t(234.6) - 234.6) <= err)
assert_(abs(t(234) - 234.0) <= err)
assert_(abs(t(234.6 + 3j) - (234.6 + 3j)) <= err)
#assert_( abs(t('234')-234.)<=err)
#assert_( abs(t('234.6')-234.6)<=err)
assert_(abs(t(-234) + 234.) <= err)
assert_(abs(t([234]) - 234.) <= err)
Reported by Pylint.
Line: 18
Column: 9
assert_(abs(t(234j) - 234.0j) <= err)
assert_(abs(t(234.6) - 234.6) <= err)
assert_(abs(t(234) - 234.0) <= err)
assert_(abs(t(234.6 + 3j) - (234.6 + 3j)) <= err)
#assert_( abs(t('234')-234.)<=err)
#assert_( abs(t('234.6')-234.6)<=err)
assert_(abs(t(-234) + 234.) <= err)
assert_(abs(t([234]) - 234.) <= err)
assert_(abs(t((234,)) - 234.) <= err)
Reported by Pylint.
Line: 21
Column: 9
assert_(abs(t(234.6 + 3j) - (234.6 + 3j)) <= err)
#assert_( abs(t('234')-234.)<=err)
#assert_( abs(t('234.6')-234.6)<=err)
assert_(abs(t(-234) + 234.) <= err)
assert_(abs(t([234]) - 234.) <= err)
assert_(abs(t((234,)) - 234.) <= err)
assert_(abs(t(array(234)) - 234.) <= err)
assert_(abs(t(array(23 + 4j, 'F')) - (23 + 4j)) <= err)
assert_(abs(t(array([234])) - 234.) <= err)
Reported by Pylint.
Line: 22
Column: 9
#assert_( abs(t('234')-234.)<=err)
#assert_( abs(t('234.6')-234.6)<=err)
assert_(abs(t(-234) + 234.) <= err)
assert_(abs(t([234]) - 234.) <= err)
assert_(abs(t((234,)) - 234.) <= err)
assert_(abs(t(array(234)) - 234.) <= err)
assert_(abs(t(array(23 + 4j, 'F')) - (23 + 4j)) <= err)
assert_(abs(t(array([234])) - 234.) <= err)
assert_(abs(t(array([[234]])) - 234.) <= err)
Reported by Pylint.
Line: 23
Column: 9
#assert_( abs(t('234.6')-234.6)<=err)
assert_(abs(t(-234) + 234.) <= err)
assert_(abs(t([234]) - 234.) <= err)
assert_(abs(t((234,)) - 234.) <= err)
assert_(abs(t(array(234)) - 234.) <= err)
assert_(abs(t(array(23 + 4j, 'F')) - (23 + 4j)) <= err)
assert_(abs(t(array([234])) - 234.) <= err)
assert_(abs(t(array([[234]])) - 234.) <= err)
assert_(abs(t(array([234], 'b')) + 22.) <= err)
Reported by Pylint.
Line: 24
Column: 9
assert_(abs(t(-234) + 234.) <= err)
assert_(abs(t([234]) - 234.) <= err)
assert_(abs(t((234,)) - 234.) <= err)
assert_(abs(t(array(234)) - 234.) <= err)
assert_(abs(t(array(23 + 4j, 'F')) - (23 + 4j)) <= err)
assert_(abs(t(array([234])) - 234.) <= err)
assert_(abs(t(array([[234]])) - 234.) <= err)
assert_(abs(t(array([234], 'b')) + 22.) <= err)
assert_(abs(t(array([234], 'h')) - 234.) <= err)
Reported by Pylint.
numpy/core/numerictypes.py
34 issues
Line: 102
Column: 1
# we don't need all these imports, but we need to keep them for compatibility
# for users using np.core.numerictypes.UPPER_TABLE
from ._string_helpers import (
english_lower, english_upper, english_capitalize, LOWER_TABLE, UPPER_TABLE
)
from ._type_aliases import (
sctypeDict,
Reported by Pylint.
Line: 106
Column: 1
english_lower, english_upper, english_capitalize, LOWER_TABLE, UPPER_TABLE
)
from ._type_aliases import (
sctypeDict,
allTypes,
bitname,
sctypes,
_concrete_types,
Reported by Pylint.
Line: 115
Column: 1
_concrete_typeinfo,
_bits_of,
)
from ._dtype import _kind_name
# we don't export these for import *, but we do want them accessible
# as numerictypes.bool, etc.
from builtins import bool, int, float, complex, object, str, bytes
from numpy.compat import long, unicode
Reported by Pylint.
Line: 223
Column: 27
return False
try:
res = obj2sctype(rep)
if res and res != object_:
return True
return False
except Exception:
return False
Reported by Pylint.
Line: 591
Column: 31
return None
def _register_types():
numbers.Integral.register(integer)
numbers.Complex.register(inexact)
numbers.Real.register(floating)
numbers.Number.register(number)
_register_types()
Reported by Pylint.
Line: 592
Column: 30
def _register_types():
numbers.Integral.register(integer)
numbers.Complex.register(inexact)
numbers.Real.register(floating)
numbers.Number.register(number)
_register_types()
Reported by Pylint.
Line: 593
Column: 27
def _register_types():
numbers.Integral.register(integer)
numbers.Complex.register(inexact)
numbers.Real.register(floating)
numbers.Number.register(number)
_register_types()
Reported by Pylint.
Line: 594
Column: 29
numbers.Integral.register(integer)
numbers.Complex.register(inexact)
numbers.Real.register(floating)
numbers.Number.register(number)
_register_types()
@set_module('numpy')
Reported by Pylint.
Line: 83
Column: 1
"""
import numbers
import warnings
from numpy.core.multiarray import (
typeinfo, ndarray, array, empty, dtype, datetime_data,
datetime_as_string, busday_offset, busday_count, is_busday,
busdaycalendar
Reported by Pylint.
Line: 85
Column: 1
import numbers
import warnings
from numpy.core.multiarray import (
typeinfo, ndarray, array, empty, dtype, datetime_data,
datetime_as_string, busday_offset, busday_count, is_busday,
busdaycalendar
)
from numpy.core.overrides import set_module
Reported by Pylint.
numpy/distutils/fcompiler/intel.py
33 issues
Line: 12
Column: 25
'IntelEM64VisualFCompiler', 'IntelEM64TFCompiler']
def intel_version_match(type):
# Match against the important stuff in the version string
return simple_version_match(start=r'Intel.*?Fortran.*?(?:%s).*?Version' % (type,))
class BaseIntelFCompiler(FCompiler):
Reported by Pylint.
Line: 17
Column: 1
return simple_version_match(start=r'Intel.*?Fortran.*?(?:%s).*?Version' % (type,))
class BaseIntelFCompiler(FCompiler):
def update_executables(self):
f = dummy_fortran_file()
self.executables['version_cmd'] = ['<F77>', '-FI', '-V', '-c',
f + '.f', '-o', f + '.o']
Reported by Pylint.
Line: 17
Column: 1
return simple_version_match(start=r'Intel.*?Fortran.*?(?:%s).*?Version' % (type,))
class BaseIntelFCompiler(FCompiler):
def update_executables(self):
f = dummy_fortran_file()
self.executables['version_cmd'] = ['<F77>', '-FI', '-V', '-c',
f + '.f', '-o', f + '.o']
Reported by Pylint.
Line: 23
Column: 42
self.executables['version_cmd'] = ['<F77>', '-FI', '-V', '-c',
f + '.f', '-o', f + '.o']
def runtime_library_dir_option(self, dir):
# TODO: could use -Xlinker here, if it's supported
assert "," not in dir
return '-Wl,-rpath=%s' % dir
Reported by Pylint.
Line: 24
Column: 3
f + '.f', '-o', f + '.o']
def runtime_library_dir_option(self, dir):
# TODO: could use -Xlinker here, if it's supported
assert "," not in dir
return '-Wl,-rpath=%s' % dir
Reported by Pylint.
Line: 30
Column: 1
return '-Wl,-rpath=%s' % dir
class IntelFCompiler(BaseIntelFCompiler):
compiler_type = 'intel'
compiler_aliases = ('ifort',)
description = 'Intel Fortran Compiler for 32-bit apps'
version_match = intel_version_match('32-bit|IA-32')
Reported by Pylint.
Line: 30
Column: 1
return '-Wl,-rpath=%s' % dir
class IntelFCompiler(BaseIntelFCompiler):
compiler_type = 'intel'
compiler_aliases = ('ifort',)
description = 'Intel Fortran Compiler for 32-bit apps'
version_match = intel_version_match('32-bit|IA-32')
Reported by Pylint.
Line: 84
Column: 1
return opt
class IntelItaniumFCompiler(IntelFCompiler):
compiler_type = 'intele'
compiler_aliases = ()
description = 'Intel Fortran Compiler for Itanium apps'
version_match = intel_version_match('Itanium|IA-64')
Reported by Pylint.
Line: 84
Column: 1
return opt
class IntelItaniumFCompiler(IntelFCompiler):
compiler_type = 'intele'
compiler_aliases = ()
description = 'Intel Fortran Compiler for Itanium apps'
version_match = intel_version_match('Itanium|IA-64')
Reported by Pylint.
Line: 104
Column: 1
}
class IntelEM64TFCompiler(IntelFCompiler):
compiler_type = 'intelem'
compiler_aliases = ()
description = 'Intel Fortran Compiler for 64-bit apps'
version_match = intel_version_match('EM64T-based|Intel\\(R\\) 64|64|IA-64|64-bit')
Reported by Pylint.
doc/source/reference/simd/simd-optimizations.py
33 issues
Line: 4
Column: 1
"""
Generate CPU features tables from CCompilerOpt
"""
from os import sys, path
gen_path = path.dirname(path.realpath(__file__))
#sys.path.append(path.abspath(path.join(gen_path, *([".."]*4), "numpy", "distutils")))
#from ccompiler_opt import CCompilerOpt
from numpy.distutils.ccompiler_opt import CCompilerOpt
Reported by Pylint.
Line: 14
Column: 1
fake_info = ("arch", "compiler", "extra_args")
# disable caching no need for it
conf_nocache = True
def __init__(self, *args, **kwargs):
no_cc = None
CCompilerOpt.__init__(self, no_cc, **kwargs)
def dist_compile(self, sources, flags, **kwargs):
return sources
def dist_info(self):
Reported by Pylint.
Line: 29
Column: 5
# To speed up
return True
def gen_features_table(self, features, ignore_groups=True,
field_names=["Name", "Implies"],
fstyle=None, fstyle_implies=None, **kwargs):
rows = []
if fstyle is None:
fstyle = lambda ft: f'``{ft}``'
Reported by Pylint.
Line: 47
Column: 5
if rows:
return self.gen_rst_table(field_names, rows, **kwargs)
def gen_gfeatures_table(self, features,
field_names=["Name", "Gather", "Implies"],
fstyle=None, fstyle_implies=None, **kwargs):
rows = []
if fstyle is None:
fstyle = lambda ft: f'``{ft}``'
Reported by Pylint.
Line: 103
Column: 36
)
return content
def features_table(arch, cc="gcc", pretty_name=None, **kwargs):
FakeCCompilerOpt.fake_info = (arch, cc, '')
ccopt = FakeCCompilerOpt(cpu_baseline="max")
features = ccopt.cpu_baseline_names()
ftable = ccopt.gen_features_table(features, **kwargs)
gtable = ccopt.gen_gfeatures_table(features, **kwargs)
Reported by Pylint.
Line: 103
Column: 26
)
return content
def features_table(arch, cc="gcc", pretty_name=None, **kwargs):
FakeCCompilerOpt.fake_info = (arch, cc, '')
ccopt = FakeCCompilerOpt(cpu_baseline="max")
features = ccopt.cpu_baseline_names()
ftable = ccopt.gen_features_table(features, **kwargs)
gtable = ccopt.gen_gfeatures_table(features, **kwargs)
Reported by Pylint.
Line: 103
Column: 20
)
return content
def features_table(arch, cc="gcc", pretty_name=None, **kwargs):
FakeCCompilerOpt.fake_info = (arch, cc, '')
ccopt = FakeCCompilerOpt(cpu_baseline="max")
features = ccopt.cpu_baseline_names()
ftable = ccopt.gen_features_table(features, **kwargs)
gtable = ccopt.gen_gfeatures_table(features, **kwargs)
Reported by Pylint.
Line: 114
Column: 48
pretty_name = arch + '/' + cc
return features_table_sections(pretty_name, ftable, gtable, **kwargs)
def features_table_diff(arch, cc, cc_vs="gcc", pretty_name=None, **kwargs):
FakeCCompilerOpt.fake_info = (arch, cc, '')
ccopt = FakeCCompilerOpt(cpu_baseline="max")
fnames = ccopt.cpu_baseline_names()
features = {f:ccopt.feature_implies(f) for f in fnames}
Reported by Pylint.
Line: 114
Column: 25
pretty_name = arch + '/' + cc
return features_table_sections(pretty_name, ftable, gtable, **kwargs)
def features_table_diff(arch, cc, cc_vs="gcc", pretty_name=None, **kwargs):
FakeCCompilerOpt.fake_info = (arch, cc, '')
ccopt = FakeCCompilerOpt(cpu_baseline="max")
fnames = ccopt.cpu_baseline_names()
features = {f:ccopt.feature_implies(f) for f in fnames}
Reported by Pylint.
Line: 114
Column: 31
pretty_name = arch + '/' + cc
return features_table_sections(pretty_name, ftable, gtable, **kwargs)
def features_table_diff(arch, cc, cc_vs="gcc", pretty_name=None, **kwargs):
FakeCCompilerOpt.fake_info = (arch, cc, '')
ccopt = FakeCCompilerOpt(cpu_baseline="max")
fnames = ccopt.cpu_baseline_names()
features = {f:ccopt.feature_implies(f) for f in fnames}
Reported by Pylint.
numpy/typing/tests/data/reveal/numerictypes.py
32 issues
Line: 3
Column: 1
import numpy as np
reveal_type(np.maximum_sctype(np.float64)) # E: Type[{float64}]
reveal_type(np.maximum_sctype("f8")) # E: Type[Any]
reveal_type(np.issctype(np.float64)) # E: bool
reveal_type(np.issctype("foo")) # E: Literal[False]
reveal_type(np.obj2sctype(np.float64)) # E: Union[None, Type[{float64}]]
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
reveal_type(np.maximum_sctype(np.float64)) # E: Type[{float64}]
reveal_type(np.maximum_sctype("f8")) # E: Type[Any]
reveal_type(np.issctype(np.float64)) # E: bool
reveal_type(np.issctype("foo")) # E: Literal[False]
reveal_type(np.obj2sctype(np.float64)) # E: Union[None, Type[{float64}]]
Reported by Pylint.
Line: 6
Column: 1
reveal_type(np.maximum_sctype(np.float64)) # E: Type[{float64}]
reveal_type(np.maximum_sctype("f8")) # E: Type[Any]
reveal_type(np.issctype(np.float64)) # E: bool
reveal_type(np.issctype("foo")) # E: Literal[False]
reveal_type(np.obj2sctype(np.float64)) # E: Union[None, Type[{float64}]]
reveal_type(np.obj2sctype(np.float64, default=False)) # E: Union[builtins.bool, Type[{float64}]]
reveal_type(np.obj2sctype("S8")) # E: Union[None, Type[Any]]
Reported by Pylint.
Line: 7
Column: 1
reveal_type(np.maximum_sctype("f8")) # E: Type[Any]
reveal_type(np.issctype(np.float64)) # E: bool
reveal_type(np.issctype("foo")) # E: Literal[False]
reveal_type(np.obj2sctype(np.float64)) # E: Union[None, Type[{float64}]]
reveal_type(np.obj2sctype(np.float64, default=False)) # E: Union[builtins.bool, Type[{float64}]]
reveal_type(np.obj2sctype("S8")) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("S8", default=None)) # E: Union[None, Type[Any]]
Reported by Pylint.
Line: 9
Column: 1
reveal_type(np.issctype(np.float64)) # E: bool
reveal_type(np.issctype("foo")) # E: Literal[False]
reveal_type(np.obj2sctype(np.float64)) # E: Union[None, Type[{float64}]]
reveal_type(np.obj2sctype(np.float64, default=False)) # E: Union[builtins.bool, Type[{float64}]]
reveal_type(np.obj2sctype("S8")) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("S8", default=None)) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("foo", default=False)) # E: Union[builtins.bool, Type[Any]]
reveal_type(np.obj2sctype(1)) # E: None
Reported by Pylint.
Line: 10
Column: 1
reveal_type(np.issctype("foo")) # E: Literal[False]
reveal_type(np.obj2sctype(np.float64)) # E: Union[None, Type[{float64}]]
reveal_type(np.obj2sctype(np.float64, default=False)) # E: Union[builtins.bool, Type[{float64}]]
reveal_type(np.obj2sctype("S8")) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("S8", default=None)) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("foo", default=False)) # E: Union[builtins.bool, Type[Any]]
reveal_type(np.obj2sctype(1)) # E: None
reveal_type(np.obj2sctype(1, default=False)) # E: bool
Reported by Pylint.
Line: 11
Column: 1
reveal_type(np.obj2sctype(np.float64)) # E: Union[None, Type[{float64}]]
reveal_type(np.obj2sctype(np.float64, default=False)) # E: Union[builtins.bool, Type[{float64}]]
reveal_type(np.obj2sctype("S8")) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("S8", default=None)) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("foo", default=False)) # E: Union[builtins.bool, Type[Any]]
reveal_type(np.obj2sctype(1)) # E: None
reveal_type(np.obj2sctype(1, default=False)) # E: bool
Reported by Pylint.
Line: 12
Column: 1
reveal_type(np.obj2sctype(np.float64)) # E: Union[None, Type[{float64}]]
reveal_type(np.obj2sctype(np.float64, default=False)) # E: Union[builtins.bool, Type[{float64}]]
reveal_type(np.obj2sctype("S8")) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("S8", default=None)) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("foo", default=False)) # E: Union[builtins.bool, Type[Any]]
reveal_type(np.obj2sctype(1)) # E: None
reveal_type(np.obj2sctype(1, default=False)) # E: bool
reveal_type(np.issubclass_(np.float64, float)) # E: bool
Reported by Pylint.
Line: 13
Column: 1
reveal_type(np.obj2sctype(np.float64, default=False)) # E: Union[builtins.bool, Type[{float64}]]
reveal_type(np.obj2sctype("S8")) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("S8", default=None)) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("foo", default=False)) # E: Union[builtins.bool, Type[Any]]
reveal_type(np.obj2sctype(1)) # E: None
reveal_type(np.obj2sctype(1, default=False)) # E: bool
reveal_type(np.issubclass_(np.float64, float)) # E: bool
reveal_type(np.issubclass_(np.float64, (int, float))) # E: bool
Reported by Pylint.
Line: 14
Column: 1
reveal_type(np.obj2sctype("S8")) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("S8", default=None)) # E: Union[None, Type[Any]]
reveal_type(np.obj2sctype("foo", default=False)) # E: Union[builtins.bool, Type[Any]]
reveal_type(np.obj2sctype(1)) # E: None
reveal_type(np.obj2sctype(1, default=False)) # E: bool
reveal_type(np.issubclass_(np.float64, float)) # E: bool
reveal_type(np.issubclass_(np.float64, (int, float))) # E: bool
reveal_type(np.issubclass_(1, 1)) # E: Literal[False]
Reported by Pylint.
tools/swig/test/testFarray.py
32 issues
Line: 18
Column: 1
# import the extension module
libDir = "lib.{}-{}.{}".format(get_platform(), *sys.version_info[:2])
sys.path.insert(0, os.path.join("build", libDir))
import Farray
######################################################################
class FarrayTestCase(unittest.TestCase):
Reported by Pylint.
Line: 106
Column: 9
def testAsString(self):
"Test Farray asString method"
result = """\
[ [ 0, 1, 2, 3 ],
[ 1, 2, 3, 4 ],
[ 2, 3, 4, 5 ],
[ 3, 4, 5, 6 ],
[ 4, 5, 6, 7 ] ]
Reported by Pylint.
Line: 120
Column: 9
def testStr(self):
"Test Farray __str__ method"
result = """\
[ [ 0, -1, -2, -3 ],
[ 1, 0, -1, -2 ],
[ 2, 1, 0, -1 ],
[ 3, 2, 1, 0 ],
[ 4, 3, 2, 1 ] ]
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python3
# System imports
from distutils.util import get_platform
import os
import sys
import unittest
# Import NumPy
import numpy as np
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python3
# System imports
from distutils.util import get_platform
import os
import sys
import unittest
# Import NumPy
import numpy as np
Reported by Pylint.
Line: 11
Column: 16
# Import NumPy
import numpy as np
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
if major == 0: BadListError = TypeError
else: BadListError = ValueError
# Add the distutils-generated build directory to the python search path and then
# import the extension module
libDir = "lib.{}-{}.{}".format(get_platform(), *sys.version_info[:2])
Reported by Pylint.
Line: 16
Column: 1
# Add the distutils-generated build directory to the python search path and then
# import the extension module
libDir = "lib.{}-{}.{}".format(get_platform(), *sys.version_info[:2])
sys.path.insert(0, os.path.join("build", libDir))
import Farray
######################################################################
Reported by Pylint.
Line: 18
Column: 1
# import the extension module
libDir = "lib.{}-{}.{}".format(get_platform(), *sys.version_info[:2])
sys.path.insert(0, os.path.join("build", libDir))
import Farray
######################################################################
class FarrayTestCase(unittest.TestCase):
Reported by Pylint.
Line: 22
Column: 1
######################################################################
class FarrayTestCase(unittest.TestCase):
def setUp(self):
self.nrows = 5
self.ncols = 4
self.array = Farray.Farray(self.nrows, self.ncols)
Reported by Pylint.
Line: 29
Column: 5
self.ncols = 4
self.array = Farray.Farray(self.nrows, self.ncols)
def testConstructor1(self):
"Test Farray size constructor"
self.assertTrue(isinstance(self.array, Farray.Farray))
def testConstructor2(self):
"Test Farray copy constructor"
Reported by Pylint.
numpy/distutils/core.py
31 issues
Line: 22
Column: 1
import distutils.core
import distutils.dist
from numpy.distutils.extension import Extension
from numpy.distutils.numpy_distribution import NumpyDistribution
from numpy.distutils.command import config, config_compiler, \
build, build_py, build_ext, build_clib, build_src, build_scripts, \
sdist, install_data, install_headers, install, bdist_rpm, \
install_clib
Reported by Pylint.
Line: 93
Column: 12
return ok
def get_distribution(always=False):
dist = distutils.core._setup_distribution
# XXX Hack to get numpy installable with easy_install.
# The problem is easy_install runs it's own setup(), which
# sets up distutils.core._setup_distribution. However,
# when our setup() runs, that gets overwritten and lost.
# We can't use isinstance, as the DistributionWithoutHelpCommands
Reported by Pylint.
Line: 94
Column: 3
def get_distribution(always=False):
dist = distutils.core._setup_distribution
# XXX Hack to get numpy installable with easy_install.
# The problem is easy_install runs it's own setup(), which
# sets up distutils.core._setup_distribution. However,
# when our setup() runs, that gets overwritten and lost.
# We can't use isinstance, as the DistributionWithoutHelpCommands
# class is local to a function in setuptools.command.easy_install
Reported by Pylint.
Line: 121
Column: 20
# or help request in command in the line.
configuration = new_attr.pop('configuration')
old_dist = distutils.core._setup_distribution
old_stop = distutils.core._setup_stop_after
distutils.core._setup_distribution = None
distutils.core._setup_stop_after = "commandline"
try:
dist = setup(**new_attr)
Reported by Pylint.
Line: 122
Column: 20
configuration = new_attr.pop('configuration')
old_dist = distutils.core._setup_distribution
old_stop = distutils.core._setup_stop_after
distutils.core._setup_distribution = None
distutils.core._setup_stop_after = "commandline"
try:
dist = setup(**new_attr)
finally:
Reported by Pylint.
Line: 123
Column: 9
old_dist = distutils.core._setup_distribution
old_stop = distutils.core._setup_stop_after
distutils.core._setup_distribution = None
distutils.core._setup_stop_after = "commandline"
try:
dist = setup(**new_attr)
finally:
distutils.core._setup_distribution = old_dist
Reported by Pylint.
Line: 124
Column: 9
old_dist = distutils.core._setup_distribution
old_stop = distutils.core._setup_stop_after
distutils.core._setup_distribution = None
distutils.core._setup_stop_after = "commandline"
try:
dist = setup(**new_attr)
finally:
distutils.core._setup_distribution = old_dist
distutils.core._setup_stop_after = old_stop
Reported by Pylint.
Line: 128
Column: 13
try:
dist = setup(**new_attr)
finally:
distutils.core._setup_distribution = old_dist
distutils.core._setup_stop_after = old_stop
if dist.help or not _command_line_ok():
# probably displayed help, skip running any commands
return dist
Reported by Pylint.
Line: 129
Column: 13
dist = setup(**new_attr)
finally:
distutils.core._setup_distribution = old_dist
distutils.core._setup_stop_after = old_stop
if dist.help or not _command_line_ok():
# probably displayed help, skip running any commands
return dist
# create setup dictionary and append to new_attr
Reported by Pylint.
Line: 135
Column: 9
return dist
# create setup dictionary and append to new_attr
config = configuration()
if hasattr(config, 'todict'):
config = config.todict()
_dict_append(new_attr, **config)
# Move extension source libraries to libraries
Reported by Pylint.