[pypy-commit] pypy numpy-minilang: make old tests pass (just because).
fijal
noreply at buildbot.pypy.org
Fri Oct 28 14:38:22 CEST 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-minilang
Changeset: r48562:c1f7d371f290
Date: 2011-10-28 14:37 +0200
http://bitbucket.org/pypy/pypy/changeset/c1f7d371f290/
Log: make old tests pass (just because).
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
@@ -127,7 +127,6 @@
def __init__(self, items):
self.items = items
-
class InterpreterState(object):
def __init__(self, code):
self.code = code
@@ -197,8 +196,11 @@
def execute(self, interp):
w_lhs = self.lhs.execute(interp)
+ assert isinstance(w_lhs, BaseArray)
+ if isinstance(self.rhs, SliceConstant):
+ # XXX interface has changed on multidim branch
+ raise NotImplementedError
w_rhs = self.rhs.execute(interp)
- assert isinstance(w_lhs, BaseArray)
if self.name == '+':
w_res = w_lhs.descr_add(interp.space, w_rhs)
elif self.name == '*':
@@ -273,6 +275,13 @@
def __repr__(self):
return "[" + ", ".join([repr(item) for item in self.items]) + "]"
+class SliceConstant(Node):
+ def __init__(self):
+ pass
+
+ def __repr__(self):
+ return 'slice()'
+
class Execute(Node):
def __init__(self, expr):
self.expr = expr
@@ -360,6 +369,10 @@
def parse_constant(self, v):
lgt = len(v)-1
assert lgt >= 0
+ if ':' in v:
+ # a slice
+ assert v == ':'
+ return SliceConstant()
if v[0] == '[':
return ArrayConstant([self.parse_constant(elem)
for elem in v[1:lgt].split(",")])
@@ -370,7 +383,7 @@
def is_identifier_or_const(self, v):
c = v[0]
if ((c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or
- (c >= '0' and c <= '9') or c in '-.[|'):
+ (c >= '0' and c <= '9') or c in '-.[|:'):
if v == '-' or v == "->":
return False
return True
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
@@ -158,3 +158,12 @@
max(b)
""")
assert interp.results[0].value.val == 256
+
+ def test_slice(self):
+ py.test.skip("in progress")
+ interp = self.run("""
+ a = [1,2,3,4]
+ b = a -> :
+ b -> 3
+ """)
+ 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
@@ -2,7 +2,7 @@
from pypy.module.micronumpy import interp_ufuncs, signature
from pypy.module.micronumpy.compile import (FakeSpace,
FloatObject, IntObject, numpy_compile, BoolObject)
-from pypy.module.micronumpy.interp_numarray import (BaseArray, SingleDimArray,
+from pypy.module.micronumpy.interp_numarray import (SingleDimArray,
SingleDimSlice)
from pypy.rlib.nonconst import NonConstant
from pypy.rpython.annlowlevel import llstr, hlstr
@@ -182,7 +182,14 @@
self.check_loop_count(3)
-class DisabledTestNumpy(object):
+class TestNumpyOld(LLJitMixin):
+ def setup_class(cls):
+ from pypy.module.micronumpy.compile import FakeSpace
+ from pypy.module.micronumpy.interp_dtype import W_Float64Dtype
+
+ cls.space = FakeSpace()
+ cls.float64_dtype = cls.space.fromcache(W_Float64Dtype)
+
def test_slice(self):
def f(i):
step = 3
More information about the pypy-commit
mailing list