Commits

Brian Kearns committed 31ccdc3

fix recordtype store data

Comments (0)

Files changed (2)

pypy/module/micronumpy/test/test_numarray.py

         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
         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

pypy/module/micronumpy/types.py

     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)