[pypy-commit] pypy default: provide delitem for ndarray
bdkearns
noreply at buildbot.pypy.org
Tue Oct 29 20:33:10 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r67698:2a3beee2babe
Date: 2013-10-29 13:16 -0400
http://bitbucket.org/pypy/pypy/changeset/2a3beee2babe/
Log: provide delitem for ndarray
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
@@ -218,6 +218,10 @@
except ArrayArgumentException:
self.setitem_array_int(space, w_idx, w_value)
+ def descr_delitem(self, space, w_idx):
+ raise OperationError(space.w_ValueError, space.wrap(
+ "cannot delete array elements"))
+
def descr_len(self, space):
shape = self.get_shape()
if len(shape):
@@ -1065,6 +1069,7 @@
__len__ = interp2app(W_NDimArray.descr_len),
__getitem__ = interp2app(W_NDimArray.descr_getitem),
__setitem__ = interp2app(W_NDimArray.descr_setitem),
+ __delitem__ = interp2app(W_NDimArray.descr_delitem),
__repr__ = interp2app(W_NDimArray.descr_repr),
__str__ = interp2app(W_NDimArray.descr_str),
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
@@ -511,6 +511,12 @@
a[self.CustomIntObject(1)] = 100
assert a[1] == 100
+ def test_delitem(self):
+ import numpypy as np
+ a = np.arange(10)
+ exc = raises(ValueError, 'del a[2]')
+ assert exc.value.message == 'cannot delete array elements'
+
def test_access_swallow_exception(self):
class ErrorIndex(object):
def __index__(self):
More information about the pypy-commit
mailing list