Commits

Antonio Cuni committed c08bafe

implement .strides for scalars

Comments (0)

Files changed (2)

pypy/module/micronumpy/arrayimpl/scalar.py

     def get_shape(self):
         return []
 
+    def get_strides(self):
+        return ()
+
     def create_iter(self, shape=None):
         return ScalarIterator(self.value)
 

pypy/module/micronumpy/test/test_numarray.py

         a = array([[1.0, 2.0],
                    [3.0, 4.0]])
         assert a.strides == (16, 8)
+        assert a[1:].strides == (16, 8)
+
+    def test_strides_scalar(self):
+        from _numpypy import array
+        a = array(42)
+        assert a.strides == ()
 
     def test_add(self):
         from _numpypy import array