[pypy-commit] pypy default: fix segfault for missing getitem_bool on ScalarIterator
bdkearns
noreply at buildbot.pypy.org
Tue Oct 29 20:33:04 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r67693:e1753c519765
Date: 2013-10-29 12:11 -0400
http://bitbucket.org/pypy/pypy/changeset/e1753c519765/
Log: fix segfault for missing getitem_bool on ScalarIterator
diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py b/pypy/module/micronumpy/arrayimpl/scalar.py
--- a/pypy/module/micronumpy/arrayimpl/scalar.py
+++ b/pypy/module/micronumpy/arrayimpl/scalar.py
@@ -1,4 +1,3 @@
-
from pypy.module.micronumpy.arrayimpl import base
from pypy.module.micronumpy.base import W_NDimArray, convert_to_array
from pypy.module.micronumpy import support
@@ -19,6 +18,9 @@
def getitem(self):
return self.v.get_scalar_value()
+ def getitem_bool(self):
+ return self.v.dtype.itemtype.bool(self.v.value)
+
def setitem(self, v):
self.v.set_scalar_value(v)
@@ -181,4 +183,3 @@
def get_buffer(self, space):
raise OperationError(space.w_ValueError, space.wrap(
"cannot point buffer to a scalar"))
-
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
@@ -1779,6 +1779,15 @@
raises(IndexError, "arange(10)[array([10])] = 3")
raises(IndexError, "arange(10)[[-11]] = 3")
+ def test_bool_single_index(self):
+ import numpypy as np
+ a = np.array([[1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9]])
+ a[np.array(True)]; skip("broken") # check for crash but skip rest of test until correct
+ assert (a[np.array(True)] == a[1]).all()
+ assert (a[np.array(False)] == a[0]).all()
+
def test_bool_array_index(self):
from numpypy import arange, array
b = arange(10)
More information about the pypy-commit
mailing list