[pypy-commit] pypy object-dtype2: test, fix for numpy object scalar actually becoming the contained object
mattip
noreply at buildbot.pypy.org
Wed Apr 22 21:53:14 CEST 2015
Author: mattip <matti.picus at gmail.com>
Branch: object-dtype2
Changeset: r76891:e91a14676362
Date: 2015-04-22 22:07 +0300
http://bitbucket.org/pypy/pypy/changeset/e91a14676362/
Log: test, fix for numpy object scalar actually becoming the contained
object
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
@@ -202,12 +202,16 @@
return self
elif isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool() \
and w_idx.ndims() > 0:
- return self.getitem_filter(space, w_idx)
+ w_ret = self.getitem_filter(space, w_idx)
else:
try:
- return self.implementation.descr_getitem(space, self, w_idx)
+ w_ret = self.implementation.descr_getitem(space, self, w_idx)
except ArrayArgumentException:
- return self.getitem_array_int(space, w_idx)
+ w_ret = self.getitem_array_int(space, w_idx)
+ if isinstance(w_ret, boxes.W_ObjectBox):
+ #return the W_Root object, not a scalar
+ w_ret = w_ret.w_obj
+ return w_ret
def getitem(self, space, index_list):
return self.implementation.getitem_index(space, index_list)
diff --git a/pypy/module/micronumpy/test/test_object_arrays.py b/pypy/module/micronumpy/test/test_object_arrays.py
--- a/pypy/module/micronumpy/test/test_object_arrays.py
+++ b/pypy/module/micronumpy/test/test_object_arrays.py
@@ -117,14 +117,15 @@
b = np.object_(3)
b2 = np.object_(3.0)
c = np.object_([4, 5])
- d = np.object_([None, {}, []])
- print type(a)
+ d = np.array([None])[0]
assert a is None
assert type(b) is int
assert type(b2) is float
assert type(c) is np.ndarray
assert c.dtype == object
- assert d.dtype == object
+ assert type(d) is type(None)
+ e = np.object_([None, {}, []])
+ assert e.dtype == object
def test_mem_array_creation_invalid_specification(self):
# while not specifically testing object dtype, this
More information about the pypy-commit
mailing list