diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-03-17 15:01:28 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-17 15:01:28 -0600 |
commit | d89c4c7e7850578e5ee61e3e09abd86318906975 (patch) | |
tree | 6736e5339887d30ea1207a8a943fd4161e714279 /numpy | |
parent | 1a92b74a5387f676dd389ffd91054e8c2733f413 (diff) | |
parent | 32129453da0f9bf0f352adaaff79f884d2bf52bc (diff) | |
download | numpy-d89c4c7e7850578e5ee61e3e09abd86318906975.tar.gz |
Merge pull request #13140 from mattip/lgtm-fixes
DEV: cleanup imports and some assignments (from LGTM)
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/compat/py3k.py | 3 | ||||
-rw-r--r-- | numpy/core/_exceptions.py | 2 | ||||
-rw-r--r-- | numpy/core/overrides.py | 1 | ||||
-rw-r--r-- | numpy/core/shape_base.py | 1 | ||||
-rw-r--r-- | numpy/ctypeslib.py | 2 | ||||
-rw-r--r-- | numpy/distutils/_shell_utils.py | 4 | ||||
-rw-r--r-- | numpy/distutils/command/build_ext.py | 4 | ||||
-rw-r--r-- | numpy/distutils/system_info.py | 7 | ||||
-rw-r--r-- | numpy/lib/function_base.py | 1 | ||||
-rw-r--r-- | numpy/lib/npyio.py | 5 | ||||
-rw-r--r-- | numpy/ma/core.py | 2 | ||||
-rw-r--r-- | numpy/ma/extras.py | 1 | ||||
-rw-r--r-- | numpy/ma/mrecords.py | 1 | ||||
-rw-r--r-- | numpy/ma/timer_comparison.py | 15 |
14 files changed, 17 insertions, 32 deletions
diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py index 141a21fed..c9ed9d52c 100644 --- a/numpy/compat/py3k.py +++ b/numpy/compat/py3k.py @@ -11,6 +11,7 @@ __all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar', 'pickle', 'contextlib_nullcontext', 'os_fspath', 'os_PathLike'] import sys +import os try: from pathlib import Path, PurePath except ImportError: @@ -173,7 +174,6 @@ else: """ import imp - import os if info is None: path = os.path.dirname(fn) fo, fn, info = imp.find_module(name, [path]) @@ -195,7 +195,6 @@ else: # Backport os.fs_path, os.PathLike, and PurePath.__fspath__ if sys.version_info[:2] >= (3, 6): - import os os_fspath = os.fspath os_PathLike = os.PathLike else: diff --git a/numpy/core/_exceptions.py b/numpy/core/_exceptions.py index 5e0105beb..227c08cd6 100644 --- a/numpy/core/_exceptions.py +++ b/numpy/core/_exceptions.py @@ -5,8 +5,6 @@ in python where it's easier. By putting the formatting in `__str__`, we also avoid paying the cost for users who silence the exceptions. """ -from numpy.core.overrides import set_module - def _unpack_tuple(tup): if len(tup) == 1: diff --git a/numpy/core/overrides.py b/numpy/core/overrides.py index 46097f39c..9f91adc83 100644 --- a/numpy/core/overrides.py +++ b/numpy/core/overrides.py @@ -1,7 +1,6 @@ """Implementation of __array_function__ overrides from NEP-18.""" import collections import functools -import os from numpy.core._multiarray_umath import ( add_docstring, implement_array_function, _get_implementing_args) diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py index e43519689..0eac772e8 100644 --- a/numpy/core/shape_base.py +++ b/numpy/core/shape_base.py @@ -5,7 +5,6 @@ __all__ = ['atleast_1d', 'atleast_2d', 'atleast_3d', 'block', 'hstack', import functools import operator -import types import warnings from . import numeric as _nx diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py index 02c3bd211..1967a85b6 100644 --- a/numpy/ctypeslib.py +++ b/numpy/ctypeslib.py @@ -51,7 +51,7 @@ Then, we're ready to call ``foo_func``: """ from __future__ import division, absolute_import, print_function -__all__ = ['load_library', 'ndpointer', 'test', 'ctypes_load_library', +__all__ = ['load_library', 'ndpointer', 'ctypes_load_library', 'c_intp', 'as_ctypes', 'as_array'] import os diff --git a/numpy/distutils/_shell_utils.py b/numpy/distutils/_shell_utils.py index 5ef874900..82abd5f4e 100644 --- a/numpy/distutils/_shell_utils.py +++ b/numpy/distutils/_shell_utils.py @@ -24,12 +24,12 @@ class CommandLineParser: @staticmethod def join(argv): """ Join a list of arguments into a command line string """ - raise NotImplemented + raise NotImplementedError @staticmethod def split(cmd): """ Split a command line string into a list of arguments """ - raise NotImplemented + raise NotImplementedError class WindowsParser: diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py index ab9d585a5..ef54fb25e 100644 --- a/numpy/distutils/command/build_ext.py +++ b/numpy/distutils/command/build_ext.py @@ -281,8 +281,8 @@ class build_ext (old_build_ext): runtime_lib = os.path.join(self.extra_dll_dir, fn) copy_file(runtime_lib, shared_lib_dir) - def swig_sources(self, sources): - # Do nothing. Swig sources have beed handled in build_src command. + def swig_sources(self, sources, extensions=None): + # Do nothing. Swig sources have been handled in build_src command. return sources def build_extension(self, ext): diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index e723b85b8..4d923ad26 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -906,7 +906,6 @@ class fftw_info(system_info): == len(ver_param['includes']): dict_append(info, include_dirs=[d]) flag = 1 - incl_dirs = [d] break if flag: dict_append(info, define_macros=ver_param['macros']) @@ -1058,9 +1057,9 @@ class mkl_info(system_info): for d in paths: dirs = glob(os.path.join(d, 'mkl', '*')) dirs += glob(os.path.join(d, 'mkl*')) - for d in dirs: - if os.path.isdir(os.path.join(d, 'lib')): - return d + for sub_dir in dirs: + if os.path.isdir(os.path.join(sub_dir, 'lib')): + return sub_dir return None def __init__(self): diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index b61a64b8e..fb40ef927 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -31,7 +31,6 @@ from numpy.core.overrides import set_module from numpy.core import overrides from numpy.core.function_base import add_newdoc from numpy.lib.twodim_base import diag -from .utils import deprecate from numpy.core.multiarray import ( _insert, add_docstring, bincount, normalize_axis_index, _monotonicity, interp as compiled_interp, interp_complex as compiled_interp_complex diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 1e43fdb34..d702859fa 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -23,8 +23,7 @@ from ._iotools import ( ) from numpy.compat import ( - asbytes, asstr, asunicode, asbytes_nested, bytes, basestring, unicode, - os_fspath, os_PathLike, pickle + asbytes, asstr, asunicode, bytes, basestring, os_fspath, os_PathLike, pickle ) if sys.version_info[0] >= 3: @@ -1123,7 +1122,6 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, if type(x) is bytes: return conv(x) return conv(x.encode("latin1")) - import functools converters[i] = functools.partial(tobytes_first, conv=conv) else: converters[i] = conv @@ -1974,7 +1972,6 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, if type(x) is bytes: return conv(x) return conv(x.encode("latin1")) - import functools user_conv = functools.partial(tobytes_first, conv=conv) else: user_conv = conv diff --git a/numpy/ma/core.py b/numpy/ma/core.py index b8fd76860..1f5bc2a51 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -44,7 +44,6 @@ from numpy.compat import ( getargspec, formatargspec, long, basestring, unicode, bytes ) from numpy import expand_dims -from numpy.core.multiarray import normalize_axis_index from numpy.core.numeric import normalize_axis_tuple from numpy.core._internal import recursive from numpy.compat import pickle @@ -1198,7 +1197,6 @@ exp = _MaskedUnaryOperation(umath.exp) conjugate = _MaskedUnaryOperation(umath.conjugate) sin = _MaskedUnaryOperation(umath.sin) cos = _MaskedUnaryOperation(umath.cos) -tan = _MaskedUnaryOperation(umath.tan) arctan = _MaskedUnaryOperation(umath.arctan) arcsinh = _MaskedUnaryOperation(umath.arcsinh) sinh = _MaskedUnaryOperation(umath.sinh) diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index 2e3b84e1c..a51d83578 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -390,7 +390,6 @@ def apply_along_axis(func1d, axis, arr, *args, **kwargs): i[axis] = slice(None, None) outshape = np.asarray(arr.shape).take(indlist) i.put(indlist, ind) - j = i.copy() res = func1d(arr[tuple(i.tolist())], *args, **kwargs) # if res is a number, then we have a smaller output array asscalar = np.isscalar(res) diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index 6779be746..9bcb3947d 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -19,7 +19,6 @@ import sys import warnings import numpy as np -import numpy.core.numerictypes as ntypes from numpy.compat import basestring from numpy import ( bool_, dtype, ndarray, recarray, array as narray diff --git a/numpy/ma/timer_comparison.py b/numpy/ma/timer_comparison.py index 68104ed0a..4ad635e38 100644 --- a/numpy/ma/timer_comparison.py +++ b/numpy/ma/timer_comparison.py @@ -430,11 +430,10 @@ if __name__ == '__main__': setup_cur = "import numpy.ma.core as module\n" + setup_base (nrepeat, nloop) = (10, 10) - if 1: - for i in range(1, 8): - func = 'tester.test_%i()' % i - cur = timeit.Timer(func, setup_cur).repeat(nrepeat, nloop*10) - cur = np.sort(cur) - print("#%i" % i + 50*'.') - print(eval("ModuleTester.test_%i.__doc__" % i)) - print("core_current : %.3f - %.3f" % (cur[0], cur[1])) + for i in range(1, 8): + func = 'tester.test_%i()' % i + cur = timeit.Timer(func, setup_cur).repeat(nrepeat, nloop*10) + cur = np.sort(cur) + print("#%i" % i + 50*'.') + print(eval("ModuleTester.test_%i.__doc__" % i)) + print("core_current : %.3f - %.3f" % (cur[0], cur[1])) |