Author: Antonio Cuni <[email protected]>
Branch: 
Changeset: r60258:c08bafe19961
Date: 2013-01-20 16:21 +0100
http://bitbucket.org/pypy/pypy/changeset/c08bafe19961/

Log:    implement .strides for scalars

diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py 
b/pypy/module/micronumpy/arrayimpl/scalar.py
--- a/pypy/module/micronumpy/arrayimpl/scalar.py
+++ b/pypy/module/micronumpy/arrayimpl/scalar.py
@@ -34,6 +34,9 @@
     def get_shape(self):
         return []
 
+    def get_strides(self):
+        return ()
+
     def create_iter(self, shape=None):
         return ScalarIterator(self.value)
 
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
@@ -689,6 +689,12 @@
         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
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to