Author: Maciej Fijalkowski <[email protected]>
Branch: numpy-refactor
Changeset: r57221:e880b0cc78bf
Date: 2012-09-07 17:20 +0200
http://bitbucket.org/pypy/pypy/changeset/e880b0cc78bf/
Log: skip take for now, implement compress
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
@@ -211,6 +211,22 @@
"order not implemented"))
return self.descr_reshape(space, [space.wrap(-1)])
+ def descr_take(self, space, w_obj, w_axis=None, w_out=None):
+ # if w_axis is None and w_out is Nont this is an equivalent to
+ # fancy indexing
+ raise Exception("unsupported for now")
+ if not space.is_w(w_axis, space.w_None):
+ raise OperationError(space.w_NotImplementedError,
+ space.wrap("axis unsupported for take"))
+ if not space.is_w(w_out, space.w_None):
+ raise OperationError(space.w_NotImplementedError,
+ space.wrap("out unsupported for take"))
+ return self.getitem_int(space, convert_to_array(space, w_obj))
+
+ def descr_compress(self, space, w_obj, w_axis=None):
+ index = convert_to_array(space, w_obj)
+ return self.getitem_filter(space, index)
+
def descr_flatten(self, space, w_order=None):
if self.is_scalar():
# scalars have no storage
@@ -486,6 +502,8 @@
tolist = interp2app(W_NDimArray.descr_tolist),
flatten = interp2app(W_NDimArray.descr_flatten),
ravel = interp2app(W_NDimArray.descr_ravel),
+ take = interp2app(W_NDimArray.descr_take),
+ compress = interp2app(W_NDimArray.descr_compress),
repeat = interp2app(W_NDimArray.descr_repeat),
swapaxes = interp2app(W_NDimArray.descr_swapaxes),
flat = GetSetProperty(W_NDimArray.descr_get_flatiter),
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
@@ -1966,6 +1966,7 @@
assert (arange(6).reshape(2, 3).T.ravel() == [0, 3, 1, 4, 2, 5]).all()
def test_take(self):
+ skip("we wait for int-based indexing")
from _numpypy import arange
assert (arange(10).take([1, 2, 1, 1]) == [1, 2, 1, 1]).all()
raises(IndexError, "arange(3).take([15])")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit