Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r68413:caa5f3b6bf46
Date: 2013-12-12 21:38 -0500
http://bitbucket.org/pypy/pypy/changeset/caa5f3b6bf46/

Log:    test/fix ndarray.__new__ passing array as buffer

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
@@ -502,3 +502,6 @@
 
     def getlength(self):
         return self.impl.size
+
+    def get_raw_address(self):
+        return self.impl.storage
diff --git a/pypy/module/micronumpy/test/test_subtype.py 
b/pypy/module/micronumpy/test/test_subtype.py
--- a/pypy/module/micronumpy/test/test_subtype.py
+++ b/pypy/module/micronumpy/test/test_subtype.py
@@ -62,6 +62,11 @@
         assert isinstance(b, matrix)
         assert (b == a).all()
 
+    def test_subtype_like_matrix(self):
+        import numpy as np
+        arr = np.array([1,2,3])
+        ret = np.ndarray.__new__(np.ndarray, arr.shape, arr.dtype, buffer=arr)
+        assert (arr == ret).all()
 
     def test_finalize(self):
         #taken from 
http://docs.scipy.org/doc/numpy/user/basics.subclassing.html#simple-example-adding-an-extra-attribute-to-ndarray
@@ -245,4 +250,3 @@
             assert isinstance(b, D)
         c = array(a, float)
         assert c.dtype is dtype(float)
-
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to