[pypy-commit] pypy numpy-dtype-alt: another test_zjit test passing.

alex_gaynor noreply at buildbot.pypy.org
Mon Aug 22 06:13:08 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: numpy-dtype-alt
Changeset: r46694:d8e0d3c9b375
Date: 2011-08-21 23:18 -0500
http://bitbucket.org/pypy/pypy/changeset/d8e0d3c9b375/

Log:	another test_zjit test passing.

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
@@ -403,10 +403,12 @@
         return self.res_dtype
 
     def _eval(self, i):
+        val = self.values.eval(i).convert_to(self.res_dtype)
+
         sig = jit.promote(self.signature)
+        assert isinstance(sig, signature.Signature)
         call_sig = sig.components[0]
         assert isinstance(call_sig, signature.Call1)
-        val = self.values.eval(i).convert_to(self.res_dtype)
         return call_sig.func(self.res_dtype, val)
 
 class Call2(VirtualArray):
@@ -432,7 +434,9 @@
     def _eval(self, i):
         lhs = self.left.eval(i).convert_to(self.res_dtype)
         rhs = self.right.eval(i).convert_to(self.res_dtype)
+
         sig = jit.promote(self.signature)
+        assert isinstance(sig, signature.Signature)
         call_sig = sig.components[0]
         assert isinstance(call_sig, signature.Call2)
         return call_sig.func(self.res_dtype, lhs, rhs)
diff --git a/pypy/module/micronumpy/signature.py b/pypy/module/micronumpy/signature.py
--- a/pypy/module/micronumpy/signature.py
+++ b/pypy/module/micronumpy/signature.py
@@ -18,6 +18,8 @@
     return res
 
 class BaseSignature(object):
+    _attrs_ = []
+
     def eq(self, other):
         return self is other
 
@@ -27,6 +29,7 @@
 class Signature(BaseSignature):
     _known_sigs = r_dict(components_eq, components_hash)
 
+    _attrs_ = ["components"]
     _immutable_fields_ = ["components[*]"]
 
     def __init__(self, components):
diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -1,9 +1,10 @@
-from pypy.interpreter.baseobjspace import InternalSpaceCache
+from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
 from pypy.jit.metainterp.test.support import LLJitMixin
 from pypy.module.micronumpy import interp_ufuncs, signature
 from pypy.module.micronumpy.compile import numpy_compile
 from pypy.module.micronumpy.interp_dtype import W_Float64Dtype
-from pypy.module.micronumpy.interp_numarray import SingleDimArray, SingleDimSlice, scalar_w
+from pypy.module.micronumpy.interp_numarray import (BaseArray, SingleDimArray,
+    SingleDimSlice, scalar_w)
 from pypy.rlib.nonconst import NonConstant
 from pypy.rlib.objectmodel import specialize
 from pypy.rpython.test.test_llinterp import interpret
@@ -19,14 +20,21 @@
         return True
 
     @specialize.argtype(1)
-    def wrap(self, w_obj):
+    def wrap(self, obj):
+        if isinstance(obj, float):
+            return FloatObject(obj)
+        raise Exception
+
+    def float(self, w_obj):
+        assert isinstance(w_obj, FloatObject)
         return w_obj
 
-    def float(self, w_obj):
-        return float(w_obj)
+    def float_w(self, w_obj):
+        return w_obj.floatval
 
-    def float_w(self, w_obj):
-        return float(w_obj)
+class FloatObject(W_Root):
+    def __init__(self, floatval):
+        self.floatval = floatval
 
 class TestNumpyJIt(LLJitMixin):
     def setup_class(cls):
@@ -48,7 +56,11 @@
     def test_floatadd(self):
         def f(i):
             ar = SingleDimArray(i, dtype=self.float64_dtype)
-            v = interp_ufuncs.add(self.space, ar, scalar_w(self.space, W_Float64Dtype, 4.5))
+            v = interp_ufuncs.add(self.space,
+                ar,
+                scalar_w(self.space, W_Float64Dtype, self.space.wrap(4.5))
+            )
+            assert isinstance(v, BaseArray)
             return v.get_concrete().eval(3).val
 
         result = self.meta_interp(f, [5], listops=True, backendopt=True)


More information about the pypy-commit mailing list