Author: Ilya Osadchiy <[email protected]>
Branch:
Changeset: r44900:59ffcf1d2531
Date: 2011-06-12 23:51 +0300
http://bitbucket.org/pypy/pypy/changeset/59ffcf1d2531/
Log: numpy: addit test_zjit for slicing
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
@@ -1,6 +1,6 @@
from pypy.jit.metainterp.test.support import LLJitMixin
from pypy.module.micronumpy.interp_numarray import (SingleDimArray, Signature,
- FloatWrapper, Call1, Call2, add, mul)
+ FloatWrapper, Call1, Call2, SingleDimSlice, add, mul)
from pypy.module.micronumpy.interp_ufuncs import negative
@@ -91,4 +91,38 @@
self.meta_interp(f, [5], listops=True, backendopt=True)
# This is 3, not 2 because there is a bridge for the exit.
- self.check_loop_count(3)
\ No newline at end of file
+ self.check_loop_count(3)
+
+ def test_slice(self):
+ space = self.space
+
+ def f(i):
+ step = 3
+ ar = SingleDimArray(step*i)
+ s = SingleDimSlice(0, step*i, step, i, ar,
ar.signature.transition(SingleDimSlice.static_signature))
+ v = Call2(add, s, s, Signature())
+ return v.get_concrete().storage[3]
+
+ result = self.meta_interp(f, [5], listops=True, backendopt=True)
+ self.check_loops({'int_mul': 1, 'getarrayitem_raw': 2, 'float_add': 1,
+ 'setarrayitem_raw': 1, 'int_add': 1,
+ 'int_lt': 1, 'guard_true': 1, 'jump': 1})
+ assert result == f(5)
+
+ def test_slice2(self):
+ space = self.space
+
+ def f(i):
+ step1 = 2
+ step2 = 3
+ ar = SingleDimArray(step2*i)
+ s1 = SingleDimSlice(0, step1*i, step1, i, ar,
ar.signature.transition(SingleDimSlice.static_signature))
+ s2 = SingleDimSlice(0, step2*i, step2, i, ar,
ar.signature.transition(SingleDimSlice.static_signature))
+ v = Call2(add, s1, s2, Signature())
+ return v.get_concrete().storage[3]
+
+ result = self.meta_interp(f, [5], listops=True, backendopt=True)
+ self.check_loops({'int_mul': 2, 'getarrayitem_raw': 2, 'float_add': 1,
+ 'setarrayitem_raw': 1, 'int_add': 1,
+ 'int_lt': 1, 'guard_true': 1, 'jump': 1})
+ assert result == f(5)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit