[pypy-svn] r46855 - in pypy/dist/pypy/rpython/numpy: . test

simonb at codespeak.net simonb at codespeak.net
Tue Sep 25 03:23:28 CEST 2007


Author: simonb
Date: Tue Sep 25 03:23:27 2007
New Revision: 46855

Modified:
   pypy/dist/pypy/rpython/numpy/rarray.py
   pypy/dist/pypy/rpython/numpy/test/test_array.py
Log:
add some tests; skip for now

Modified: pypy/dist/pypy/rpython/numpy/rarray.py
==============================================================================
--- pypy/dist/pypy/rpython/numpy/rarray.py	(original)
+++ pypy/dist/pypy/rpython/numpy/rarray.py	Tue Sep 25 03:23:27 2007
@@ -20,7 +20,6 @@
     GcArray, GcStruct, Number, Primitive, Signed, Ptr, Unsigned, Char, Void, FixedSizeArray, Bool,\
     GcForwardReference, malloc, direct_arrayitems, direct_ptradd, nullptr, typeMethod,\
     cast_primitive
-from pypy.rpython.lltypesystem.rffi import cast
 from pypy.rpython.lltypesystem.rtuple import TupleRepr
 
 def gen_build_from_shape(ndim, zero=False):
@@ -647,6 +646,7 @@
                 r_item, v_item = convert_scalar_to_array(r_item, v_item, hop.llops)
                 source_ndim = 1
             elif isinstance(r_item, AbstractBaseListRepr):
+                # Note this does a copy:
                 r_item, v_item = convert_list_to_array(r_item, v_item, hop.llops)
                 source_ndim = 1
             else:

Modified: pypy/dist/pypy/rpython/numpy/test/test_array.py
==============================================================================
--- pypy/dist/pypy/rpython/numpy/test/test_array.py	(original)
+++ pypy/dist/pypy/rpython/numpy/test/test_array.py	Tue Sep 25 03:23:27 2007
@@ -829,6 +829,37 @@
         for i in range(len(data)):
             assert res.dataptr[i] == data[i]//2
 
+    def test_specialize_array_setitem_alias(self):
+        py.test.skip('not implemented')
+        def f():
+            a = numpy.array([1,2,3,4])
+            a[1:] = a[:3]
+            return a
+
+        res = interpret(f, [])
+        data = [1,1,2,3]
+        for i in range(len(data)):
+            assert res.dataptr[i] == data[i]
+
+    def test_specialize_array_inplace_add_alias(self):
+        py.test.skip('not implemented')
+        def f():
+            a = numpy.array([1,2,3,4])
+            a[1:] += a[:3]
+            return a
+
+        res = interpret(f, [])
+        data = [1,3,5,7]
+        for i in range(len(data)):
+            assert res.dataptr[i] == data[i]
+
+"""
+TODO (maybe):
+* indexing with ellipses
+* indexing with newaxis
+* unary plus operator (does a copy)
+* advanced selection: indexing with bool/int arrays (or lists)
+"""
 
 class Test_compile:
     def setup_class(self):



More information about the Pypy-commit mailing list