The following issues were found
numpy/typing/tests/data/reveal/testing.py
137 issues
Line: 11
Column: 8
import numpy as np
import numpy.typing as npt
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
bool_obj: bool
suppress_obj: np.testing.suppress_warnings
FT = TypeVar("FT", bound=Callable[..., Any])
Reported by Pylint.
Line: 12
Column: 8
import numpy.typing as npt
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
bool_obj: bool
suppress_obj: np.testing.suppress_warnings
FT = TypeVar("FT", bound=Callable[..., Any])
Reported by Pylint.
Line: 21
Column: 8
def func() -> int: ...
def func2(
x: npt.NDArray[np.number[Any]],
y: npt.NDArray[np.number[Any]],
) -> npt.NDArray[np.bool_]: ...
reveal_type(np.testing.KnownFailureException()) # E: KnownFailureException
reveal_type(np.testing.IgnoreException()) # E: IgnoreException
Reported by Pylint.
Line: 21
Column: 20
def func() -> int: ...
def func2(
x: npt.NDArray[np.number[Any]],
y: npt.NDArray[np.number[Any]],
) -> npt.NDArray[np.bool_]: ...
reveal_type(np.testing.KnownFailureException()) # E: KnownFailureException
reveal_type(np.testing.IgnoreException()) # E: IgnoreException
Reported by Pylint.
Line: 22
Column: 20
def func2(
x: npt.NDArray[np.number[Any]],
y: npt.NDArray[np.number[Any]],
) -> npt.NDArray[np.bool_]: ...
reveal_type(np.testing.KnownFailureException()) # E: KnownFailureException
reveal_type(np.testing.IgnoreException()) # E: IgnoreException
Reported by Pylint.
Line: 22
Column: 8
def func2(
x: npt.NDArray[np.number[Any]],
y: npt.NDArray[np.number[Any]],
) -> npt.NDArray[np.bool_]: ...
reveal_type(np.testing.KnownFailureException()) # E: KnownFailureException
reveal_type(np.testing.IgnoreException()) # E: IgnoreException
Reported by Pylint.
Line: 23
Column: 6
def func2(
x: npt.NDArray[np.number[Any]],
y: npt.NDArray[np.number[Any]],
) -> npt.NDArray[np.bool_]: ...
reveal_type(np.testing.KnownFailureException()) # E: KnownFailureException
reveal_type(np.testing.IgnoreException()) # E: IgnoreException
reveal_type(np.testing.clear_and_catch_warnings(modules=[np.testing])) # E: _clear_and_catch_warnings_without_records
Reported by Pylint.
Line: 25
Column: 1
y: npt.NDArray[np.number[Any]],
) -> npt.NDArray[np.bool_]: ...
reveal_type(np.testing.KnownFailureException()) # E: KnownFailureException
reveal_type(np.testing.IgnoreException()) # E: IgnoreException
reveal_type(np.testing.clear_and_catch_warnings(modules=[np.testing])) # E: _clear_and_catch_warnings_without_records
reveal_type(np.testing.clear_and_catch_warnings(True)) # E: _clear_and_catch_warnings_with_records
reveal_type(np.testing.clear_and_catch_warnings(False)) # E: _clear_and_catch_warnings_without_records
Reported by Pylint.
Line: 26
Column: 1
) -> npt.NDArray[np.bool_]: ...
reveal_type(np.testing.KnownFailureException()) # E: KnownFailureException
reveal_type(np.testing.IgnoreException()) # E: IgnoreException
reveal_type(np.testing.clear_and_catch_warnings(modules=[np.testing])) # E: _clear_and_catch_warnings_without_records
reveal_type(np.testing.clear_and_catch_warnings(True)) # E: _clear_and_catch_warnings_with_records
reveal_type(np.testing.clear_and_catch_warnings(False)) # E: _clear_and_catch_warnings_without_records
reveal_type(np.testing.clear_and_catch_warnings(bool_obj)) # E: clear_and_catch_warnings
Reported by Pylint.
Line: 28
Column: 1
reveal_type(np.testing.KnownFailureException()) # E: KnownFailureException
reveal_type(np.testing.IgnoreException()) # E: IgnoreException
reveal_type(np.testing.clear_and_catch_warnings(modules=[np.testing])) # E: _clear_and_catch_warnings_without_records
reveal_type(np.testing.clear_and_catch_warnings(True)) # E: _clear_and_catch_warnings_with_records
reveal_type(np.testing.clear_and_catch_warnings(False)) # E: _clear_and_catch_warnings_without_records
reveal_type(np.testing.clear_and_catch_warnings(bool_obj)) # E: clear_and_catch_warnings
reveal_type(np.testing.clear_and_catch_warnings.class_modules) # E: tuple[types.ModuleType]
reveal_type(np.testing.clear_and_catch_warnings.modules) # E: set[types.ModuleType]
Reported by Pylint.
numpy/lib/nanfunctions.py
137 issues
Line: 948
Column: 18
if out is not None and not issubclass(out.dtype.type, np.inexact):
raise TypeError("If a is inexact, then out must be inexact")
cnt = np.sum(~mask, axis=axis, dtype=np.intp, keepdims=keepdims)
tot = np.sum(arr, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
avg = _divide_by_count(tot, cnt, out=out)
isbad = (cnt == 0)
if isbad.any():
Reported by Pylint.
Line: 1540
Column: 18
# keepdims=True, however matrix now raises an error in this case, but
# the reason that it drops the keepdims kwarg is to force keepdims=True
# so this used to work by serendipity.
cnt = np.sum(~mask, axis=axis, dtype=np.intp, keepdims=_keepdims)
avg = np.sum(arr, axis=axis, dtype=dtype, keepdims=_keepdims)
avg = _divide_by_count(avg, cnt)
# Compute squared deviation from mean.
np.subtract(arr, avg, out=arr, casting='unsafe')
Reported by Pylint.
Line: 224
Column: 27
return np.divide(a, b, out=out, casting='unsafe')
def _nanmin_dispatcher(a, axis=None, out=None, keepdims=None):
return (a, out)
@array_function_dispatch(_nanmin_dispatcher)
def nanmin(a, axis=None, out=None, keepdims=np._NoValue):
Reported by Pylint.
Line: 224
Column: 48
return np.divide(a, b, out=out, casting='unsafe')
def _nanmin_dispatcher(a, axis=None, out=None, keepdims=None):
return (a, out)
@array_function_dispatch(_nanmin_dispatcher)
def nanmin(a, axis=None, out=None, keepdims=np._NoValue):
Reported by Pylint.
Line: 229
Column: 45
@array_function_dispatch(_nanmin_dispatcher)
def nanmin(a, axis=None, out=None, keepdims=np._NoValue):
"""
Return minimum of an array or minimum along an axis, ignoring any NaNs.
When all-NaN slices are encountered a ``RuntimeWarning`` is raised and
Nan is returned for that slice.
Reported by Pylint.
Line: 314
Column: 24
"""
kwargs = {}
if keepdims is not np._NoValue:
kwargs['keepdims'] = keepdims
if type(a) is np.ndarray and a.dtype != np.object_:
# Fast, but not safe for subclasses of ndarray, or object arrays,
# which do not implement isnan (gh-9009), or fmin correctly (gh-8975)
res = np.fmin.reduce(a, axis=axis, out=out, **kwargs)
Reported by Pylint.
Line: 339
Column: 27
return res
def _nanmax_dispatcher(a, axis=None, out=None, keepdims=None):
return (a, out)
@array_function_dispatch(_nanmax_dispatcher)
def nanmax(a, axis=None, out=None, keepdims=np._NoValue):
Reported by Pylint.
Line: 339
Column: 48
return res
def _nanmax_dispatcher(a, axis=None, out=None, keepdims=None):
return (a, out)
@array_function_dispatch(_nanmax_dispatcher)
def nanmax(a, axis=None, out=None, keepdims=np._NoValue):
Reported by Pylint.
Line: 344
Column: 45
@array_function_dispatch(_nanmax_dispatcher)
def nanmax(a, axis=None, out=None, keepdims=np._NoValue):
"""
Return the maximum of an array or maximum along an axis, ignoring any
NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is
raised and NaN is returned for that slice.
Reported by Pylint.
Line: 429
Column: 24
"""
kwargs = {}
if keepdims is not np._NoValue:
kwargs['keepdims'] = keepdims
if type(a) is np.ndarray and a.dtype != np.object_:
# Fast, but not safe for subclasses of ndarray, or object arrays,
# which do not implement isnan (gh-9009), or fmax correctly (gh-8975)
res = np.fmax.reduce(a, axis=axis, out=out, **kwargs)
Reported by Pylint.
numpy/ma/extras.py
137 issues
Line: 26
Column: 1
import itertools
import warnings
from . import core as ma
from .core import (
MaskedArray, MAError, add, array, asarray, concatenate, filled, count,
getmask, getmaskarray, make_mask_descr, masked, masked_array, mask_or,
nomask, ones, sort, zeros, getdata, get_masked_subclass, dot,
mask_rowcols
Reported by Pylint.
Line: 27
Column: 1
import warnings
from . import core as ma
from .core import (
MaskedArray, MAError, add, array, asarray, concatenate, filled, count,
getmask, getmaskarray, make_mask_descr, masked, masked_array, mask_or,
nomask, ones, sort, zeros, getdata, get_masked_subclass, dot,
mask_rowcols
)
Reported by Pylint.
Line: 27
Column: 1
import warnings
from . import core as ma
from .core import (
MaskedArray, MAError, add, array, asarray, concatenate, filled, count,
getmask, getmaskarray, make_mask_descr, masked, masked_array, mask_or,
nomask, ones, sort, zeros, getdata, get_masked_subclass, dot,
mask_rowcols
)
Reported by Pylint.
Line: 27
Column: 1
import warnings
from . import core as ma
from .core import (
MaskedArray, MAError, add, array, asarray, concatenate, filled, count,
getmask, getmaskarray, make_mask_descr, masked, masked_array, mask_or,
nomask, ones, sort, zeros, getdata, get_masked_subclass, dot,
mask_rowcols
)
Reported by Pylint.
Line: 27
Column: 1
import warnings
from . import core as ma
from .core import (
MaskedArray, MAError, add, array, asarray, concatenate, filled, count,
getmask, getmaskarray, make_mask_descr, masked, masked_array, mask_or,
nomask, ones, sort, zeros, getdata, get_masked_subclass, dot,
mask_rowcols
)
Reported by Pylint.
Line: 27
Column: 1
import warnings
from . import core as ma
from .core import (
MaskedArray, MAError, add, array, asarray, concatenate, filled, count,
getmask, getmaskarray, make_mask_descr, masked, masked_array, mask_or,
nomask, ones, sort, zeros, getdata, get_masked_subclass, dot,
mask_rowcols
)
Reported by Pylint.
Line: 27
Column: 1
import warnings
from . import core as ma
from .core import (
MaskedArray, MAError, add, array, asarray, concatenate, filled, count,
getmask, getmaskarray, make_mask_descr, masked, masked_array, mask_or,
nomask, ones, sort, zeros, getdata, get_masked_subclass, dot,
mask_rowcols
)
Reported by Pylint.
Line: 207
Column: 5
"""
a = np.empty_like(arr).view(MaskedArray)
a._mask = np.ones(a.shape, dtype=make_mask_descr(a.dtype))
return a
#####--------------------------------------------------------------------------
#---- --- Standard functions ---
Reported by Pylint.
Line: 753
Column: 17
s = mid.sum(out=out)
if not odd:
s = np.true_divide(s, 2., casting='safe', out=out)
s = np.lib.utils._median_nancheck(asorted, s, axis, out)
else:
s = mid.mean(out=out)
# if result is masked either the input contained enough
# minimum_fill_value so that it would be the median or all values
Reported by Pylint.
Line: 793
Column: 13
s = np.ma.sum(low_high, axis=axis, out=out)
np.true_divide(s.data, 2., casting='unsafe', out=s.data)
s = np.lib.utils._median_nancheck(asorted, s, axis, out)
else:
s = np.ma.mean(low_high, axis=axis, out=out)
return s
Reported by Pylint.
numpy/typing/tests/data/reveal/ndarray_misc.py
136 issues
Line: 14
Column: 1
from typing import Any
import numpy as np
from numpy.typing import NDArray
class SubClass(NDArray[np.object_]): ...
f8: np.float64
B: SubClass
Reported by Pylint.
Line: 26
Column: 1
ctypes_obj = AR_f8.ctypes
reveal_type(ctypes_obj.data) # E: int
reveal_type(ctypes_obj.shape) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj.strides) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj._as_parameter_) # E: ctypes.c_void_p
reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p
Reported by Pylint.
Line: 27
Column: 1
ctypes_obj = AR_f8.ctypes
reveal_type(ctypes_obj.data) # E: int
reveal_type(ctypes_obj.shape) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj.strides) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj._as_parameter_) # E: ctypes.c_void_p
reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p
reveal_type(ctypes_obj.shape_as(ct.c_longlong)) # E: ctypes.Array[ctypes.c_longlong]
Reported by Pylint.
Line: 28
Column: 1
reveal_type(ctypes_obj.data) # E: int
reveal_type(ctypes_obj.shape) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj.strides) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj._as_parameter_) # E: ctypes.c_void_p
reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p
reveal_type(ctypes_obj.shape_as(ct.c_longlong)) # E: ctypes.Array[ctypes.c_longlong]
reveal_type(ctypes_obj.strides_as(ct.c_ubyte)) # E: ctypes.Array[ctypes.c_ubyte]
Reported by Pylint.
Line: 29
Column: 1
reveal_type(ctypes_obj.data) # E: int
reveal_type(ctypes_obj.shape) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj.strides) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj._as_parameter_) # E: ctypes.c_void_p
reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p
reveal_type(ctypes_obj.shape_as(ct.c_longlong)) # E: ctypes.Array[ctypes.c_longlong]
reveal_type(ctypes_obj.strides_as(ct.c_ubyte)) # E: ctypes.Array[ctypes.c_ubyte]
Reported by Pylint.
Line: 31
Column: 1
reveal_type(ctypes_obj.strides) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj._as_parameter_) # E: ctypes.c_void_p
reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p
reveal_type(ctypes_obj.shape_as(ct.c_longlong)) # E: ctypes.Array[ctypes.c_longlong]
reveal_type(ctypes_obj.strides_as(ct.c_ubyte)) # E: ctypes.Array[ctypes.c_ubyte]
reveal_type(f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all()) # E: numpy.bool_
Reported by Pylint.
Line: 32
Column: 1
reveal_type(ctypes_obj._as_parameter_) # E: ctypes.c_void_p
reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p
reveal_type(ctypes_obj.shape_as(ct.c_longlong)) # E: ctypes.Array[ctypes.c_longlong]
reveal_type(ctypes_obj.strides_as(ct.c_ubyte)) # E: ctypes.Array[ctypes.c_ubyte]
reveal_type(f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all(axis=0)) # E: Any
Reported by Pylint.
Line: 33
Column: 1
reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p
reveal_type(ctypes_obj.shape_as(ct.c_longlong)) # E: ctypes.Array[ctypes.c_longlong]
reveal_type(ctypes_obj.strides_as(ct.c_ubyte)) # E: ctypes.Array[ctypes.c_ubyte]
reveal_type(f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all(axis=0)) # E: Any
reveal_type(AR_f8.all(keepdims=True)) # E: Any
Reported by Pylint.
Line: 35
Column: 1
reveal_type(ctypes_obj.shape_as(ct.c_longlong)) # E: ctypes.Array[ctypes.c_longlong]
reveal_type(ctypes_obj.strides_as(ct.c_ubyte)) # E: ctypes.Array[ctypes.c_ubyte]
reveal_type(f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all(axis=0)) # E: Any
reveal_type(AR_f8.all(keepdims=True)) # E: Any
reveal_type(AR_f8.all(out=B)) # E: SubClass
Reported by Pylint.
Line: 36
Column: 1
reveal_type(ctypes_obj.strides_as(ct.c_ubyte)) # E: ctypes.Array[ctypes.c_ubyte]
reveal_type(f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all()) # E: numpy.bool_
reveal_type(AR_f8.all(axis=0)) # E: Any
reveal_type(AR_f8.all(keepdims=True)) # E: Any
reveal_type(AR_f8.all(out=B)) # E: SubClass
reveal_type(f8.any()) # E: numpy.bool_
Reported by Pylint.
numpy/lib/tests/test_regression.py
136 issues
Line: 1
Column: 1
import pytest
import os
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_array_almost_equal,
assert_raises, _assert_valid_refcount,
)
Reported by Pylint.
Line: 20
Column: 13
def test_cov_parameters(self):
# Ticket #91
x = np.random.random((3, 3))
y = x.copy()
np.cov(x, rowvar=True)
np.cov(y, rowvar=False)
assert_array_equal(x, y)
Reported by Pylint.
Line: 145
Column: 17
def dp():
n = 3
a = np.ones((n,)*5)
i = np.random.randint(0, n, size=thesize)
a[np.ix_(i, i, i, i, i)] = 0
def dp2():
n = 3
a = np.ones((n,)*5)
Reported by Pylint.
Line: 151
Column: 17
def dp2():
n = 3
a = np.ones((n,)*5)
i = np.random.randint(0, n, size=thesize)
a[np.ix_(i, i, i, i, i)]
assert_raises(ValueError, dp)
assert_raises(ValueError, dp2)
Reported by Pylint.
Line: 1
Column: 1
import pytest
import os
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_array_almost_equal,
assert_raises, _assert_valid_refcount,
)
Reported by Pylint.
Line: 28
Column: 13
def test_mem_digitize(self):
# Ticket #95
for i in range(100):
np.digitize([1, 2, 3, 4], [1, 3])
np.digitize([0, 1, 2, 3, 4], [1, 3])
def test_unique_zero_sized(self):
# Ticket #205
Reported by Pylint.
Line: 50
Column: 18
def test_refcount_vectorize(self):
# Ticket #378
def p(x, y):
return 123
v = np.vectorize(p)
_assert_valid_refcount(v)
def test_poly1d_nan_roots(self):
Reported by Pylint.
Line: 50
Column: 15
def test_refcount_vectorize(self):
# Ticket #378
def p(x, y):
return 123
v = np.vectorize(p)
_assert_valid_refcount(v)
def test_poly1d_nan_roots(self):
Reported by Pylint.
Line: 80
Column: 9
# Ticket #554
x = np.poly1d([1, 2, 3])
y = np.poly1d([3, 4])
assert_(x != y)
assert_(x == x)
def test_polyfit_build(self):
# Ticket #628
ref = [-1.06123820e-06, 5.70886914e-04, -1.13822012e-01,
Reported by Pylint.
Line: 81
Column: 9
x = np.poly1d([1, 2, 3])
y = np.poly1d([3, 4])
assert_(x != y)
assert_(x == x)
def test_polyfit_build(self):
# Ticket #628
ref = [-1.06123820e-06, 5.70886914e-04, -1.13822012e-01,
9.95368241e+00, -3.14526520e+02]
Reported by Pylint.
numpy/lib/tests/test_format.py
135 issues
Line: 282
Column: 1
import shutil
import tempfile
import warnings
import pytest
from io import BytesIO
import numpy as np
from numpy.testing import (
assert_, assert_array_equal, assert_raises, assert_raises_regex,
Reported by Pylint.
Line: 494
Column: 11
def test_compressed_roundtrip(tmpdir):
arr = np.random.rand(200, 200)
npz_file = os.path.join(tmpdir, 'compressed.npz')
np.savez_compressed(npz_file, arr=arr)
with np.load(npz_file) as npz:
arr1 = npz['arr']
assert_array_equal(arr, arr1)
Reported by Pylint.
Line: 279
Column: 1
'''
import sys
import os
import shutil
import tempfile
import warnings
import pytest
from io import BytesIO
Reported by Pylint.
Line: 280
Column: 1
import sys
import os
import shutil
import tempfile
import warnings
import pytest
from io import BytesIO
import numpy as np
Reported by Pylint.
Line: 290
Column: 1
assert_, assert_array_equal, assert_raises, assert_raises_regex,
assert_warns,
)
from numpy.lib import format
# Generate some basic arrays to test with.
scalars = [
np.uint8,
Reported by Pylint.
Line: 434
Column: 5
def assert_equal_(o1, o2):
assert_(o1 == o2)
def test_roundtrip():
for arr in basic_arrays + record_arrays:
arr2 = roundtrip(arr)
Reported by Pylint.
Line: 557
Column: 17
data = data_f
if encoding == 'latin1' and fname.startswith('py2'):
assert_(isinstance(data[3], str))
assert_array_equal(data[:-1], expected[:-1])
# mojibake occurs
assert_array_equal(data[-1].encode(encoding), expected[-1])
else:
assert_(isinstance(data[3], bytes))
Reported by Pylint.
Line: 562
Column: 17
# mojibake occurs
assert_array_equal(data[-1].encode(encoding), expected[-1])
else:
assert_(isinstance(data[3], bytes))
assert_array_equal(data, expected)
if fname.startswith('py2'):
if fname.endswith('.npz'):
data = np.load(path, allow_pickle=True)
Reported by Pylint.
Line: 647
Column: 5
])
def test_descr_to_dtype(dt):
dt1 = format.descr_to_dtype(dt.descr)
assert_equal_(dt1, dt)
arr1 = np.zeros(3, dt)
arr2 = roundtrip(arr1)
assert_array_equal(arr1, arr2)
Reported by Pylint.
Line: 663
Column: 9
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings('always', '', UserWarning)
format.write_array(f, d)
assert_(w[0].category is UserWarning)
# check alignment of data portion
f.seek(0)
header = f.readline()
assert_(len(header) % format.ARRAY_ALIGN == 0)
Reported by Pylint.
benchmarks/benchmarks/bench_ufunc_strides.py
135 issues
Line: 1
Column: 1
from .common import Benchmark
import numpy as np
UNARY_UFUNCS = [obj for obj in np.core.umath.__dict__.values() if
isinstance(obj, np.ufunc)]
UNARY_OBJECT_UFUNCS = [uf for uf in UNARY_UFUNCS if "O->O" in uf.types]
UNARY_OBJECT_UFUNCS.remove(getattr(np, 'invert'))
Reported by Pylint.
Line: 19
Column: 32
param_names = ['ufunc', 'stride_in', 'stride_out', 'dtype']
timeout = 10
def setup(self, ufuncname, stride, stride_out, dtype):
np.seterr(all='ignore')
try:
self.f = ufuncname
except AttributeError:
raise NotImplementedError(f"No ufunc {ufuncname} found") from None
Reported by Pylint.
Line: 19
Column: 52
param_names = ['ufunc', 'stride_in', 'stride_out', 'dtype']
timeout = 10
def setup(self, ufuncname, stride, stride_out, dtype):
np.seterr(all='ignore')
try:
self.f = ufuncname
except AttributeError:
raise NotImplementedError(f"No ufunc {ufuncname} found") from None
Reported by Pylint.
Line: 19
Column: 40
param_names = ['ufunc', 'stride_in', 'stride_out', 'dtype']
timeout = 10
def setup(self, ufuncname, stride, stride_out, dtype):
np.seterr(all='ignore')
try:
self.f = ufuncname
except AttributeError:
raise NotImplementedError(f"No ufunc {ufuncname} found") from None
Reported by Pylint.
Line: 22
Column: 13
def setup(self, ufuncname, stride, stride_out, dtype):
np.seterr(all='ignore')
try:
self.f = ufuncname
except AttributeError:
raise NotImplementedError(f"No ufunc {ufuncname} found") from None
N = 100000
self.arr_out = np.empty(stride_out*N, dtype)
self.arr = np.random.rand(stride*N).astype(dtype)
Reported by Pylint.
Line: 26
Column: 9
except AttributeError:
raise NotImplementedError(f"No ufunc {ufuncname} found") from None
N = 100000
self.arr_out = np.empty(stride_out*N, dtype)
self.arr = np.random.rand(stride*N).astype(dtype)
if (ufuncname.__name__ == 'arccosh'):
self.arr = 1.0 + self.arr
def time_ufunc(self, ufuncname, stride, stride_out, dtype):
Reported by Pylint.
Line: 27
Column: 9
raise NotImplementedError(f"No ufunc {ufuncname} found") from None
N = 100000
self.arr_out = np.empty(stride_out*N, dtype)
self.arr = np.random.rand(stride*N).astype(dtype)
if (ufuncname.__name__ == 'arccosh'):
self.arr = 1.0 + self.arr
def time_ufunc(self, ufuncname, stride, stride_out, dtype):
self.f(self.arr[::stride], self.arr_out[::stride_out])
Reported by Pylint.
Line: 29
Column: 13
self.arr_out = np.empty(stride_out*N, dtype)
self.arr = np.random.rand(stride*N).astype(dtype)
if (ufuncname.__name__ == 'arccosh'):
self.arr = 1.0 + self.arr
def time_ufunc(self, ufuncname, stride, stride_out, dtype):
self.f(self.arr[::stride], self.arr_out[::stride_out])
class AVX_UFunc_log(Benchmark):
Reported by Pylint.
Line: 31
Column: 45
if (ufuncname.__name__ == 'arccosh'):
self.arr = 1.0 + self.arr
def time_ufunc(self, ufuncname, stride, stride_out, dtype):
self.f(self.arr[::stride], self.arr_out[::stride_out])
class AVX_UFunc_log(Benchmark):
params = [stride, dtype]
param_names = ['stride', 'dtype']
Reported by Pylint.
Line: 31
Column: 37
if (ufuncname.__name__ == 'arccosh'):
self.arr = 1.0 + self.arr
def time_ufunc(self, ufuncname, stride, stride_out, dtype):
self.f(self.arr[::stride], self.arr_out[::stride_out])
class AVX_UFunc_log(Benchmark):
params = [stride, dtype]
param_names = ['stride', 'dtype']
Reported by Pylint.
numpy/polynomial/chebyshev.py
132 issues
Line: 114
Column: 1
import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index
from . import polyutils as pu
from ._polybase import ABCPolyBase
__all__ = [
'chebzero', 'chebone', 'chebx', 'chebdomain', 'chebline', 'chebadd',
'chebsub', 'chebmulx', 'chebmul', 'chebdiv', 'chebpow', 'chebval',
Reported by Pylint.
Line: 115
Column: 1
from numpy.core.multiarray import normalize_axis_index
from . import polyutils as pu
from ._polybase import ABCPolyBase
__all__ = [
'chebzero', 'chebone', 'chebx', 'chebdomain', 'chebline', 'chebadd',
'chebsub', 'chebmulx', 'chebmul', 'chebdiv', 'chebpow', 'chebval',
'chebder', 'chebint', 'cheb2poly', 'poly2cheb', 'chebfromroots',
Reported by Pylint.
Line: 441
Column: 5
array([-2., -8., 4., 12.])
"""
from .polynomial import polyadd, polysub, polymulx
[c] = pu.as_series([c])
n = len(c)
if n < 3:
return c
Reported by Pylint.
Line: 305
Column: 8
n = len(zs)//2
ns = np.array([-1, 0, 1], dtype=zs.dtype)
zs *= np.arange(-n, n+1)*2
d, r = _zseries_div(zs, ns)
return d
def _zseries_int(zs):
"""Integrate a z-series.
Reported by Pylint.
Line: 566
Column: 12
array([1.5+0.j, 0. +0.j, 0.5+0.j])
"""
return pu._fromroots(chebline, chebmul, roots)
def chebadd(c1, c2):
"""
Add one Chebyshev series to another.
Reported by Pylint.
Line: 608
Column: 12
array([4., 4., 4.])
"""
return pu._add(c1, c2)
def chebsub(c1, c2):
"""
Subtract one Chebyshev series from another.
Reported by Pylint.
Line: 652
Column: 12
array([ 2., 0., -2.])
"""
return pu._sub(c1, c2)
def chebmulx(c):
"""Multiply a Chebyshev series by x.
Reported by Pylint.
Line: 817
Column: 16
return quo, rem
def chebpow(c, pow, maxpower=16):
"""Raise a Chebyshev series to a power.
Returns the Chebyshev series `c` raised to the power `pow`. The
argument `c` is a sequence of coefficients ordered from low to high.
i.e., [1,2,3] is the series ``T_0 + 2*T_1 + 3*T_2.``
Reported by Pylint.
Line: 870
Column: 13
# in the usual way.
zs = _cseries_to_zseries(c)
prd = zs
for i in range(2, power + 1):
prd = np.convolve(prd, zs)
return _zseries_to_cseries(prd)
def chebder(c, m=1, scl=1, axis=0):
Reported by Pylint.
Line: 938
Column: 11
c = np.array(c, ndmin=1, copy=True)
if c.dtype.char in '?bBhHiIlLqQpP':
c = c.astype(np.double)
cnt = pu._deprecate_as_int(m, "the order of derivation")
iaxis = pu._deprecate_as_int(axis, "the axis")
if cnt < 0:
raise ValueError("The order of derivation must be non-negative")
iaxis = normalize_axis_index(iaxis, c.ndim)
Reported by Pylint.
numpy/core/defchararray.py
131 issues
Line: 19
Column: 1
"""
import functools
from .numerictypes import (
string_, unicode_, integer, int_, object_, bool_, character)
from .numeric import ndarray, compare_chararrays
from .numeric import array as narray
from numpy.core.multiarray import _vec_string
from numpy.core.overrides import set_module
Reported by Pylint.
Line: 21
Column: 1
import functools
from .numerictypes import (
string_, unicode_, integer, int_, object_, bool_, character)
from .numeric import ndarray, compare_chararrays
from .numeric import array as narray
from numpy.core.multiarray import _vec_string
from numpy.core.overrides import set_module
from numpy.core import overrides
from numpy.compat import asbytes
Reported by Pylint.
Line: 22
Column: 1
from .numerictypes import (
string_, unicode_, integer, int_, object_, bool_, character)
from .numeric import ndarray, compare_chararrays
from .numeric import array as narray
from numpy.core.multiarray import _vec_string
from numpy.core.overrides import set_module
from numpy.core import overrides
from numpy.compat import asbytes
import numpy
Reported by Pylint.
Line: 313
Column: 29
return _vec_string(arr1, (dtype, out_size), '__add__', (arr2,))
def _multiply_dispatcher(a, i):
return (a,)
@array_function_dispatch(_multiply_dispatcher)
def multiply(a, i):
Reported by Pylint.
Line: 418
Column: 34
return _vec_string(a_arr, a_arr.dtype, 'capitalize')
def _center_dispatcher(a, width, fillchar=None):
return (a,)
@array_function_dispatch(_center_dispatcher)
def center(a, width, fillchar=' '):
Reported by Pylint.
Line: 418
Column: 27
return _vec_string(a_arr, a_arr.dtype, 'capitalize')
def _center_dispatcher(a, width, fillchar=None):
return (a,)
@array_function_dispatch(_center_dispatcher)
def center(a, width, fillchar=' '):
Reported by Pylint.
Line: 459
Column: 43
a_arr, (a_arr.dtype.type, size), 'center', (width_arr, fillchar))
def _count_dispatcher(a, sub, start=None, end=None):
return (a,)
@array_function_dispatch(_count_dispatcher)
def count(a, sub, start=0, end=None):
Reported by Pylint.
Line: 459
Column: 31
a_arr, (a_arr.dtype.type, size), 'center', (width_arr, fillchar))
def _count_dispatcher(a, sub, start=None, end=None):
return (a,)
@array_function_dispatch(_count_dispatcher)
def count(a, sub, start=0, end=None):
Reported by Pylint.
Line: 459
Column: 26
a_arr, (a_arr.dtype.type, size), 'center', (width_arr, fillchar))
def _count_dispatcher(a, sub, start=None, end=None):
return (a,)
@array_function_dispatch(_count_dispatcher)
def count(a, sub, start=0, end=None):
Reported by Pylint.
Line: 509
Column: 40
return _vec_string(a, int_, 'count', [sub, start] + _clean_args(end))
def _code_dispatcher(a, encoding=None, errors=None):
return (a,)
@array_function_dispatch(_code_dispatcher)
def decode(a, encoding=None, errors=None):
Reported by Pylint.
numpy/polynomial/hermite.py
130 issues
Line: 82
Column: 1
import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index
from . import polyutils as pu
from ._polybase import ABCPolyBase
__all__ = [
'hermzero', 'hermone', 'hermx', 'hermdomain', 'hermline', 'hermadd',
'hermsub', 'hermmulx', 'hermmul', 'hermdiv', 'hermpow', 'hermval',
Reported by Pylint.
Line: 83
Column: 1
from numpy.core.multiarray import normalize_axis_index
from . import polyutils as pu
from ._polybase import ABCPolyBase
__all__ = [
'hermzero', 'hermone', 'hermx', 'hermdomain', 'hermline', 'hermadd',
'hermsub', 'hermmulx', 'hermmul', 'hermdiv', 'hermpow', 'hermval',
'hermder', 'hermint', 'herm2poly', 'poly2herm', 'hermfromroots',
Reported by Pylint.
Line: 180
Column: 5
array([0., 1., 2., 3.])
"""
from .polynomial import polyadd, polysub, polymulx
[c] = pu.as_series([c])
n = len(c)
if n == 1:
return c
Reported by Pylint.
Line: 310
Column: 12
array([0.+0.j, 0.+0.j])
"""
return pu._fromroots(hermline, hermmul, roots)
def hermadd(c1, c2):
"""
Add one Hermite series to another.
Reported by Pylint.
Line: 350
Column: 12
array([2., 4., 6., 4.])
"""
return pu._add(c1, c2)
def hermsub(c1, c2):
"""
Subtract one Hermite series from another.
Reported by Pylint.
Line: 390
Column: 12
array([0., 0., 0., 4.])
"""
return pu._sub(c1, c2)
def hermmulx(c):
"""Multiply a Hermite series by x.
Reported by Pylint.
Line: 557
Column: 12
(array([1., 2., 3.]), array([1., 1.]))
"""
return pu._div(hermmul, c1, c2)
def hermpow(c, pow, maxpower=16):
"""Raise a Hermite series to a power.
Reported by Pylint.
Line: 560
Column: 16
return pu._div(hermmul, c1, c2)
def hermpow(c, pow, maxpower=16):
"""Raise a Hermite series to a power.
Returns the Hermite series `c` raised to the power `pow`. The
argument `c` is a sequence of coefficients ordered from low to high.
i.e., [1,2,3] is the series ``P_0 + 2*P_1 + 3*P_2.``
Reported by Pylint.
Line: 594
Column: 12
array([81., 52., 82., 12., 9.])
"""
return pu._pow(hermmul, c, pow, maxpower)
def hermder(c, m=1, scl=1, axis=0):
"""
Differentiate a Hermite series.
Reported by Pylint.
Line: 655
Column: 11
c = np.array(c, ndmin=1, copy=True)
if c.dtype.char in '?bBhHiIlLqQpP':
c = c.astype(np.double)
cnt = pu._deprecate_as_int(m, "the order of derivation")
iaxis = pu._deprecate_as_int(axis, "the axis")
if cnt < 0:
raise ValueError("The order of derivation must be non-negative")
iaxis = normalize_axis_index(iaxis, c.ndim)
Reported by Pylint.