Commits

Justin Peel  committed db7b9b0

fix a bug in to_str for ndim=1, size=1 arrays. also affected any multi-dim array where the last dimension is 1. tests included.

  • Participants
  • Parent commits 07bd76d

Comments (0)

Files changed (2)

File pypy/module/micronumpy/interp_numarray.py

         if size < 1:
             builder.append('[]')
             return
-        elif size == 1:
-            builder.append(dtype.itemtype.str_format(self.getitem(0)))
-            return
         if size > 1000:
             # Once this goes True it does not go back to False for recursive
             # calls
             use_ellipsis = True
         ndims = len(self.shape)
+        if ndims == 0:
+            builder.append(dtype.itemtype.str_format(self.getitem(0)))
+            return
         i = 0
         builder.append('[')
         if ndims > 1:

File pypy/module/micronumpy/test/test_numarray.py

         assert repr(a) == "array(0.0)"
         a = array(0.2)
         assert repr(a) == "array(0.2)"
+        a = array([2])
+        assert repr(a) == "array([2])"
 
     def test_repr_multi(self):
-        from _numpypy import arange, zeros
+        from _numpypy import arange, zeros, array
         a = zeros((3, 4))
         assert repr(a) == '''array([[0.0, 0.0, 0.0, 0.0],
        [0.0, 0.0, 0.0, 0.0],
        [498, 999],
        [499, 1000],
        [500, 1001]])'''
+        a = arange(2).reshape((2,1))
+        assert repr(a) == '''array([[0],
+       [1]])'''
 
     def test_repr_slice(self):
         from _numpypy import array, zeros