Skip to content

Commit

Permalink
DEV: cleanup imports and some assignments (from LGTM)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Mar 17, 2019
1 parent bee436d commit 3212945
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 34 deletions.
3 changes: 1 addition & 2 deletions numpy/compat/py3k.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'pickle', 'contextlib_nullcontext', 'os_fspath', 'os_PathLike']

import sys
import os
try:
from pathlib import Path, PurePath
except ImportError:
Expand Down Expand Up @@ -173,7 +174,6 @@ def npy_load_module(name, fn, info=None):
"""
import imp
import os
if info is None:
path = os.path.dirname(fn)
fo, fn, info = imp.find_module(name, [path])
Expand All @@ -195,7 +195,6 @@ def npy_load_module(name, fn, info=None):

# 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:
Expand Down
2 changes: 0 additions & 2 deletions numpy/core/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
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:
Expand Down
1 change: 0 additions & 1 deletion numpy/core/overrides.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 0 additions & 1 deletion numpy/core/shape_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import functools
import operator
import types
import warnings

from . import numeric as _nx
Expand Down
2 changes: 1 addition & 1 deletion numpy/ctypeslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"""
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
Expand Down
4 changes: 2 additions & 2 deletions numpy/distutils/_shell_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions numpy/distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ def run(self):
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):
Expand Down
7 changes: 3 additions & 4 deletions numpy/distutils/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,6 @@ def calc_ver_info(self, ver_param):
== 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'])
Expand Down Expand Up @@ -1058,9 +1057,9 @@ def get_mkl_rootdir(self):
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):
Expand Down
1 change: 0 additions & 1 deletion numpy/lib/function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
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
Expand Down
5 changes: 1 addition & 4 deletions numpy/lib/npyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
)

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:
Expand Down Expand Up @@ -1123,7 +1122,6 @@ def tobytes_first(x, conv):
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
Expand Down Expand Up @@ -1974,7 +1972,6 @@ def tobytes_first(x, conv):
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
Expand Down
2 changes: 0 additions & 2 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
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
Expand Down Expand Up @@ -1198,7 +1197,6 @@ def __call__(self, a, b, *args, **kwargs):
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)
Expand Down
1 change: 0 additions & 1 deletion numpy/ma/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion numpy/ma/mrecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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
Expand Down
15 changes: 7 additions & 8 deletions numpy/ma/timer_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,10 @@ def test_A(self):
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]))
2 changes: 0 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ def main(argv):
ret = subprocess.call(cmd, cwd=os.path.join(ROOT_DIR, 'benchmarks'))
sys.exit(ret)

test_dir = os.path.join(ROOT_DIR, 'build', 'test')

if args.build_only:
sys.exit(0)
else:
Expand Down

0 comments on commit 3212945

Please sign in to comment.