Author: Maciej Fijalkowski <fij...@gmail.com> Branch: numpy-multidim Changeset: r48938:8e3ada08df4f Date: 2011-11-08 16:43 +0100 http://bitbucket.org/pypy/pypy/changeset/8e3ada08df4f/
Log: a nicely passing test and a test we want to work on 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 @@ -183,3 +183,11 @@ a -> 0 -> 1 """) assert interp.results[0].value.val == 2 + + def test_multidim_getitem_2(self): + interp = self.run(""" + a = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] + b = a + a + b -> 1 -> 1 + """) + assert interp.results[0].value.val == 8 diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -737,6 +737,11 @@ a = array([[1, 2], [3, 4], [5, 6]]) assert ((a + a) == array([[1+1, 2+2], [3+3, 4+4], [5+5, 6+6]])).all() + def test_getitem_add(self): + from numpy import array + a = array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) + assert (a + a)[1, 1] == 8 + class AppTestSupport(object): def setup_class(cls): import struct 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 @@ -243,6 +243,35 @@ 'setarrayitem_raw': 1, 'int_add': 3, 'int_lt': 1, 'guard_true': 1, 'jump': 1}) + def define_multidim(): + return """ + a = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] + b = a + a + b -> 1 -> 1 + """ + + def test_multidim(self): + result = self.run('multidim') + assert result == 8 + self.check_loops({'float_add': 1, 'getarrayitem_raw': 2, + 'guard_true': 1, 'int_add': 1, 'int_lt': 1, + 'jump': 1, 'setarrayitem_raw': 1}) + + def define_multidim_slice(): + return """ + a = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]] + b = a -> ::2 + c = b + b + c -> 1 -> 1 + """ + + def test_multidim_slice(self): + result = self.run('multidim_slice') + assert result == 12 + py.test.skip("improve") + self.check_loops({}) + + class TestNumpyOld(LLJitMixin): def setup_class(cls): py.test.skip("old") _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit