diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2015-07-05 13:19:43 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-07-05 17:29:25 -0600 |
commit | 7fa8ab6ac29c1dccf34dae5c53211ace67620ed7 (patch) | |
tree | 29c6f65a680e9bb21bda2624ba1e38ace5d48525 /numpy/core | |
parent | 8b3e9ae5262c1da1118370cd6e83db9b2166952e (diff) | |
download | numpy-7fa8ab6ac29c1dccf34dae5c53211ace67620ed7.tar.gz |
MAINT: Fix some pyflakes warnings in numpy/core/*.py
These fixes are not agressive as some of the code is complicated
and it is better to be careful.
The files numeric.py and numerictypes.py are not easily analysed
and the latter is self modifying. Pyflakes generates a number of
invalid warnings for those files.
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/_internal.py | 5 | ||||
-rw-r--r-- | numpy/core/defchararray.py | 23 | ||||
-rw-r--r-- | numpy/core/function_base.py | 2 | ||||
-rw-r--r-- | numpy/core/memmap.py | 7 | ||||
-rw-r--r-- | numpy/core/numeric.py | 49 | ||||
-rw-r--r-- | numpy/core/numerictypes.py | 35 | ||||
-rw-r--r-- | numpy/core/setup.py | 4 | ||||
-rw-r--r-- | numpy/core/setup_common.py | 12 | ||||
-rw-r--r-- | numpy/core/shape_base.py | 2 |
9 files changed, 64 insertions, 75 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index b6af93d43..f8271d5ab 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -8,9 +8,8 @@ from __future__ import division, absolute_import, print_function import re import sys -import warnings -from numpy.compat import asbytes, bytes, basestring +from numpy.compat import asbytes, basestring from .multiarray import dtype, array, ndarray import ctypes from .numerictypes import object_ @@ -561,7 +560,6 @@ def _dtype_from_pep3118(spec, byteorder='@', is_subdtype=False): this_explicit_name = False common_alignment = 1 is_padding = False - last_offset = 0 dummy_name_index = [0] @@ -691,7 +689,6 @@ def _dtype_from_pep3118(spec, byteorder='@', is_subdtype=False): raise RuntimeError("Duplicate field name '%s' in PEP3118 format" % name) fields[name] = (value, offset) - last_offset = offset if not this_explicit_name: next_dummy_name() diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index e273007c9..e18f912d6 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -25,17 +25,18 @@ from numpy.core.multiarray import _vec_string from numpy.compat import asbytes, long import numpy -__all__ = ['chararray', - 'equal', 'not_equal', 'greater_equal', 'less_equal', 'greater', 'less', - 'str_len', 'add', 'multiply', 'mod', 'capitalize', 'center', 'count', - 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', - 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', - 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', - 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', - 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', - 'swapcase', 'title', 'translate', 'upper', 'zfill', - 'isnumeric', 'isdecimal', - 'array', 'asarray'] +__all__ = [ + 'chararray', 'equal', 'not_equal', 'greater_equal', 'less_equal', + 'greater', 'less', 'str_len', 'add', 'multiply', 'mod', 'capitalize', + 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', + 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', + 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', + 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', + 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', + 'title', 'translate', 'upper', 'zfill', 'isnumeric', 'isdecimal', + 'array', 'asarray' + ] + _globalvar = 0 if sys.version_info[0] >= 3: diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py index 1e759e0c2..e50e1a505 100644 --- a/numpy/core/function_base.py +++ b/numpy/core/function_base.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function __all__ = ['logspace', 'linspace'] from . import numeric as _nx -from .numeric import array, result_type, NaN +from .numeric import result_type, NaN def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index 2e8b305d3..70d7b72b4 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -1,14 +1,11 @@ from __future__ import division, absolute_import, print_function -__all__ = ['memmap'] - -import warnings -import sys - import numpy as np from .numeric import uint8, ndarray, dtype from numpy.compat import long, basestring +__all__ = ['memmap'] + dtypedescr = dtype valid_filemodes = ["r", "c", "r+", "w+"] writeable_filemodes = ["r+", "w+"] diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index c31c5f75f..fd53b5c72 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1,6 +1,5 @@ from __future__ import division, absolute_import, print_function -import os import sys import warnings import collections @@ -21,30 +20,28 @@ else: loads = pickle.loads -__all__ = ['newaxis', 'ndarray', 'flatiter', 'nditer', 'nested_iters', 'ufunc', - 'arange', 'array', 'zeros', 'count_nonzero', - 'empty', 'broadcast', 'dtype', 'fromstring', 'fromfile', - 'frombuffer', 'int_asbuffer', 'where', 'argwhere', 'copyto', - 'concatenate', 'fastCopyAndTranspose', 'lexsort', 'set_numeric_ops', - 'can_cast', 'promote_types', 'min_scalar_type', 'result_type', - 'asarray', 'asanyarray', 'ascontiguousarray', 'asfortranarray', - 'isfortran', 'empty_like', 'zeros_like', 'ones_like', - 'correlate', 'convolve', 'inner', 'dot', 'einsum', 'outer', 'vdot', - 'alterdot', 'restoredot', 'roll', 'rollaxis', 'cross', 'tensordot', - 'array2string', 'get_printoptions', 'set_printoptions', - 'array_repr', 'array_str', 'set_string_function', - 'little_endian', 'require', - 'fromiter', 'array_equal', 'array_equiv', - 'indices', 'fromfunction', 'isclose', - 'load', 'loads', 'isscalar', 'binary_repr', 'base_repr', - 'ones', 'identity', 'allclose', 'compare_chararrays', 'putmask', - 'seterr', 'geterr', 'setbufsize', 'getbufsize', - 'seterrcall', 'geterrcall', 'errstate', 'flatnonzero', - 'Inf', 'inf', 'infty', 'Infinity', - 'nan', 'NaN', 'False_', 'True_', 'bitwise_not', - 'CLIP', 'RAISE', 'WRAP', 'MAXDIMS', 'BUFSIZE', 'ALLOW_THREADS', - 'ComplexWarning', 'may_share_memory', 'full', 'full_like', - 'matmul'] +__all__ = [ + 'newaxis', 'ndarray', 'flatiter', 'nditer', 'nested_iters', 'ufunc', + 'arange', 'array', 'zeros', 'count_nonzero', 'empty', 'broadcast', + 'dtype', 'fromstring', 'fromfile', 'frombuffer', 'int_asbuffer', + 'where', 'argwhere', 'copyto', 'concatenate', 'fastCopyAndTranspose', + 'lexsort', 'set_numeric_ops', 'can_cast', 'promote_types', + 'min_scalar_type', 'result_type', 'asarray', 'asanyarray', + 'ascontiguousarray', 'asfortranarray', 'isfortran', 'empty_like', + 'zeros_like', 'ones_like', 'correlate', 'convolve', 'inner', 'dot', + 'einsum', 'outer', 'vdot', 'alterdot', 'restoredot', 'roll', + 'rollaxis', 'cross', 'tensordot', 'array2string', 'get_printoptions', + 'set_printoptions', 'array_repr', 'array_str', 'set_string_function', + 'little_endian', 'require', 'fromiter', 'array_equal', 'array_equiv', + 'indices', 'fromfunction', 'isclose', 'load', 'loads', 'isscalar', + 'binary_repr', 'base_repr', 'ones', 'identity', 'allclose', + 'compare_chararrays', 'putmask', 'seterr', 'geterr', 'setbufsize', + 'getbufsize', 'seterrcall', 'geterrcall', 'errstate', 'flatnonzero', + 'Inf', 'inf', 'infty', 'Infinity', 'nan', 'NaN', 'False_', 'True_', + 'bitwise_not', 'CLIP', 'RAISE', 'WRAP', 'MAXDIMS', 'BUFSIZE', + 'ALLOW_THREADS', 'ComplexWarning', 'may_share_memory', 'full', + 'full_like', 'matmul', + ] if sys.version_info[0] < 3: __all__.extend(['getbuffer', 'newbuffer']) @@ -1281,7 +1278,7 @@ def tensordot(a, b, axes=2): bs = b.shape ndb = len(b.shape) equal = True - if (na != nb): + if na != nb: equal = False else: for k in range(na): diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index d8277beea..7dc6e0bd8 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -82,6 +82,18 @@ Exported symbols include: """ from __future__ import division, absolute_import, print_function +import types as _types +import sys +import numbers + +from numpy.compat import bytes, long +from numpy.core.multiarray import ( + typeinfo, ndarray, array, empty, dtype, datetime_data, + datetime_as_string, busday_offset, busday_count, is_busday, + busdaycalendar + ) + + # we add more at the bottom __all__ = ['sctypeDict', 'sctypeNA', 'typeDict', 'typeNA', 'sctypes', 'ScalarType', 'obj2sctype', 'cast', 'nbytes', 'sctype2char', @@ -90,15 +102,6 @@ __all__ = ['sctypeDict', 'sctypeNA', 'typeDict', 'typeNA', 'sctypes', 'busday_offset', 'busday_count', 'is_busday', 'busdaycalendar', ] -from numpy.core.multiarray import ( - typeinfo, ndarray, array, empty, dtype, datetime_data, - datetime_as_string, busday_offset, busday_count, is_busday, - busdaycalendar - ) -import types as _types -import sys -from numpy.compat import bytes, long -import numbers # we don't export these for import *, but we do want them accessible # as numerictypes.bool, etc. @@ -328,15 +331,10 @@ def _add_aliases(): sctypeNA[char] = na_name _add_aliases() -# Integers handled so that -# The int32, int64 types should agree exactly with -# PyArray_INT32, PyArray_INT64 in C -# We need to enforce the same checking as is done -# in arrayobject.h where the order of getting a -# bit-width match is: -# long, longlong, int, short, char -# for int8, int16, int32, int64, int128 - +# Integers are handled so that the int32 and int64 types should agree +# exactly with NPY_INT32, NPY_INT64. We need to enforce the same checking +# as is done in arrayobject.h where the order of getting a bit-width match +# is long, longlong, int, short, char. def _add_integer_aliases(): _ctypes = ['LONG', 'LONGLONG', 'INT', 'SHORT', 'BYTE'] for ctype in _ctypes: @@ -960,6 +958,7 @@ def _register_types(): numbers.Integral.register(integer) numbers.Complex.register(inexact) numbers.Real.register(floating) + _register_types() def find_common_type(array_types, scalar_types): diff --git a/numpy/core/setup.py b/numpy/core/setup.py index ac797562d..9221bd2c4 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -3,11 +3,9 @@ from __future__ import division, print_function import imp import os import sys -import shutil import pickle import copy import warnings -import re from os.path import join from numpy.distutils import log from distutils.dep_util import newer @@ -381,7 +379,7 @@ def visibility_define(config): def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration, dot_join - from numpy.distutils.system_info import get_info, default_lib_dirs + from numpy.distutils.system_info import get_info config = Configuration('core', parent_package, top_path) local_dir = config.local_path diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py index c7bb8688c..c923b6d91 100644 --- a/numpy/core/setup_common.py +++ b/numpy/core/setup_common.py @@ -2,12 +2,10 @@ from __future__ import division, absolute_import, print_function # Code common to build tools import sys -from os.path import join import warnings import copy import binascii -from distutils.ccompiler import CompileError #------------------- # Versioning support @@ -54,11 +52,13 @@ def is_released(config): return True def get_api_versions(apiversion, codegen_dir): - """Return current C API checksum and the recorded checksum for the given - version of the C API version.""" - api_files = [join(codegen_dir, 'numpy_api_order.txt'), - join(codegen_dir, 'ufunc_api_order.txt')] + """ + Return current C API checksum and the recorded checksum. + + Return current C API checksum and the recorded checksum for the given + version of the C API version. + """ # Compute the hash of the current API as defined in the .txt files in # code_generators sys.path.insert(0, codegen_dir) diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py index 50c46f38e..0dd2e164a 100644 --- a/numpy/core/shape_base.py +++ b/numpy/core/shape_base.py @@ -4,7 +4,7 @@ __all__ = ['atleast_1d', 'atleast_2d', 'atleast_3d', 'vstack', 'hstack', 'stack'] from . import numeric as _nx -from .numeric import array, asanyarray, newaxis +from .numeric import asanyarray, newaxis def atleast_1d(*arys): """ |