Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ hg diff test_numeric.py
- diff -r 9698baa9d6b5 pypy/module/test_lib_pypy/numpypy/core/test_numeric.py
- --- a/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py Thu Jan 26 19:13:20 2012 +0200
- +++ b/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py Thu Jan 26 21:27:06 2012 +0200
- @@ -142,3 +142,77 @@
- assert str(b) == "[7 8 9]"
- b = a[2:1, ]
- assert str(b) == "[]"
- +
- +class AppTestConcatenation(BaseNumpyAppTest):
- + def test_hstack(self):
- + import numpypy as np
- + a = np.array((1,2,3))
- + b = np.array((2,3,4))
- + assert all(np.hstack((a,b))== np.array([1, 2, 3, 2, 3, 4]))
- + a = np.array([[1],[2],[3]])
- + b = np.array([[2],[3],[4]])
- + assert np.all(np.hstack((a,b)) == np.array([
- + [1, 2],
- + [2, 3],
- + [3, 4]
- + ]))
- + for shape1, shape2 in [[(1, 2), (1, 3)], [(4, 2), [4, 3]]]:
- + a, b = np.ones(shape1), np.ones(shape2)
- + assert np.all(np.hstack((a, b)) == np.ones((a.shape[0], a.shape[1]+b.shape[1])))
- + for shape1, shape2 in [[(2, 3, 4), (2, 7, 4)], [(1, 4, 7), (1, 10, 7)], [(1, 4, 7), (1, 0, 7)], [(1, 0, 7), (1, 0, 7)]]:
- + a, b = np.ones(shape1), np.ones(shape2)
- + assert np.all(np.hstack((a, b)) == np.ones((a.shape[0], a.shape[1]+b.shape[1], a.shape[2])))
- +
- + def test_vstack(self):
- + import numpypy as np
- + a = np.array([1, 2, 3])
- + b = np.array([2, 3, 4])
- + assert np.all(np.vstack((a,b)) == np.array([
- + [1, 2, 3],
- + [2, 3, 4]
- + ]))
- +
- + a = np.array([[1], [2], [3]])
- + b = np.array([[2], [3], [4]])
- + assert np.all(np.vstack((a,b)) == np.array([
- + [1],
- + [2],
- + [3],
- + [2],
- + [3],
- + [4]
- + ]))
- +
- + for shape1, shape2 in [[(2, 1), (3, 1)], [(2, 4), [3, 4]]]:
- + a, b = np.ones(shape1), np.ones(shape2)
- + assert np.all(np.vstack((a, b)) == np.ones((a.shape[0]+b.shape[0], a.shape[1])))
- + for shape1, shape2 in [[(3, 2, 4), (7, 2, 4)], [(0, 2, 7), (10, 2, 7)], [(0, 2, 7), (0, 2, 7)]]:
- + a, b = np.ones(shape1), np.ones(shape2)
- + assert np.all(np.vstack((a, b)) == np.ones((a.shape[0]+b.shape[0], a.shape[1], a.shape[2])))
- +
- + def test_dstack(self):
- + import numpypy as np
- + a = np.array((1,2,3))
- + b = np.array((2,3,4))
- + assert np.all(np.dstack((a,b)) == np.array([[
- + [1, 2],
- + [2, 3],test_stac&ks.py
- + [3, 4]
- + ]]))
- + a = np.array([[1],[2],[3]])
- + b = np.array([[2],[3],[4]])
- + assert np.all(np.dstack((a,b)) == np.array([
- + [[1, 2]],
- + [[2, 3]],
- + [[3, 4]]
- + ]))
- + for shape1, shape2 in [[(4, 2, 3), (4, 2, 7)], [(7, 2, 0), (7, 2, 10)], [(7, 2, 0), (7, 2, 0)]]:
- + a, b = np.ones(shape1), np.ones(shape2)
- + assert np.all(np.dstack((a, b)) == np.ones((a.shape[0], a.shape[1], a.shape[2]+b.shape[2])))
- +
- + for shape1, shape2 in [[(4, 2, 3, 5), (4, 2, 7, 5)], [(7, 2, 0, 5), (7, 2, 10, 5)], [(7, 2, 0, 5), (7, 2, 0, 5)]]:
- + a, b = np.ones(shape1), np.ones(shape2)
- + assert np.all(np.dstack((a, b)) == np.ones((a.shape[0], a.shape[1], a.shape[2]+b.shape[2], a.shape[3])))
- +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement