[pypy-commit] pypy numpy-refactor: tolist, simplified
fijal
noreply at buildbot.pypy.org
Wed Sep 5 19:00:04 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-refactor
Changeset: r57157:39505d9f7094
Date: 2012-09-05 18:43 +0200
http://bitbucket.org/pypy/pypy/changeset/39505d9f7094/
Log: tolist, simplified
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
@@ -151,6 +151,15 @@
def descr_get_transpose(self, space):
return W_NDimArray(self.implementation.transpose())
+ def descr_tolist(self, space):
+ if len(self.get_shape()) == 0:
+ return self.get_scalar_value().item(space)
+ l_w = []
+ for i in range(self.get_shape()[0]):
+ l_w.append(space.call_method(self.descr_getitem(space,
+ space.wrap(i)), "tolist"))
+ return space.newlist(l_w)
+
# --------------------- operations ----------------------------
def _unaryop_impl(ufunc_name):
@@ -394,6 +403,7 @@
copy = interp2app(W_NDimArray.descr_copy),
reshape = interp2app(W_NDimArray.descr_reshape),
T = GetSetProperty(W_NDimArray.descr_get_transpose),
+ tolist = interp2app(W_NDimArray.descr_tolist),
)
def decode_w_dtype(space, w_dtype):
More information about the pypy-commit
mailing list