Skip to content

Commit

Permalink
MAINT: Clean up, mostly unused imports.
Browse files Browse the repository at this point in the history
WarrenWeckesser committed Jan 23, 2020
1 parent 04ac2a1 commit 021163b
Showing 32 changed files with 10 additions and 52 deletions.
1 change: 0 additions & 1 deletion numpy/core/_add_newdocs.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
core/fromnumeric.py, core/defmatrix.py up-to-date.
"""
import sys

from numpy.core import numerictypes as _numerictypes
from numpy.core import dtype
1 change: 0 additions & 1 deletion numpy/core/_exceptions.py
Original file line number Diff line number Diff line change
@@ -157,7 +157,6 @@ def _total_size(self):
@staticmethod
def _size_to_string(num_bytes):
""" Convert a number of bytes into a binary size string """
import math

# https://en.wikipedia.org/wiki/Binary_prefix
LOG2_STEP = 10
4 changes: 2 additions & 2 deletions numpy/core/arrayprint.py
Original file line number Diff line number Diff line change
@@ -31,12 +31,12 @@

import numpy as np
from . import numerictypes as _nt
from .umath import absolute, not_equal, isnan, isinf, isfinite, isnat
from .umath import absolute, isinf, isfinite, isnat
from . import multiarray
from .multiarray import (array, dragon4_positional, dragon4_scientific,
datetime_as_string, datetime_data, ndarray,
set_legacy_print_mode)
from .fromnumeric import ravel, any
from .fromnumeric import any
from .numeric import concatenate, asarray, errstate
from .numerictypes import (longlong, intc, int_, float_, complex_, bool_,
flexible)
1 change: 0 additions & 1 deletion numpy/core/fromnumeric.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
import warnings

import numpy as np
from .. import VisibleDeprecationWarning
from . import multiarray as mu
from . import overrides
from . import umath as um
3 changes: 0 additions & 3 deletions numpy/core/multiarray.py
Original file line number Diff line number Diff line change
@@ -7,13 +7,10 @@
"""

import functools
import sys
import warnings
import sys

from . import overrides
from . import _multiarray_umath
import numpy as np
from ._multiarray_umath import * # noqa: F403
from ._multiarray_umath import (
_fastCopyAndTranspose, _flagdict, _insert, _reconstruct, _vec_string,
3 changes: 1 addition & 2 deletions numpy/core/numeric.py
Original file line number Diff line number Diff line change
@@ -4,10 +4,9 @@
import sys
import warnings
import numbers
import contextlib

import numpy as np
from numpy.compat import pickle, basestring
from numpy.compat import basestring
from . import multiarray
from .multiarray import (
_fastCopyAndTranspose as fastCopyAndTranspose, ALLOW_THREADS,
1 change: 0 additions & 1 deletion numpy/core/records.py
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@
array([2., 2.])
"""
import sys
import os
import warnings
from collections import Counter, OrderedDict
1 change: 0 additions & 1 deletion numpy/core/setup_common.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
import sys
import warnings
import copy
import binascii
import textwrap

from numpy.distutils.misc_util import mingw32
1 change: 0 additions & 1 deletion numpy/core/tests/test_arrayprint.py
Original file line number Diff line number Diff line change
@@ -837,7 +837,6 @@ def test_bad_args(self):
assert_raises(TypeError, np.set_printoptions, threshold=b'1')

def test_unicode_object_array():
import sys
expected = "array(['é'], dtype=object)"
x = np.array([u'\xe9'], dtype=object)
assert_equal(repr(x), expected)
3 changes: 1 addition & 2 deletions numpy/core/tests/test_defchararray.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import sys

import numpy as np
from numpy.core.multiarray import _vec_string
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_raises,
assert_raises_regex, suppress_warnings,
assert_raises_regex
)

kw_unicode_true = {'unicode': True} # make 2to3 work properly
2 changes: 0 additions & 2 deletions numpy/core/tests/test_deprecations.py
Original file line number Diff line number Diff line change
@@ -4,11 +4,9 @@
"""
import datetime
import sys
import operator
import warnings
import pytest
import shutil
import tempfile

import numpy as np
1 change: 0 additions & 1 deletion numpy/core/tests/test_function_base.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
)
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_array_equal, assert_allclose,
suppress_warnings
)


1 change: 0 additions & 1 deletion numpy/core/tests/test_indexing.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
import warnings
import functools
import operator
import pytest

import numpy as np
from numpy.core._multiarray_tests import array_indexing
1 change: 0 additions & 1 deletion numpy/core/tests/test_mem_overlap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import itertools
import pytest

6 changes: 1 addition & 5 deletions numpy/core/tests/test_scalar_ctors.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
"""
Test the scalar constructors, which also do type-coercion
"""
import sys
import platform
import pytest

import numpy as np
from numpy.testing import (
assert_equal, assert_almost_equal, assert_raises, assert_warns,
assert_equal, assert_almost_equal, assert_warns,
)

class TestFromString:
8 changes: 2 additions & 6 deletions numpy/core/tests/test_scalar_methods.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
"""
Test the scalar constructors, which also do type-coercion
"""
import os
import fractions
import platform

import pytest
import numpy as np

from numpy.testing import (
run_module_suite,
assert_equal, assert_almost_equal, assert_raises, assert_warns,
dec
)
from numpy.testing import assert_equal, assert_raises


class TestAsIntegerRatio:
# derived in part from the cpython test "test_floatasratio"
1 change: 0 additions & 1 deletion numpy/core/tests/test_scalarbuffer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Test scalar buffer interface adheres to PEP 3118
"""
import sys
import numpy as np
import pytest

2 changes: 1 addition & 1 deletion numpy/core/tests/test_scalarprint.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

from tempfile import TemporaryFile
import numpy as np
from numpy.testing import assert_, assert_equal, suppress_warnings
from numpy.testing import assert_, assert_equal

class TestRealScalars:
def test_str(self):
1 change: 0 additions & 1 deletion numpy/core/tests/test_shape_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
import sys
import numpy as np
from numpy.core import (
array, arange, atleast_1d, atleast_2d, atleast_3d, block, vstack, hstack,
2 changes: 0 additions & 2 deletions numpy/core/tests/test_unicode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import numpy as np
from numpy.compat import unicode
from numpy.testing import assert_, assert_equal, assert_array_equal
1 change: 0 additions & 1 deletion numpy/distutils/ccompiler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import re
import sys
import types
import shlex
import time
import subprocess
1 change: 0 additions & 1 deletion numpy/lib/_datasource.py
Original file line number Diff line number Diff line change
@@ -36,7 +36,6 @@
"""
import os
import sys
import warnings
import shutil
import io
from contextlib import closing
2 changes: 1 addition & 1 deletion numpy/lib/format.py
Original file line number Diff line number Diff line change
@@ -599,7 +599,7 @@ def _read_array_header(fp, version):
raise ValueError(msg.format(d['fortran_order']))
try:
dtype = descr_to_dtype(d['descr'])
except TypeError as e:
except TypeError:
msg = "descr is not a valid dtype descriptor: {!r}"
raise ValueError(msg.format(d['descr']))

5 changes: 1 addition & 4 deletions numpy/lib/tests/test__datasource.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import os
import sys
import pytest
from tempfile import mkdtemp, mkstemp, NamedTemporaryFile
from shutil import rmtree

import numpy.lib._datasource as datasource
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_warns
)
from numpy.testing import assert_, assert_equal, assert_raises

import urllib.request as urllib_request
from urllib.parse import urlparse
1 change: 0 additions & 1 deletion numpy/lib/tests/test_mixins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numbers
import operator
import sys

import numpy as np
from numpy.testing import assert_, assert_equal, assert_raises
1 change: 0 additions & 1 deletion numpy/lib/tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys

import numpy as np
from numpy.testing import (
2 changes: 0 additions & 2 deletions numpy/polynomial/chebyshev.py
Original file line number Diff line number Diff line change
@@ -87,7 +87,6 @@
(preprint: https://www.math.hmc.edu/~benjamin/papers/CombTrig.pdf, pg. 4)
"""
import warnings
import numpy as np
import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index
@@ -1058,7 +1057,6 @@ def chebint(c, m=1, k=[], lbnd=0, scl=1, axis=0):
if n > 1:
tmp[2] = c[1]/4
for j in range(2, n):
t = c[j]/(2*j + 1) # FIXME: t never used
tmp[j + 1] = c[j]/(2*(j + 1))
tmp[j - 1] -= c[j]/(2*(j - 1))
tmp[0] += k[i] - chebval(lbnd, tmp)
1 change: 0 additions & 1 deletion numpy/polynomial/hermite.py
Original file line number Diff line number Diff line change
@@ -58,7 +58,6 @@
`numpy.polynomial`
"""
import warnings
import numpy as np
import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index
1 change: 0 additions & 1 deletion numpy/polynomial/hermite_e.py
Original file line number Diff line number Diff line change
@@ -58,7 +58,6 @@
`numpy.polynomial`
"""
import warnings
import numpy as np
import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index
1 change: 0 additions & 1 deletion numpy/polynomial/laguerre.py
Original file line number Diff line number Diff line change
@@ -58,7 +58,6 @@
`numpy.polynomial`
"""
import warnings
import numpy as np
import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index
1 change: 0 additions & 1 deletion numpy/polynomial/legendre.py
Original file line number Diff line number Diff line change
@@ -81,7 +81,6 @@
numpy.polynomial.hermite_e
"""
import warnings
import numpy as np
import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index
1 change: 0 additions & 1 deletion numpy/polynomial/polynomial.py
Original file line number Diff line number Diff line change
@@ -62,7 +62,6 @@
'polyfit', 'polytrim', 'polyroots', 'Polynomial', 'polyval2d', 'polyval3d',
'polygrid2d', 'polygrid3d', 'polyvander2d', 'polyvander3d']

import warnings
import numpy as np
import numpy.linalg as la
from numpy.core.multiarray import normalize_axis_index

0 comments on commit 021163b

Please sign in to comment.