Author: Brian Kearns <[email protected]>
Branch:
Changeset: r68522:31ccdc34a8cb
Date: 2013-12-20 19:10 -0500
http://bitbucket.org/pypy/pypy/changeset/31ccdc34a8cb/
Log: fix recordtype store data
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
@@ -3101,10 +3101,10 @@
assert repr(a[0]) == '(1, 2.0)'
def test_nested_dtype(self):
- from numpypy import zeros
+ import numpy as np
a = [('x', int), ('y', float)]
b = [('x', int), ('y', a)]
- arr = zeros((), dtype=b)
+ arr = np.zeros((), dtype=b)
assert arr['x'] == 0
arr['x'] = 2
assert arr['x'] == 2
@@ -3114,9 +3114,13 @@
assert exc.value.message == "field named xx not found"
assert arr['y'].dtype == a
assert arr['y'].shape == ()
- #assert arr['y'][()]['x'] == 0
- #assert arr['y'][()]['y'] == 0
- arr = zeros(3, dtype=b)
+ assert arr['y'][()]['x'] == 0
+ assert arr['y'][()]['y'] == 0
+ arr['y'][()]['x'] = 2
+ arr['y'][()]['y'] = 3
+ assert arr['y'][()]['x'] == 2
+ assert arr['y'][()]['y'] == 3
+ arr = np.zeros(3, dtype=b)
arr[1]['x'] = 15
assert arr[1]['x'] == 15
arr[1]['y']['y'] = 3.5
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
@@ -1847,7 +1847,7 @@
def store(self, arr, i, ofs, box):
assert isinstance(box, interp_boxes.W_VoidBox)
for k in range(box.dtype.get_size()):
- arr.storage[k + i] = box.arr.storage[k + box.ofs]
+ arr.storage[k + i + ofs] = box.arr.storage[k + box.ofs]
def to_builtin_type(self, space, box):
assert isinstance(box, interp_boxes.W_VoidBox)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit