Author: Brian Kearns <[email protected]>
Branch:
Changeset: r68521:c477a1c101c4
Date: 2013-12-20 18:50 -0500
http://bitbucket.org/pypy/pypy/changeset/c477a1c101c4/
Log: fix scalar recordtype getitem
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
@@ -134,8 +134,7 @@
elif space.isinstance_w(w_idx, space.w_str):
if self.dtype.is_record_type():
w_val = self.value.descr_getitem(space, w_idx)
- assert isinstance(w_val, W_GenericBox)
- return w_val.descr_ravel(space)
+ return convert_to_array(space, w_val)
elif space.is_none(w_idx):
new_shape = [1]
arr = W_NDimArray.from_shape(space, new_shape, self.dtype)
diff --git a/pypy/module/micronumpy/interp_boxes.py
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -421,7 +421,7 @@
self.dtype = dtype
def get_dtype(self, space):
- return self.arr.dtype
+ return self.dtype
def raw_str(self):
return self.arr.dtype.itemtype.to_str(self)
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
@@ -3112,10 +3112,10 @@
assert exc.value.message == "0-d arrays can't be indexed"
exc = raises(ValueError, "arr['xx'] = 2")
assert exc.value.message == "field named xx not found"
- arr['y']
- #assert arr['y'].shape == ()
- #assert arr['y'][()][0] == 0
- #assert arr['y'][()][0] == 0
+ assert arr['y'].dtype == a
+ assert arr['y'].shape == ()
+ #assert arr['y'][()]['x'] == 0
+ #assert arr['y'][()]['y'] == 0
arr = zeros(3, dtype=b)
arr[1]['x'] = 15
assert arr[1]['x'] == 15
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit