[pypy-commit] pypy numpy-minilang: cleanup

fijal noreply at buildbot.pypy.org
Fri Oct 28 00:22:04 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-minilang
Changeset: r48547:7861ff043f50
Date: 2011-10-28 00:21 +0200
http://bitbucket.org/pypy/pypy/changeset/7861ff043f50/

Log:	cleanup

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
@@ -4,7 +4,7 @@
 """
 
 from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
-from pypy.module.micronumpy.interp_dtype import W_Float64Dtype, W_Int32Dtype
+from pypy.module.micronumpy.interp_dtype import W_Float64Dtype
 from pypy.module.micronumpy.interp_numarray import Scalar, BaseArray, descr_new_array
 from pypy.rlib.objectmodel import specialize
 
@@ -12,12 +12,6 @@
 class BogusBytecode(Exception):
     pass
 
-def create_array(dtype, size):
-    a = SingleDimArray(size, dtype=dtype)
-    for i in range(size):
-        dtype.setitem(a.storage, i, dtype.box(float(i % 10)))
-    return a
-
 class FakeSpace(object):
     w_ValueError = None
     w_TypeError = None
@@ -323,50 +317,3 @@
 def numpy_compile(code):
     parser = Parser()
     return InterpreterState(parser.parse(code))
-
-def xxx_numpy_compile(bytecode, array_size):
-    stack = []
-    i = 0
-    dtype = space.fromcache(W_Float64Dtype)
-    for b in bytecode:
-        if b == 'a':
-            stack.append(create_array(dtype, array_size))
-            i += 1
-        elif b == 'f':
-            stack.append(Scalar(dtype, dtype.box(1.2)))
-        elif b == '+':
-            right = stack.pop()
-            res = stack.pop().descr_add(space, right)
-            assert isinstance(res, BaseArray)
-            stack.append(res)
-        elif b == '-':
-            right = stack.pop()
-            res = stack.pop().descr_sub(space, right)
-            assert isinstance(res, BaseArray)
-            stack.append(res)
-        elif b == '*':
-            right = stack.pop()
-            res = stack.pop().descr_mul(space, right)
-            assert isinstance(res, BaseArray)
-            stack.append(res)
-        elif b == '/':
-            right = stack.pop()
-            res = stack.pop().descr_div(space, right)
-            assert isinstance(res, BaseArray)
-            stack.append(res)
-        elif b == '%':
-            right = stack.pop()
-            res = stack.pop().descr_mod(space, right)
-            assert isinstance(res, BaseArray)
-            stack.append(res)
-        elif b == '|':
-            res = stack.pop().descr_abs(space)
-            assert isinstance(res, BaseArray)
-            stack.append(res)
-        else:
-            print "Unknown opcode: %s" % b
-            raise BogusBytecode()
-    if len(stack) != 1:
-        print "Bogus bytecode, uneven stack length"
-        raise BogusBytecode()
-    return stack[0]
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
@@ -58,7 +58,7 @@
                           "setarrayitem_raw": 1, "int_add": 1,
                           "int_lt": 1, "guard_true": 1, "jump": 1})
 
-class TstXyz(object):
+class DisabledTestNumpy(object):
     def test_sum(self):
         space = self.space
         float64_dtype = self.float64_dtype
@@ -342,17 +342,3 @@
         result = self.meta_interp(f, [5], listops=True, backendopt=True)
         assert result == f(5)
 
-class TestTranslation(object):
-    def test_compile(self):
-        x = numpy_compile('aa+f*f/a-', 10)
-        x = x.compute()
-        assert isinstance(x, SingleDimArray)
-        assert x.size == 10
-        assert x.eval(0).val == 0
-        assert x.eval(1).val == ((1 + 1) * 1.2) / 1.2 - 1
-
-    def test_translation(self):
-        # we import main to check if the target compiles
-        from pypy.translator.goal.targetnumpystandalone import main
-
-        interpret(main, [llstr('af+'), 100])


More information about the pypy-commit mailing list