[pypy-commit] pypy default: allow indexing by lists of floats
mattip
noreply at buildbot.pypy.org
Thu Oct 29 05:20:49 EDT 2015
Author: mattip <matti.picus at gmail.com>
Branch:
Changeset: r80474:1351a22e9a74
Date: 2015-10-29 09:10 +1100
http://bitbucket.org/pypy/pypy/changeset/1351a22e9a74/
Log: allow indexing by lists of floats
diff --git a/pypy/module/micronumpy/ndarray.py b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -144,7 +144,7 @@
return [], w_index.get_shape(), w_index.get_shape(), [w_index]
w_lst = space.listview(w_index)
for w_item in w_lst:
- if not space.isinstance_w(w_item, space.w_int):
+ if not (space.isinstance_w(w_item, space.w_int) or space.isinstance_w(w_item, space.w_float)):
break
else:
arr = convert_to_array(space, w_index)
diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -676,6 +676,12 @@
a[self.CustomIntObject(1)] = 100
assert a[1] == 100
+ def test_setitem_list_of_float(self):
+ from numpy import arange
+ a = arange(10)
+ a[[0.9]] = -10
+ assert a[0] == -10
+
def test_delitem(self):
import numpy as np
a = np.arange(10)
More information about the pypy-commit
mailing list