Commits

Maciej Fijalkowski committed faae60a

remove silliness of str_format, make it back rpython. fix test

Comments (0)

Files changed (2)

pypy/module/micronumpy/test/test_iter.py

         backstrides = [x * (y - 1) for x,y in zip(strides, shape)]
         assert backstrides == [10, 4]
         i = ViewIterator(start, strides, backstrides, shape)
-        i = i.next_skip_ofs(2,2)
-        i = i.next_skip_ofs(2,2)
-        i = i.next_skip_ofs(2,2)
+        i = i.next_skip_x(2,2)
+        i = i.next_skip_x(2,2)
+        i = i.next_skip_x(2,2)
         assert i.offset == 6
         assert not i.done()
         assert i.indices == [1,1]
         #And for some big skips
-        i = i.next_skip_ofs(2,5)
+        i = i.next_skip_x(2,5)
         assert i.offset == 11
         assert i.indices == [2,1]
-        i = i.next_skip_ofs(2,5)
+        i = i.next_skip_x(2,5)
         # Note: the offset does not overflow but recycles,
         # this is good for broadcast
         assert i.offset == 1
         backstrides = [x * (y - 1) for x,y in zip(strides, shape)]
         assert backstrides == [2, 12]
         i = ViewIterator(start, strides, backstrides, shape)
-        i = i.next_skip_ofs(2,2)
-        i = i.next_skip_ofs(2,2)
-        i = i.next_skip_ofs(2,2)
+        i = i.next_skip_x(2,2)
+        i = i.next_skip_x(2,2)
+        i = i.next_skip_x(2,2)
         assert i.offset == 4
         assert i.indices == [1,1]
         assert not i.done()
-        i = i.next_skip_ofs(2,5)
+        i = i.next_skip_x(2,5)
         assert i.offset == 5
         assert i.indices == [2,1]
         assert not i.done()
-        i = i.next_skip_ofs(2,5)
+        i = i.next_skip_x(2,5)
         assert i.indices == [0,1]
         assert i.offset == 3
         assert i.done()

pypy/module/micronumpy/types.py

     def box(self, value):
         return self.BoxType(rffi.cast(self.T, value))
 
-    def str_format(self, box):
-        return self._str_format(self.unbox(box))
-
     def unbox(self, box):
         assert isinstance(box, self.BoxType)
         return box.value
     def to_builtin_type(self, space, w_item):
         return space.wrap(self.unbox(w_item))
 
-    def _str_format(self, value):
-        return "True" if value else "False"
+    def str_format(self, box):
+        return "True" if self.unbox(box) else "False"
 
     def for_computation(self, v):
         return int(v)
     def _coerce(self, space, w_item):
         return self._base_coerce(space, w_item)
 
-    def _str_format(self, value):
-        return str(self.for_computation(value))
+    def str_format(self, box):
+        return str(self.for_computation(self.unbox(box)))
 
     def for_computation(self, v):
         return widen(v)
     def _coerce(self, space, w_item):
         return self.box(space.float_w(space.call_function(space.w_float, w_item)))
 
-    def _str_format(self, value):
-        return float2string(self.for_computation(value), "g",
+    def str_format(self, box):
+        return float2string(self.for_computation(self.unbox(box)), "g",
                             rfloat.DTSF_STR_PRECISION)
 
     def for_computation(self, v):
                 first = False
             else:
                 pieces.append(", ")
-            pieces.append(tp._str_format(tp._read(box.arr.storage, 1, box.ofs,
-                                                  ofs)))
+            pieces.append(tp.str_format(tp.read(box.arr, 1, box.ofs, ofs)))
         pieces.append(")")
         return "".join(pieces)