[pypy-commit] pypy ndarray-view: test view shape changes

mattip noreply at buildbot.pypy.org
Fri Jun 28 14:40:41 CEST 2013


Author: Matti Picus <matti.picus at gmail.com>
Branch: ndarray-view
Changeset: r65058:050f965366b8
Date: 2013-06-28 13:48 +0300
http://bitbucket.org/pypy/pypy/changeset/050f965366b8/

Log:	test view shape changes

diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py b/pypy/module/micronumpy/arrayimpl/concrete.py
--- a/pypy/module/micronumpy/arrayimpl/concrete.py
+++ b/pypy/module/micronumpy/arrayimpl/concrete.py
@@ -75,6 +75,10 @@
         else:
             return None
 
+    def get_view(self, dtype, new_shape):
+        pass
+        #return SliceArray(self.start,
+
     def get_real(self, orig_array):
         strides = self.get_strides()
         backstrides = self.get_backstrides()
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
@@ -1428,6 +1428,12 @@
         exc = raises(TypeError, s.view, dtype='int8')
         assert exc.value[0] == "view() takes no keyword arguments"
         assert s.view('double') < 7e-323
+        x = array(range(15), dtype='int16').reshape(3,5)
+        exc = raises(ValueError, x.view, dtype='int32')
+        assert exc.value[0] == "new type not compatible with array."
+        assert x.view('int8').shape == (3, 10)
+        x = array(range(15), dtype='int16').reshape(3,5).T
+        assert x.view('int8').shape == (10, 3)
 
     def test_tolist_scalar(self):
         from numpypy import int32, bool_


More information about the pypy-commit mailing list