[pypy-commit] pypy numpy-multidim: kill a function that was only used by one test. a bit pep-8ify, not too

fijal noreply at buildbot.pypy.org
Thu Nov 3 16:41:32 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-multidim
Changeset: r48704:fa14e6831e42
Date: 2011-11-03 16:41 +0100
http://bitbucket.org/pypy/pypy/changeset/fa14e6831e42/

Log:	kill a function that was only used by one test. a bit pep-8ify, not
	too much though

diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -7,7 +7,6 @@
 from pypy.rpython.lltypesystem import lltype
 from pypy.tool.sourcetools import func_with_new_name
 
-
 numpy_driver = jit.JitDriver(greens = ['signature'],
                              reds = ['result_size', 'i', 'self', 'result'])
 all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self',
@@ -209,25 +208,6 @@
             assert isinstance(w_res, BaseArray)
             return w_res.descr_sum(space)
 
-    def _getnums(self, comma):
-        dtype = self.find_dtype()
-        if self.find_size() > 1000:
-            nums = [
-                dtype.str_format(self.eval(index))
-                for index in range(3)
-            ]
-            nums.append("..." + "," * comma)
-            nums.extend([
-                dtype.str_format(self.eval(index))
-                for index in range(self.find_size() - 3, self.find_size())
-            ])
-        else:
-            nums = [
-                dtype.str_format(self.eval(index))
-                for index in range(self.find_size())
-            ]
-        return nums
-
     def get_concrete(self):
         raise NotImplementedError
 
@@ -269,7 +249,8 @@
         # Since what we want is to print a plethora of 2d views, let
         # a slice do the work for us.
         concrete = self.get_concrete()
-        return space.wrap(NDimSlice(concrete, self.signature, [], self.shape).tostr(False))
+        r = NDimSlice(concrete, self.signature, [], self.shape).tostr(False)
+        return space.wrap(r)
 
     def _index_of_single_item(self, space, w_idx):
         # we assume C ordering for now
@@ -641,7 +622,6 @@
     @jit.unroll_safe
     def calc_index(self, item):
         index = []
-        __item = item
         _item = item
         for i in range(len(self.shape) -1, 0, -1):
             s = self.shape[i]
@@ -671,18 +651,21 @@
             item += index[i]
             i += 1
         return item
-    def tostr(self, comma,indent=' '):
+    
+    def tostr(self, comma, indent=' '):
         ret = ''
         dtype = self.find_dtype()
         ndims = len(self.shape)#-self.shape_reduction
         for s in self.shape:
-            if s==0:
+            if s == 0:
                 ret += '[]'
                 return ret
-        if ndims>2:
+        if ndims > 2:
             ret += '['
             for i in range(self.shape[0]):
-                ret += NDimSlice(self.parent, self.signature, [(i,0,0,1)], self.shape[1:]).tostr(comma,indent=indent+' ')
+                chunks = [(i, 0, 0, 1)]
+                ret += NDimSlice(self.parent, self.signature, chunks,
+                                 self.shape[1:]).tostr(comma,indent=indent + ' ')
                 if i+1<self.shape[0]:
                     ret += ',\n\n'+ indent
             ret += ']'
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
@@ -102,10 +102,11 @@
         code = """
         a = [1,2,3,4]
         b = [4,5,6,5]
-        a + b
+        c = a + b
+        c -> 3
         """
         interp = self.run(code)
-        assert interp.results[0]._getnums(False) == ["5.0", "7.0", "9.0", "9.0"]
+        assert interp.results[-1].value.val == 9
 
     def test_array_getitem(self):
         code = """


More information about the pypy-commit mailing list