[pypy-commit] pypy numpy-record-dtypes: remove silliness of str_format, make it back rpython. fix test
fijal
noreply at buildbot.pypy.org
Fri Feb 17 16:11:16 CET 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-record-dtypes
Changeset: r52588:faae60a012bd
Date: 2012-02-17 17:10 +0200
http://bitbucket.org/pypy/pypy/changeset/faae60a012bd/
Log: remove silliness of str_format, make it back rpython. fix test
diff --git a/pypy/module/micronumpy/test/test_iter.py b/pypy/module/micronumpy/test/test_iter.py
--- a/pypy/module/micronumpy/test/test_iter.py
+++ b/pypy/module/micronumpy/test/test_iter.py
@@ -49,17 +49,17 @@
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
@@ -72,17 +72,17 @@
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()
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -88,9 +88,6 @@
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
@@ -272,8 +269,8 @@
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)
@@ -303,8 +300,8 @@
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)
@@ -474,8 +471,8 @@
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):
@@ -690,8 +687,7 @@
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)
More information about the pypy-commit
mailing list