mattip  committed 995703e

fix translation

  • Participants
  • Parent commits 47a1da6
  • Branches numpypy-array_prepare_-array_wrap

Comments (0)

Files changed (2)

File pypy/module/micronumpy/

     def descr___array_prepare__(self, space, w_array, w_context):
         # stub implementation of __array_prepare__()
-        if isinstance(w_array, (W_NDimArray, interp_boxes.Box)):
+        if isinstance(w_array, W_NDimArray) or \
+           isinstance(w_array, interp_boxes.Box):
             return w_array
             raise OperationError(space.w_TypeError,

File pypy/module/micronumpy/

         if out:
             return out
-        if not type(obj) == W_NDimArray:
+        if type(obj) is not W_NDimArray:
             #If obj is a subtype of W_NDimArray, return a empty-shape instance
             out = W_NDimArray.from_shape(space, [], dtype, w_instance=obj)
         return res
     def call_prepare(self, space, w_out, w_obj, w_result):
+        assert isinstance(w_result, W_NDimArray)
         if isinstance(w_out, W_NDimArray):
             w_array = space.lookup(w_out, "__array_prepare__")
             w_caller = w_out
             w_caller = w_obj
         if w_array:
             w_retVal = space.get_and_call_function(w_array, w_caller, w_result, None)
-            if not isinstance(w_retVal, (W_NDimArray, interp_boxes.Box)):
+            if not isinstance(w_retVal, W_NDimArray) and \
+               not isinstance(w_retVal, interp_boxes.Box):
                 raise OperationError(space.w_ValueError,
                     space.wrap( "__array_prepare__ must return an "
                                 "ndarray or subclass thereof"))