[pypy-commit] pypy numpy-back-to-applevel: a pretty important fix for item and more tests, bad fijal
fijal
noreply at buildbot.pypy.org
Thu Jan 26 21:59:54 CET 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-back-to-applevel
Changeset: r51818:f5834bdc4464
Date: 2012-01-26 22:40 +0200
http://bitbucket.org/pypy/pypy/changeset/f5834bdc4464/
Log: a pretty important fix for item and more tests, bad fijal
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
@@ -651,7 +651,10 @@
raise OperationError(space.w_ValueError, space.wrap("index out of bounds"))
return self.value.item(space)
if space.isinstance_w(w_arg, space.w_int):
- i = to_coords(space, self.shape, self.size, self.order, w_arg)[0]
+ if isinstance(self, Scalar):
+ raise OperationError(space.w_ValueError, space.wrap("index out of bounds"))
+ concr = self.get_concrete()
+ i = to_coords(space, self.shape, concr.size, concr.order, w_arg)[0]
# XXX a bit around
return self.descr_getitem(space, space.newtuple([space.wrap(x)
for x in i])).item(space)
@@ -677,7 +680,6 @@
Intermediate class representing a literal.
"""
size = 1
- order = 'C'
_attrs_ = ["dtype", "value", "shape"]
def __init__(self, dtype, value):
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
@@ -1487,6 +1487,10 @@
assert array([3]).item(0) == 3
assert type(array([3]).item(0)) is int
assert array([1, 2, 3]).item(-1) == 3
+ a = array([1, 2, 3])
+ assert a[::2].item(1) == 3
+ assert (a + a).item(1) == 4
+ raises(ValueError, "array(5).item(1)")
class AppTestSupport(BaseNumpyAppTest):
def setup_class(cls):
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -181,7 +181,7 @@
return v1 >= v2
def bool(self, v):
- return bool(self.for_computation(self.unbox(v)))
+ return self.for_computation(self.unbox(v)) != 0
@simple_binary_op
def max(self, v1, v2):
More information about the pypy-commit
mailing list