[pypy-commit] pypy default: numpy: some tests for slices

snus_mumrik noreply at buildbot.pypy.org
Mon Jun 13 09:44:24 CEST 2011


Author: Ilya Osadchiy <osadchiy.ilya at gmail.com>
Branch: 
Changeset: r44898:f67feab0137f
Date: 2011-06-03 00:09 +0300
http://bitbucket.org/pypy/pypy/changeset/f67feab0137f/

Log:	numpy: some tests for slices

diff --git a/pypy/module/micronumpy/test/test_base.py b/pypy/module/micronumpy/test/test_base.py
--- a/pypy/module/micronumpy/test/test_base.py
+++ b/pypy/module/micronumpy/test/test_base.py
@@ -16,4 +16,4 @@
         v3 = ar.descr_add(space, FloatWrapper(1.0))
         assert v2.signature is v3.signature
         v4 = ar.descr_add(space, ar)
-        assert v1.signature is v4.signature
\ No newline at end of file
+        assert v1.signature is v4.signature
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
@@ -138,4 +138,46 @@
         b = a + a
         c = b + b
         b[1] = 5
-        assert c[1] == 4
\ No newline at end of file
+        assert c[1] == 4
+
+    def test_getslice(self):
+        from numpy import array
+        a = array(range(5))
+        s = a[1:5]
+        assert len(s) == 4
+        for i in range(4):
+            assert s[i] == a[i+1]
+
+    def test_getslice_step(self):
+        from numpy import array
+        a = array(range(10))
+        s = a[1:9:2]
+        assert len(s) == 4
+        for i in range(4):
+            assert s[i] == a[2*i+1]
+        
+    def test_slice_update(self):
+        from numpy import array
+        a = array(range(5))
+        s = a[0:3]
+        s[1] = 10
+        assert a[1] == 10
+        a[2] = 20
+        assert s[2] == 20
+
+
+    def test_slice_invaidate(self):
+        # check that slice shares invalidation list with 
+        from numpy import array
+        a = array(range(5))
+        s = a[0:2]
+        b = array([10,11])
+        c = s + b
+        a[0]=100
+        assert c[0] == 10
+        assert c[1] == 12
+        d = s + b
+        a[1]=101
+        assert d[0] == 110
+        assert d[1] == 12
+


More information about the pypy-commit mailing list