Commits

Anonymous committed 6adc66b

add test_repr for 3-dim array

  • Participants
  • Parent commits 0d9e53f
  • Branches numpy-multidim

Comments (0)

Files changed (2)

File pypy/module/micronumpy/interp_numarray.py

         if ndims>2:
             ret += '['
             for i in range(self.shape[0]):
-                ret += NDimSlice(self.parent, self.signature, [(i,0,0,1)], self.shape[1:]).tostr(commai,indent=indent+' ')
+                ret += NDimSlice(self.parent, self.signature, [(i,0,0,1)], self.shape[1:]).tostr(comma,indent=indent+' ')
                 if i+1<self.shape[0]:
-                    ret += ',\n\n'
+                    ret += ',\n\n'+ indent
             ret += ']'
         elif ndims==2:
             ret += '['

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

         assert repr(a) == '''array([[0.0, 0.0, 0.0, 0.0],
        [0.0, 0.0, 0.0, 0.0],
        [0.0, 0.0, 0.0, 0.0]])'''
+        a = zeros((2,3,4))
+        assert repr(a) == '''array([[[0.0, 0.0, 0.0, 0.0],
+        [0.0, 0.0, 0.0, 0.0],
+        [0.0, 0.0, 0.0, 0.0]],
+
+       [[0.0, 0.0, 0.0, 0.0],
+        [0.0, 0.0, 0.0, 0.0],
+        [0.0, 0.0, 0.0, 0.0]]])'''
 
     def test_repr_slice(self):
         from numpy import array, zeros
         a[1:4:2] = 0.
         assert a[1] == 0.
         assert a[3] == 0.
+    def test_scalar(self):
+        from numpy import array
+        a = array(3)
+        assert a[0] == 3 
 
     def test_len(self):
         from numpy import array