diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2015-07-25 17:52:48 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-07-25 18:07:23 -0600 |
commit | 0d9dae2e89406e63679bc6a2bd65d50150a24a54 (patch) | |
tree | 1ac4671f5e300051e1027adbbbe01039b1c14ff8 /numpy/tests | |
parent | fd79f6900717ff312497d71c64817226f494cb19 (diff) | |
download | numpy-0d9dae2e89406e63679bc6a2bd65d50150a24a54.tar.gz |
STY: PEP8 and pyflakes fixes for numpy/tests.
Diffstat (limited to 'numpy/tests')
-rw-r--r-- | numpy/tests/test_ctypeslib.py | 36 | ||||
-rw-r--r-- | numpy/tests/test_matlib.py | 18 |
2 files changed, 29 insertions, 25 deletions
diff --git a/numpy/tests/test_ctypeslib.py b/numpy/tests/test_ctypeslib.py index 8e9c6c0bd..5e888eb65 100644 --- a/numpy/tests/test_ctypeslib.py +++ b/numpy/tests/test_ctypeslib.py @@ -5,7 +5,7 @@ import sys import numpy as np from numpy.ctypeslib import ndpointer, load_library from numpy.distutils.misc_util import get_shared_lib_extension -from numpy.testing import * +from numpy.testing import TestCase, run_module_suite, dec try: cdll = load_library('multiarray', np.core.multiarray.__file__) @@ -14,32 +14,36 @@ except ImportError: _HAS_CTYPE = False class TestLoadLibrary(TestCase): - @dec.skipif(not _HAS_CTYPE, "ctypes not available on this python installation") - @dec.knownfailureif(sys.platform=='cygwin', "This test is known to fail on cygwin") + @dec.skipif(not _HAS_CTYPE, + "ctypes not available on this python installation") + @dec.knownfailureif(sys.platform == + 'cygwin', "This test is known to fail on cygwin") def test_basic(self): try: - cdll = load_library('multiarray', - np.core.multiarray.__file__) + # Should succeed + load_library('multiarray', np.core.multiarray.__file__) except ImportError as e: - msg = "ctypes is not available on this python: skipping the test" \ - " (import error was: %s)" % str(e) + msg = ("ctypes is not available on this python: skipping the test" + " (import error was: %s)" % str(e)) print(msg) - @dec.skipif(not _HAS_CTYPE, "ctypes not available on this python installation") - @dec.knownfailureif(sys.platform=='cygwin', "This test is known to fail on cygwin") + @dec.skipif(not _HAS_CTYPE, + "ctypes not available on this python installation") + @dec.knownfailureif(sys.platform == + 'cygwin', "This test is known to fail on cygwin") def test_basic2(self): - """Regression for #801: load_library with a full library name - (including extension) does not work.""" + # Regression for #801: load_library with a full library name + # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) - cdll = load_library('multiarray%s' % so, - np.core.multiarray.__file__) + # Should succeed + load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: - msg = "ctypes is not available on this python: skipping the test" \ - " (import error was: %s)" % str(e) + msg = ("ctypes is not available on this python: skipping the test" + " (import error was: %s)" % str(e)) print(msg) class TestNdpointer(TestCase): @@ -57,7 +61,7 @@ class TestNdpointer(TestCase): np.array([1], dt.newbyteorder('swap'))) dtnames = ['x', 'y'] dtformats = [np.intc, np.float64] - dtdescr = {'names' : dtnames, 'formats' : dtformats} + dtdescr = {'names': dtnames, 'formats': dtformats} dt = np.dtype(dtdescr) p = ndpointer(dtype=dt) self.assertTrue(p.from_param(np.zeros((10,), dt))) diff --git a/numpy/tests/test_matlib.py b/numpy/tests/test_matlib.py index 0bc8548ba..3ff6cd7ed 100644 --- a/numpy/tests/test_matlib.py +++ b/numpy/tests/test_matlib.py @@ -5,36 +5,36 @@ import numpy.matlib from numpy.testing import assert_array_equal, assert_, run_module_suite def test_empty(): - x = np.matlib.empty((2,)) + x = numpy.matlib.empty((2,)) assert_(isinstance(x, np.matrix)) assert_(x.shape, (1, 2)) def test_ones(): - assert_array_equal(np.matlib.ones((2, 3)), + assert_array_equal(numpy.matlib.ones((2, 3)), np.matrix([[ 1., 1., 1.], [ 1., 1., 1.]])) - assert_array_equal(np.matlib.ones(2), np.matrix([[ 1., 1.]])) + assert_array_equal(numpy.matlib.ones(2), np.matrix([[ 1., 1.]])) def test_zeros(): - assert_array_equal(np.matlib.zeros((2, 3)), + assert_array_equal(numpy.matlib.zeros((2, 3)), np.matrix([[ 0., 0., 0.], [ 0., 0., 0.]])) - assert_array_equal(np.matlib.zeros(2), np.matrix([[ 0., 0.]])) + assert_array_equal(numpy.matlib.zeros(2), np.matrix([[ 0., 0.]])) def test_identity(): - x = np.matlib.identity(2, dtype=np.int) + x = numpy.matlib.identity(2, dtype=np.int) assert_array_equal(x, np.matrix([[1, 0], [0, 1]])) def test_eye(): - x = np.matlib.eye(3, k=1, dtype=int) + x = numpy.matlib.eye(3, k=1, dtype=int) assert_array_equal(x, np.matrix([[ 0, 1, 0], [ 0, 0, 1], [ 0, 0, 0]])) def test_rand(): - x = np.matlib.rand(3) + x = numpy.matlib.rand(3) # check matrix type, array would have shape (3,) assert_(x.ndim == 2) @@ -45,7 +45,7 @@ def test_randn(): def test_repmat(): a1 = np.arange(4) - x = np.matlib.repmat(a1, 2, 2) + x = numpy.matlib.repmat(a1, 2, 2) y = np.array([[0, 1, 2, 3, 0, 1, 2, 3], [0, 1, 2, 3, 0, 1, 2, 3]]) assert_array_equal(x, y) |