[pypy-commit] pypy numpy-concatenate: Changed some variable names and added a couple more tests

jterrace noreply at buildbot.pypy.org
Wed Dec 14 23:01:28 CET 2011


Author: Jeff Terrace <jterrace at gmail.com>
Branch: numpy-concatenate
Changeset: r50523:083461b61320
Date: 2011-12-14 17:01 -0500
http://bitbucket.org/pypy/pypy/changeset/083461b61320/

Log:	Changed some variable names and added a couple more tests

diff --git a/pypy/module/micronumpy/app_numpy.py b/pypy/module/micronumpy/app_numpy.py
--- a/pypy/module/micronumpy/app_numpy.py
+++ b/pypy/module/micronumpy/app_numpy.py
@@ -55,13 +55,13 @@
     if len(arrays) == 0:
         raise ValueError("concatenation of zero-length sequences is impossible")
     
-    out_array = numpypy.zeros(shape)
+    out_array = numpypy.empty(shape)
     slicing_index = [slice(None)] * len(shape)
-    axis_ptr = 0
+    axis_start = 0
     for a in arrays:
-        slicing_index[axis] = slice(axis_ptr, axis_ptr + a.shape[axis])
+        slicing_index[axis] = slice(axis_start, axis_start + a.shape[axis])
         out_array[tuple(slicing_index)] = a
-        axis_ptr += a.shape[axis]
+        axis_start += a.shape[axis]
     
     return out_array
     
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -936,6 +936,14 @@
         assert (b == [[1, 2],[3, 4],[5, 6]]).all()
         c = concatenate((b1, b2.T), axis=1)
         assert (c == [[1, 2, 5],[3, 4, 6]]).all()
+        d = concatenate(([0],[1]))
+        assert (d == [0,1]).all()
+        e1 = array([[0,1],[2,3]])
+        e = concatenate(e1)
+        assert (e == [0,1,2,3]).all()
+        f1 = array([0,1])
+        f = concatenate((f1, [2], f1, [7]))
+        assert (f == [0,1,2,0,1,7]).all()
         
         bad_axis = raises(ValueError, concatenate, (a1,a2), axis=1)
         assert str(bad_axis.value) == "bad axis argument"


More information about the pypy-commit mailing list