[pypy-commit] pypy numpypy-ctypes: fix translation.

alex_gaynor noreply at buildbot.pypy.org
Sat Feb 18 18:48:46 CET 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: numpypy-ctypes
Changeset: r52617:36d4deeac481
Date: 2012-02-18 12:48 -0500
http://bitbucket.org/pypy/pypy/changeset/36d4deeac481/

Log:	fix translation.

diff --git a/pypy/module/micronumpy/appbridge.py b/pypy/module/micronumpy/appbridge.py
--- a/pypy/module/micronumpy/appbridge.py
+++ b/pypy/module/micronumpy/appbridge.py
@@ -1,6 +1,11 @@
 
 from pypy.rlib.objectmodel import specialize
 
+
+ at specialize.memo()
+def get_module_attr(module):
+    return "w_" + module.replace(".", "_") + "_module"
+
 class AppBridgeCache(object):
     w_numpypy_core__methods_module = None
     w__var = None
@@ -22,7 +27,7 @@
 
     @specialize.arg(2, 3)
     def call_method(self, space, module, name, *args):
-        module_attr = "w_" + module.replace(".", "_") + "_module"
+        module_attr = get_module_attr(module)
         meth_attr = "w_" + name
         w_meth = getattr(self, meth_attr)
         if w_meth is None:
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -258,7 +258,8 @@
 
     @jit.unroll_safe
     def descr_get_strides(self, space):
-        return space.newtuple([space.wrap(i) for i in self.strides])
+        concrete = self.get_concrete()
+        return space.newtuple([space.wrap(i) for i in concrete.strides])
 
     def descr_get_size(self, space):
         return space.wrap(self.size)
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
@@ -1710,10 +1710,9 @@
         raises(ValueError, "array(5).item(1)")
 
     def test_ctypes(self):
-        import gc
         from _numpypy import array
 
-        a = array([1, 2, 3, 4, 5])
+        a = array([1, 2, 3, 4, 5.0])
         assert a.ctypes._data == a.__array_interface__["data"][0]
         assert a is a.ctypes._arr
 
@@ -1725,6 +1724,15 @@
         assert len(strides) == 1
         assert strides[0] == 1
 
+        b = a[2:]
+        assert b.ctypes._data == a.ctypes._data
+        b.ctypes.get_strides()
+        b.ctypes.get_shape()
+
+        c = b + b
+        c.ctypes.get_strides()
+        c.ctypes.get_shape()
+
         a = array(2)
         raises(TypeError, lambda: a.ctypes)
 


More information about the pypy-commit mailing list