summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_stride_tricks.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-07-30 14:17:00 -0600
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-07-31 21:07:59 +0200
commitb2955ede452b8ca2aae5d0b035cd19c8a3b12480 (patch)
tree9650423c39ce77ba9831751094087d3c14687a5b /numpy/lib/tests/test_stride_tricks.py
parent778af02eb7c1668e751f435cd2a4952a362a0433 (diff)
downloadnumpy-b2955ede452b8ca2aae5d0b035cd19c8a3b12480.tar.gz
MAINT: Fix problems noted by pyflakes in numpy/lib/tests.
Diffstat (limited to 'numpy/lib/tests/test_stride_tricks.py')
-rw-r--r--numpy/lib/tests/test_stride_tricks.py50
1 files changed, 26 insertions, 24 deletions
diff --git a/numpy/lib/tests/test_stride_tricks.py b/numpy/lib/tests/test_stride_tricks.py
index 3adcf0b41..cd0973300 100644
--- a/numpy/lib/tests/test_stride_tricks.py
+++ b/numpy/lib/tests/test_stride_tricks.py
@@ -1,15 +1,17 @@
from __future__ import division, absolute_import, print_function
import numpy as np
-from numpy.testing import *
-from numpy.lib.stride_tricks import broadcast_arrays
-from numpy.lib.stride_tricks import as_strided
+from numpy.testing import (
+ run_module_suite, assert_equal, assert_array_equal,
+ assert_raises
+ )
+from numpy.lib.stride_tricks import as_strided, broadcast_arrays
def assert_shapes_correct(input_shapes, expected_shape):
- """ Broadcast a list of arrays with the given input shapes and check the
- common output shape.
- """
+ # Broadcast a list of arrays with the given input shapes and check the
+ # common output shape.
+
inarrays = [np.zeros(s) for s in input_shapes]
outarrays = broadcast_arrays(*inarrays)
outshapes = [a.shape for a in outarrays]
@@ -18,17 +20,17 @@ def assert_shapes_correct(input_shapes, expected_shape):
def assert_incompatible_shapes_raise(input_shapes):
- """ Broadcast a list of arrays with the given (incompatible) input shapes
- and check that they raise a ValueError.
- """
+ # Broadcast a list of arrays with the given (incompatible) input shapes
+ # and check that they raise a ValueError.
+
inarrays = [np.zeros(s) for s in input_shapes]
assert_raises(ValueError, broadcast_arrays, *inarrays)
def assert_same_as_ufunc(shape0, shape1, transposed=False, flipped=False):
- """ Broadcast two shapes against each other and check that the data layout
- is the same as if a ufunc did the broadcasting.
- """
+ # Broadcast two shapes against each other and check that the data layout
+ # is the same as if a ufunc did the broadcasting.
+
x0 = np.zeros(shape0, dtype=int)
# Note that multiply.reduce's identity element is 1.0, so when shape1==(),
# this gives the desired n==1.
@@ -66,8 +68,8 @@ def test_one_off():
def test_same_input_shapes():
- """ Check that the final shape is just the input shape.
- """
+ # Check that the final shape is just the input shape.
+
data = [
(),
(1,),
@@ -93,9 +95,9 @@ def test_same_input_shapes():
def test_two_compatible_by_ones_input_shapes():
- """ Check that two different input shapes (of the same length but some have
- 1s) broadcast to the correct shape.
- """
+ # Check that two different input shapes of the same length, but some have
+ # ones, broadcast to the correct shape.
+
data = [
[[(1,), (3,)], (3,)],
[[(1, 3), (3, 3)], (3, 3)],
@@ -118,9 +120,9 @@ def test_two_compatible_by_ones_input_shapes():
def test_two_compatible_by_prepending_ones_input_shapes():
- """ Check that two different input shapes (of different lengths) broadcast
- to the correct shape.
- """
+ # Check that two different input shapes (of different lengths) broadcast
+ # to the correct shape.
+
data = [
[[(), (3,)], (3,)],
[[(3,), (3, 3)], (3, 3)],
@@ -150,8 +152,8 @@ def test_two_compatible_by_prepending_ones_input_shapes():
def test_incompatible_shapes_raise_valueerror():
- """ Check that a ValueError is raised for incompatible shapes.
- """
+ # Check that a ValueError is raised for incompatible shapes.
+
data = [
[(3,), (4,)],
[(2, 3), (2,)],
@@ -165,8 +167,8 @@ def test_incompatible_shapes_raise_valueerror():
def test_same_as_ufunc():
- """ Check that the data layout is the same as if a ufunc did the operation.
- """
+ # Check that the data layout is the same as if a ufunc did the operation.
+
data = [
[[(1,), (3,)], (3,)],
[[(1, 3), (3, 3)], (3, 3)],