[pypy-commit] pypy default: hg backout 3eba2ed546ad

arigo noreply at buildbot.pypy.org
Sun Dec 11 13:34:11 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r50379:1c29f19cb8d7
Date: 2011-12-11 13:33 +0100
http://bitbucket.org/pypy/pypy/changeset/1c29f19cb8d7/

Log:	hg backout 3eba2ed546ad

	Does not translate.

	The issue is that to_builtin_type() is not RPython: the result of
	self.unbox() is going to be promoted to the widest possible integer,
	meaning that tests like "assert y.tolist() is True" would fail after
	translation (if it did translate).

diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -91,9 +91,6 @@
     descr_neg = _unaryop_impl("negative")
     descr_abs = _unaryop_impl("absolute")
 
-    def descr_tolist(self, space):
-        return self.get_dtype(space).itemtype.to_builtin_type(space, self)
-
 
 class W_BoolBox(W_GenericBox, PrimitiveBox):
     descr__new__, get_dtype = new_dtype_getter("bool")
@@ -182,8 +179,6 @@
 
     __neg__ = interp2app(W_GenericBox.descr_neg),
     __abs__ = interp2app(W_GenericBox.descr_abs),
-
-    tolist = interp2app(W_GenericBox.descr_tolist),
 )
 
 W_BoolBox.typedef = TypeDef("bool_", W_GenericBox.typedef,
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
@@ -876,17 +876,6 @@
             arr.setshape(space, new_shape)
         return arr
 
-    def descr_tolist(self, space):
-        if len(self.shape) == 0:
-            assert isinstance(self, Scalar)
-            return self.value.descr_tolist(space)
-        w_result = space.newlist([])
-        for i in range(self.shape[0]):
-            space.call_method(w_result, "append",
-                space.call_method(self.descr_getitem(space, space.wrap(i)), "tolist")
-            )
-        return w_result
-
     def descr_mean(self, space):
         return space.div(self.descr_sum(space), space.wrap(self.find_size()))
 
@@ -1496,7 +1485,6 @@
 
     copy = interp2app(BaseArray.descr_copy),
     reshape = interp2app(BaseArray.descr_reshape),
-    tolist = interp2app(BaseArray.descr_tolist),
 )
 
 
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
@@ -879,45 +879,6 @@
         b[0] = 3
         assert b.__debug_repr__() == 'Call2(add, forced=Array)'
 
-    def test_tolist_scalar(self):
-        from numpypy import int32, bool_
-        x = int32(23)
-        assert x.tolist() == 23
-        assert type(x.tolist()) is int
-        y = bool_(True)
-        assert y.tolist() is True
-
-    def test_tolist_zerodim(self):
-        from numpypy import array
-        x = array(3)
-        assert x.tolist() == 3
-        assert type(x.tolist()) is int
-
-    def test_tolist_singledim(self):
-        from numpypy import array
-        a = array(range(5))
-        assert a.tolist() == [0, 1, 2, 3, 4]
-        assert type(a.tolist()[0]) is int
-        b = array([0.2, 0.4, 0.6])
-        assert b.tolist() == [0.2, 0.4, 0.6]
-
-    def test_tolist_multidim(self):
-        from numpypy import array
-        a = array([[1, 2], [3, 4]])
-        assert a.tolist() == [[1, 2], [3, 4]]
-
-    def test_tolist_view(self):
-        from numpypy import array
-        a = array([[1,2],[3,4]])
-        assert (a + a).tolist() == [[2, 4], [6, 8]]
-
-    def test_tolist_slice(self):
-        from numpypy import array
-        a = array([[17.1, 27.2], [40.3, 50.3]])
-        assert a[:,0].tolist() == [17.1, 40.3]
-        assert a[0].tolist() == [17.1, 27.2]
-
-
 class AppTestMultiDim(BaseNumpyAppTest):
     def test_init(self):
         import numpypy
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
@@ -78,9 +78,6 @@
         w_obj.__init__(self._coerce(space, w_item).value)
         return w_obj
 
-    def to_builtin_type(self, space, box):
-        return space.wrap(self.unbox(box))
-
     def _coerce(self, space, w_item):
         raise NotImplementedError
 


More information about the pypy-commit mailing list