summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_stride_tricks.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-09-02 13:21:48 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-09-03 05:22:10 -0600
commitd2c44c5a012d0a5db7d10a2586c8e9c58045d04b (patch)
treeb93306d17c5460a68d7e7fb29e6be729ad2a28dd /numpy/lib/tests/test_stride_tricks.py
parent57245e4570fa84f2e40a6fa1cc22716d279f8c00 (diff)
downloadnumpy-d2c44c5a012d0a5db7d10a2586c8e9c58045d04b.tar.gz
STY: Make numpy/lib/test/*.py PEP8 compliant.
Run autopep8 over the test files in numpy/lib/test and make fixes to the result. Also remove Python5 workaround.
Diffstat (limited to 'numpy/lib/tests/test_stride_tricks.py')
-rw-r--r--numpy/lib/tests/test_stride_tricks.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_stride_tricks.py b/numpy/lib/tests/test_stride_tricks.py
index 5d06e0a8c..4d57d2ca7 100644
--- a/numpy/lib/tests/test_stride_tricks.py
+++ b/numpy/lib/tests/test_stride_tricks.py
@@ -15,6 +15,7 @@ def assert_shapes_correct(input_shapes, expected_shape):
expected = [expected_shape] * len(inarrays)
assert_equal(outshapes, expected)
+
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.
@@ -22,6 +23,7 @@ def assert_incompatible_shapes_raise(input_shapes):
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.
@@ -51,6 +53,7 @@ def test_same():
assert_array_equal(x, bx)
assert_array_equal(y, by)
+
def test_one_off():
x = np.array([[1, 2, 3]])
y = np.array([[1], [2], [3]])
@@ -60,6 +63,7 @@ def test_one_off():
assert_array_equal(bx0, bx)
assert_array_equal(by0, by)
+
def test_same_input_shapes():
""" Check that the final shape is just the input shape.
"""
@@ -86,6 +90,7 @@ def test_same_input_shapes():
input_shapes3 = [shape, shape, shape]
assert_shapes_correct(input_shapes3, shape)
+
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.
@@ -110,6 +115,7 @@ def test_two_compatible_by_ones_input_shapes():
# Reverse the input shapes since broadcasting should be symmetric.
assert_shapes_correct(input_shapes[::-1], expected_shape)
+
def test_two_compatible_by_prepending_ones_input_shapes():
""" Check that two different input shapes (of different lengths) broadcast
to the correct shape.
@@ -141,6 +147,7 @@ def test_two_compatible_by_prepending_ones_input_shapes():
# Reverse the input shapes since broadcasting should be symmetric.
assert_shapes_correct(input_shapes[::-1], expected_shape)
+
def test_incompatible_shapes_raise_valueerror():
""" Check that a ValueError is raised for incompatible shapes.
"""
@@ -155,6 +162,7 @@ def test_incompatible_shapes_raise_valueerror():
# Reverse the input shapes since broadcasting should be symmetric.
assert_incompatible_shapes_raise(input_shapes[::-1])
+
def test_same_as_ufunc():
""" Check that the data layout is the same as if a ufunc did the operation.
"""
@@ -195,7 +203,7 @@ def test_same_as_ufunc():
]
for input_shapes, expected_shape in data:
assert_same_as_ufunc(input_shapes[0], input_shapes[1],
- "Shapes: %s %s" % (input_shapes[0], input_shapes[1]))
+ "Shapes: %s %s" % (input_shapes[0], input_shapes[1]))
# Reverse the input shapes since broadcasting should be symmetric.
assert_same_as_ufunc(input_shapes[1], input_shapes[0])
# Try them transposed, too.