[pypy-commit] pypy numpy-minilang: pass the test_zjit finally
fijal
noreply at buildbot.pypy.org
Thu Oct 27 23:32:12 CEST 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-minilang
Changeset: r48543:f1d8e024a3ed
Date: 2011-10-27 23:31 +0200
http://bitbucket.org/pypy/pypy/changeset/f1d8e024a3ed/
Log: pass the test_zjit finally
diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -37,6 +37,9 @@
def issequence_w(self, w_obj):
return w_obj.seq
+ def isinstance_w(self, w_obj, w_tp):
+ return False
+
@specialize.argtype(1)
def wrap(self, obj):
if isinstance(obj, float):
@@ -87,6 +90,7 @@
@specialize.arg(1)
def interp_w(self, tp, what):
+ assert isinstance(what, tp)
return what
class FloatObject(W_Root):
@@ -176,7 +180,8 @@
if isinstance(w_rhs, Scalar):
index = int(interp.space.float_w(
w_rhs.value.wrap(interp.space)))
- return w_lhs.get_concrete().eval(index)
+ dtype = interp.space.fromcache(W_Float64Dtype)
+ return Scalar(dtype, w_lhs.get_concrete().eval(index))
else:
raise NotImplementedError
else:
@@ -204,6 +209,12 @@
def __init__(self, v):
self.v = int(v)
+ def execute(self, interp):
+ w_list = interp.space.newlist(
+ [interp.space.wrap(float(i)) for i in range(self.v)])
+ dtype = interp.space.fromcache(W_Float64Dtype)
+ return descr_new_array(interp.space, None, w_list, w_dtype=dtype)
+
def __repr__(self):
return 'Range(%s)' % self.v
@@ -223,7 +234,8 @@
def execute(self, interp):
w_list = self.wrap(interp.space)
- return descr_new_array(interp.space, None, w_list)
+ dtype = interp.space.fromcache(W_Float64Dtype)
+ return descr_new_array(interp.space, None, w_list, w_dtype=dtype)
def __repr__(self):
return "[" + ", ".join([repr(item) for item in self.items]) + "]"
diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -236,22 +236,20 @@
return dt
def find_dtype_for_scalar(space, w_obj, current_guess=None):
- w_type = space.type(w_obj)
-
bool_dtype = space.fromcache(interp_dtype.W_BoolDtype)
long_dtype = space.fromcache(interp_dtype.W_LongDtype)
int64_dtype = space.fromcache(interp_dtype.W_Int64Dtype)
- if space.is_w(w_type, space.w_bool):
+ if space.isinstance_w(w_obj, space.w_bool):
if current_guess is None or current_guess is bool_dtype:
return bool_dtype
return current_guess
- elif space.is_w(w_type, space.w_int):
+ elif space.isinstance_w(w_obj, space.w_int):
if (current_guess is None or current_guess is bool_dtype or
current_guess is long_dtype):
return long_dtype
return current_guess
- elif space.is_w(w_type, space.w_long):
+ elif space.isinstance_w(w_obj, space.w_long):
if (current_guess is None or current_guess is bool_dtype or
current_guess is long_dtype or current_guess is int64_dtype):
return int64_dtype
diff --git a/pypy/module/micronumpy/test/test_compile.py b/pypy/module/micronumpy/test/test_compile.py
--- a/pypy/module/micronumpy/test/test_compile.py
+++ b/pypy/module/micronumpy/test/test_compile.py
@@ -112,5 +112,12 @@
a + b -> 3
"""
interp = self.run(code)
- assert interp.results[0].val == 3 + 6
+ assert interp.results[0].value.val == 3 + 6
+ def test_range_getitem(self):
+ code = """
+ r = |20|
+ r -> 3
+ """
+ interp = self.run(code)
+ assert interp.results[0].value.val == 3
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
@@ -4,7 +4,7 @@
FloatObject, IntObject, Parser)
from pypy.module.micronumpy.interp_dtype import W_Int32Dtype, W_Float64Dtype, W_Int64Dtype, W_UInt64Dtype
from pypy.module.micronumpy.interp_numarray import (BaseArray, SingleDimArray,
- SingleDimSlice, scalar_w)
+ SingleDimSlice, scalar_w, Scalar)
from pypy.rlib.nonconst import NonConstant
from pypy.rpython.annlowlevel import llstr
from pypy.rpython.test.test_llinterp import interpret
@@ -17,6 +17,8 @@
# trick annotator
c = """
a = 3
+ b = [1,2] + [3,4]
+ c = a
"""
space = FakeSpace()
@@ -26,7 +28,9 @@
def f(i):
interp = InterpreterState(codes[i])
interp.run(space)
- return interp.results[0]
+ res = interp.results[0]
+ assert isinstance(res, BaseArray)
+ return interp.space.float_w(res.eval(0).wrap(interp.space))
return self.meta_interp(f, [0], listops=True, backendopt=True)
def test_add(self):
More information about the pypy-commit
mailing list