Daniel Roberts avatar Daniel Roberts committed 14cbc93

Preparing for sync with trunk.

Comments (0)

Files changed (1)

pypy/module/micronumpy/microarray.py

     def __init__(self, array):
         self.array = array
         self.i = 0
+        self.shape = array.shape[0]
         self.step = array.slice_steps[0]
-        self.shape = array.shape[0]
         self.stride = array.strides[0]
         self.ndim = len(array.shape)
         self.offset = 0
 
 
 class MicroArray(BaseNumArray):
-    _immutable_fields_ = ['shape', 'parent', 'strides', 'offset', 'slice_starts']
+    _immutable_fields_ = ['parent', 'data', 'offset', 'shape', 'slice_steps', 'strides']
     def __init__(self, shape, dtype,
                  order='C', strides=None, parent=None,
                  offset=0, slice_steps=None):
                 offset += start * self.slice_steps[i] * self.strides[i]
                 shape[resdim] = length
                 slice_steps[resdim] = self.slice_steps[i] * step
+                strides[resdim] = self.strides[i]
                 resdim += 1
             elif space.is_w(w_index, space.w_Ellipsis):
                 shape[resdim] = self.shape[i]
 
         size = size_from_shape(shape)
 
-        if size == 0:
+        if len(shape) == 0:
             return self.getitem(space, offset)
         else:
             ar = MicroArray(shape,
         dtype = self.dtype.dtype
 
         offset, shape, slice_steps, strides = self.index2slices(space, w_index)
+        #print "Shape:", shape, "Steps:", slice_steps, "Strides:", strides
 
         size = size_from_shape(shape)
 
         try:
-            # XXX: if size is 0 we shouldn't really infer
             value_shape = infer_shape(space, w_value)
             value_size = size_from_shape(value_shape)
         except OperationError, e:
                 value_size = 0
             else: raise
 
-        if size == 0:
+        if len(value_shape) == 0 and len(shape) > 0:
+            self.set_slice_single_value(space, offset, shape, slice_steps, strides,
+                                        self.dtype.dtype.coerce(space, w_value))
+        elif len(shape) == 0:
             if len(value_shape) > 0:
                 raise OperationError(space.w_ValueError,
                                      space.wrap("shape mismatch: objects cannot"
 
             self.setitem(space, offset, self.dtype.dtype.coerce(space, w_value))
         else:
-            if squeeze_shape(value_shape) != squeeze_shape(shape):
+            if shape != value_shape:
                 raise OperationError(space.w_ValueError,
                                      space.wrap("shape mismatch: objects cannot"
                                                 " be broadcast to a single shape"))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.