Author: mattip
Branch: numppy-flatitter
Changeset: r51844:32b53b45a4c3
Date: 2012-01-27 11:42 +0200
http://bitbucket.org/pypy/pypy/changeset/32b53b45a4c3/

Log:    failed attempt to redo compile.py

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
@@ -9,7 +9,7 @@
 from pypy.module.micronumpy import interp_boxes
 from pypy.module.micronumpy.interp_dtype import get_dtype_cache
 from pypy.module.micronumpy.interp_numarray import (Scalar, BaseArray,
-     scalar_w, W_NDimArray, array, W_FlatIterator)
+     scalar_w, W_NDimArray, array)
 from pypy.module.micronumpy import interp_ufuncs
 from pypy.rlib.objectmodel import specialize, instantiate
 
@@ -32,7 +32,7 @@
 class BadToken(Exception):
     pass
 
-SINGLE_ARG_FUNCTIONS = ["sum", "prod", "max", "min", "all", "any", "unegative"]
+SINGLE_ARG_FUNCTIONS = ["sum", "prod", "max", "min", "all", "any", 
"unegative", "flat"]
 
 class FakeSpace(object):
     w_ValueError = None
@@ -313,21 +313,6 @@
     def __repr__(self):
         return 'Range(%s)' % self.v
 
-class FlatIterFromRange(Node):
-    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 = get_dtype_cache(interp.space).w_float64dtype
-        return W_FlatIterator(array(interp.space, w_list, w_dtype=dtype, 
-                                w_order=None))
-
-    def __repr__(self):
-        return 'FlatFromRange(%s)' % self.v
-
 class Code(Node):
     def __init__(self, statements):
         self.statements = statements
@@ -411,6 +396,8 @@
             elif self.name == "unegative":
                 neg = interp_ufuncs.get(interp.space).negative
                 w_res = neg.call(interp.space, [arr])
+            elif self.name == "flat":
+                w_res = arr.descr_flat(interp.space)
             else:
                 assert False # unreachable code
             if isinstance(w_res, BaseArray):
@@ -437,7 +424,6 @@
     ('=', 'assign'),
     (',', 'comma'),
     ('\|', 'pipe'),
-    ('\!', 'exclaim'),
     ('\(', 'paren_left'),
     ('\)', 'paren_right'),
 ]
@@ -544,10 +530,6 @@
                 stack.append(RangeConstant(tokens.pop().v))
                 end = tokens.pop()
                 assert end.name == 'pipe'
-            elif token.name == 'exclaim':
-                stack.append(FlatIterFromRange(tokens.pop().v))
-                end = tokens.pop()
-                assert end.name == 'exclaim'
             elif accept_comma and token.name == 'comma':
                 continue
             else:
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
@@ -371,7 +371,8 @@
                                 'arraylen_gc': 1})
     def define_flat_iter():
         return '''
-        !30!
+        a = |30|
+        flat(a)
         '''
 
     def test_flat_iter(self):
@@ -380,8 +381,9 @@
 
     def define_flat_getitem():
         return '''
-        a = !30!
-        a -> 6
+        a = |30|
+        b = flat(a)
+        b -> 6
         '''
 
     def test_flat_getitem(self):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to