[pypy-commit] pypy default: fix setitem using array scalars also
bdkearns
noreply at buildbot.pypy.org
Mon Nov 18 20:49:13 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r68220:c16f3a1dbc73
Date: 2013-11-18 14:48 -0500
http://bitbucket.org/pypy/pypy/changeset/c16f3a1dbc73/
Log: fix setitem using array scalars also
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
@@ -213,7 +213,8 @@
self.implementation.setitem_index(space, index_list, w_value)
def descr_setitem(self, space, w_idx, w_value):
- if isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool_type():
+ if isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool_type() \
+ and len(w_idx.get_shape()) > 0:
self.setitem_filter(space, w_idx, convert_to_array(space, w_value))
return
try:
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
@@ -1869,11 +1869,19 @@
[7, 8, 9]])
assert (a[np.array(0)] == a[0]).all()
assert (a[np.array(1)] == a[1]).all()
+ assert (a[np.array(True)] == a[1]).all()
+ assert (a[np.array(False)] == a[0]).all()
exc = raises(IndexError, "a[np.array(1.1)]")
assert exc.value.message == 'arrays used as indices must be of ' \
'integer (or boolean) type'
- assert (a[np.array(True)] == a[1]).all()
- assert (a[np.array(False)] == a[0]).all()
+
+ a[np.array(1)] = a[2]
+ assert a[1][1] == 8
+ a[np.array(True)] = a[0]
+ assert a[1][1] == 2
+ exc = raises(IndexError, "a[np.array(1.1)] = a[2]")
+ assert exc.value.message == 'arrays used as indices must be of ' \
+ 'integer (or boolean) type'
def test_bool_array_index(self):
from numpypy import arange, array
More information about the pypy-commit
mailing list