Commits

Maciej Fijalkowski committed c1f7d37

make old tests pass (just because).

Comments (0)

Files changed (3)

pypy/module/micronumpy/compile.py

     def __init__(self, items):
         self.items = items
 
-
 class InterpreterState(object):
     def __init__(self, code):
         self.code = code
 
     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 == '*':
     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
     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(",")])
     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

pypy/module/micronumpy/test/test_compile.py

         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

pypy/module/micronumpy/test/test_zjit.py

 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
         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.